Hello friends I hope you all have read my post about the sensors used in line follower..
So now it is the time to go for the logical side…..
Let us start with how actually a line is followed
According to the position of sensors we have to make a look-up table for all the possibilities….
Let us start…..
If i am using 3 sensors I can do…
LEFT SENSOR
|
CENTER SENSOR
|
RIGHT SENSOR
|
LEFT MOTOR
|
RIGHT MOTOR
|
comment
|
0
|
0
|
0
|
FORWARD
|
FORWARD
|
To avoid the cross…
|
0
|
0
|
1
|
STOP
|
FORWARD
|
|
0
|
1
|
0
|
FORWARD
|
FORWARD
|
Worst case!!!
|
0
|
1
|
1
|
STOP
|
FORWARD
|
|
1
|
0
|
0
|
FORWARD
|
STOP
|
|
1
|
0
|
1
|
FORWARD
|
FORWARD
|
|
1
|
1
|
0
|
FORWARD
|
STOP
|
|
1
|
1
|
1
|
REVERSE
|
REVERSE
|
Line is lost
Return to line
|
*note that when sensor is on black surface we get 0
*and assume that we have to follow a black track in white
surface…
After understanding the logic it is always easy to convert
it to programming…
Here the programming I have given
is for AVR 8535.
//motors
are connected to PORTB
//sensors
are connected to PORTA
//as
the motor is too much fast we had to turn off motor for certain time..
//program
of line follower with three sensors
//6/8/11
#include<avr/io.h>
#include<delay.h>
void
main(void)
{
DDRD=0xF0;
//Setting the data direction of Port-D where motors are connected
PORTA=0XFF;
DDRA=0X00;
DDRC=0XFF;
while(1)
{
while((PINA
& 0X07)==0X03)
{
PORTD=0X20;
delayms(75);
PORTD=0x00;
delayms(200);
}
while((PINA
& 0x07)==0x00)
{
PORTD=0XA0;
delayms(50);
PORTD=0x00;
delayms(200);
}
while((PINA
& 0x07)==0x01)
{
PORTD=0x20;
delayms(75);
PORTD=0x00;
delayms(200);
}
while((PINA
& 0x07)==0x02)
{
PORTD=0x50;
delayms(75);
PORTD=0x00;
delayms(200);
}
while((PINA
& 0x07)==0x04)
{
PORTD=0x80;
delayms(75);
PORTD=0x00;
delayms(200);
}
while((PINA
& 0x07)==0x05)
{
PORTD=0xA0;
delayms(75);
PORTD=0x00;
delayms(200);
}
while((PINA
& 0x07)==0x06)
{
PORTD=0x80;
delayms(75);
PORTD=0x00;
delayms(200);
}
while((PINA
& 0x07)==0x07)
{
PORTD=0x50;
delayms(75);
PORTD=0x00;
delayms(200);
}
}
}
Now let us see a video in action...
you can see all the logic being applied in video....
hope you loved it...
place any comment if you want to ask.....
-keyur
:)
Nice one explanation of the line follower , thanx for share :)
ReplyDelete