Showing posts with label sensors. Show all posts
Showing posts with label sensors. Show all posts

September 21, 2011

My line follower (Programming)


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.....


We had a fun making it....

-keyur
:)
Read more ...

September 15, 2011

My line follower....


How to make a line follower?
What a big question coming in the mind of almost all UG students....
I have a solution for that …..
what basically a line follower has to do is to detect the line with the sensors
The sensors are mainly the optical transmitter and receivers.
They throw light at the surface and receive to detect if the light is fully reflected or absorbed by the surface
absorption means the surface below that sensor is black and reflection means that the surface below that surface is white.

Now let us go to the sensor side...
I have experimenter many sensors related to optical transmission and reception I would like to mention them in brief here
1)first I tried directly with the IR LED and Photo diode but the configuration didn't work perfectly according to my needs.

So I have to go for the other configuration
2)second one is just the enhanced version of first one I included an indicator LED to show whether the sensor is working or not and used a simple transistor as a switch configuration …



Here you can put a potentiometer in the base so that you can vary the sensitivity of the sensor , but we got perfect result with the help of steady values also so you can also try “Trial and error method”.

Many people recommend the sensor based on Photo Resistor(LDR) but I would say “don't go for it”..
and now one video speaks more than one post. 


 
Now you have all you need to start programming a micro controller to make decision and a good algorithm to keep following the line.....

you can go for programming and logic of line follower in my another post
enjoy “sensing” :)


Read more ...
Related Posts Plugin for WordPress, Blogger...