go away spammer

Author Topic: trying to build a line follower robot  (Read 5787 times)

0 Members and 1 Guest are viewing this topic.

Offline minmxTopic starter

  • Jr. Member
  • **
  • Posts: 7
  • Helpful? 0
trying to build a line follower robot
« on: April 27, 2010, 09:12:27 PM »
hi, I'm new in all of this informatics systems and i have a question that my group and i, and we can't answer it: ??? ???
I'm building a line follower robot and i have two sensor, right and left, their are a photosensors. I'm using flowcode to program my pic, with C language. my pic is 16F84A

how and where we can program a servomotor with the PWM function:

RL(left receptor)=0 RR(right receptor)=0 PWM=1.5ms

RL=0 RR=1 PWM=1.8ms

RL=1 RR=0 PWM=0.8ms

RL=1 RR=1 PWM=0.8

if you could help me thanks you so much. :) ;D :)

also if you could give me the instructions to make the configuration of my servo
« Last Edit: April 27, 2010, 09:35:51 PM by minmx »

Offline Soeren

  • Supreme Robot
  • *****
  • Posts: 4,672
  • Helpful? 227
  • Mind Reading: 0.0
Re: trying to build a line follower robot
« Reply #1 on: April 27, 2010, 09:36:10 PM »
Hi,

FlowCode will only help you build the skeleton of the system. When that's done, break out of FlowCode and program the functions that is not inherent in FlowCode directly in C or inline assembler.

If you have the least say in the choice of controller, opt for a more up to date variant, even its successor is out of production now.
Newer controllers have much more program space, stack space, speed, counters etc. and cost less than half.
Regards,
Søren

A rather fast and fairly heavy robot with quite large wheels needs what? A lot of power?
Please remember...
Engineering is based on numbers - not adjectives

Offline minmxTopic starter

  • Jr. Member
  • **
  • Posts: 7
  • Helpful? 0
Re: trying to build a line follower robot
« Reply #2 on: April 27, 2010, 10:59:57 PM »
OK. But if someone can give me the algorithm in code C of the function i post i will thanks you

Offline amando96

  • Robot Overlord
  • ****
  • Posts: 187
  • Helpful? 1
Re: trying to build a line follower robot
« Reply #3 on: April 29, 2010, 06:40:50 PM »
if(left sensor){
black;
Turn_left();
} else drive_forward();
}

if(right sensor){
black;
Turn_right();
} else{
drive_forward();
}

that's a pseudo code, it WILL work, just have to get timings/PWM right, as something that simple doesn't like high speeds, i used a code based on that for this guy:
[youtube]rorcle following it's first line[/youtube]

it's even faster now, once you get the hang of it, it's easy :)

I'm using three sensors though, so i say when the middle sensor detects black, to move forwards, the rest is the same.

once it's following lines, try using PID, i'm working on that at the moment, it should be faster, and smoother.
Rorcle, 60% complete
AATV, 5% complete

Offline minmxTopic starter

  • Jr. Member
  • **
  • Posts: 7
  • Helpful? 0
Re: trying to build a line follower robot
« Reply #4 on: April 30, 2010, 05:33:37 AM »
OK thanks, but will follow a black line in a white background ?
And will a 6V engine will it be to fast for the algorithm?
« Last Edit: April 30, 2010, 08:07:07 AM by minmx »

Offline amando96

  • Robot Overlord
  • ****
  • Posts: 187
  • Helpful? 1
Re: trying to build a line follower robot
« Reply #5 on: May 01, 2010, 03:23:38 PM »
it can follow both coloured lines, just by adjusting the code, i'm using 6v motors, way too fast, i have never used pics in my life, but do they have  PWM? if yes, start out slowly, and gradually adjust the code to get it going at the desired speed.
Rorcle, 60% complete
AATV, 5% complete

Offline minmxTopic starter

  • Jr. Member
  • **
  • Posts: 7
  • Helpful? 0
Re: trying to build a line follower robot
« Reply #6 on: May 01, 2010, 05:15:37 PM »
ooo OK.
and if i use an other program like picbasic pro, which algorithm i need to use to follow the line'
?

Offline Soeren

  • Supreme Robot
  • *****
  • Posts: 4,672
  • Helpful? 227
  • Mind Reading: 0.0
Re: trying to build a line follower robot
« Reply #7 on: May 05, 2010, 03:33:45 PM »
Hi,

and if i use an other program like picbasic pro, which algorithm i need to use to follow the line'
?
Whatever programming language, you have to first sketch out what you wanna do and then find the commands to build the algorithm and make it happen.

What the program will look like will depend on your sensors, your actuators and what you want to do with them, but for PWM to a motor, you can use this, straight from the manual:

  PWM Pin, Duty, Cycle

Outputs a pulse width modulated pulse train on Pin. Each cycle of PWM consists of 256 steps.
The Duty cycle for each PWM cycle ranges from 0 (0%) to 255 (100%).
This PWM cycle is repeated Cycle times.

Pin may be a constant, 0 - 15, or a variable that contains a number 0 - 15 (e.g. B0) or a pin name (e.g. PORTA.0).

The Cycle time of PWM is dependent upon the oscillator frequency.
If a 4MHz oscillator is used, each Cycle would be about 5ms long.
If a 20MHz oscillator is used, each Cycle would be about 1ms in length.
Defining an OSC value has no effect on PWM. The Cycle time always changes with the actual oscillator speed.

If you want continuous PWM output and the PICmicro MCU has PWM hardware, HPWM may be used instead of PWM.


I'll suggest that you read through the manual, to get a feel for which commands does what.
Regards,
Søren

A rather fast and fairly heavy robot with quite large wheels needs what? A lot of power?
Please remember...
Engineering is based on numbers - not adjectives

 


Get Your Ad Here

data_list