Monday, April 26, 2010

Line Following Robot


Hey Folks,
In the last post, I have a shared a document on implementing PID controller, I hope that it was useful .
In this article I would like to share one of its applications – Line Following Robot.

Now let’s analyze how can we build a Line Following Robot using the PID controller and analog sensors.
My tryst with this robot happened when I decided to participate in a competition at SASTRA university  and at the end of it all I won 2nd Prize. The sad part being I could not find enough time to make a new Hard Ware (HW) for this competition, so I had to modify my Micromouse . So my Line Following Robot is same as my Micromouse but with modified sensor position and Software (SW). A small advise for the aspiring Robot-makers same robot model can be used for several competition ( solving different problem statements) with minor modification in HW and significant change in SW.
This is my Micromouse
This is my Line Follower after Modification :
Bottom View:

You can observe that the major change is only in sensor board (considering HW). 
Modified sensor board for this Line Follower looks something like this .
The third sensor in the above pic is completely competition specific, at this moment you can safely ignore that sensor (for more information on sensor's refer my presentation on Making of Micromouse in my old posts).
Both the sensors are connected to ADC port of the microcontroller. Also remember that the distance between two sensors should be equal to the width of the Line (i.e. white line on black background or vice versa) that robot should follow.
This would be Ideal position of the sensors.
IDEAL POSITION:
Output voltage from both the sensors would be approximately same. Lets now introduce a new variable Error, which is mathematically calculated as shown below,

Error = LeftSensor(O/P voltage) –  RightSensor(O/P voltage);

For the ideal position this Error will be Zero (approximately).
Lets now imagine that the Robot deviates towards right, the new sensor position would look something like this.
SCENARIO 1: ROBOT DEVIATING TOWARDS RIGHT:
In the above scenario voltage reading from Left sensor will be greater than that of Right sensor resulting in Error value greater than zero . As a corrective measure, robot should move a little towards left, so that it would come back to the ideal position again. 
Solution: There are two ways to get back to Ideal Position
Solution 1 :  The speed of the left motor should be reduced when compared to that of right motor.
Solution 2:  The speed of the Right motor should be increased when compared to that of Left motor speed ( I prefer increasing the speed of Right Motor).
How much speed change should we apply??

Lets now introduce another term named Delta speed. We can use PID controller to calculate this delta speed. 
Lets imagine that we are using a P (proportional) controller alone.

DeltaSpeed = Error * Kp; 
Where Kp is a proportional constant.
SCENARIO 1: ROBOT DEVIATING TOWARDS LEFT:
Here error would be negative, so DeltaSpeed is calculated as
DeltaSpeed = Error * (-Kp);
Now this DeltaSpeed calculated is the amount of speed that should be either reduced or increased on the respective motors in order to bring the robot to ideal position.
By using trail and error method the value of Kp is obtained. 
Since our Robot moves continuously on the line and correction is done continuously, it is not necessary to concentrate on Steady State Error, so we can also safely ignore Integral and Derivate Controller. So, foline follower proportional controller would be Sufficient.
Here is a Small video of my Line Follower:


10 comments:

Anonymous said...

I always motivated by you, your thoughts and attitude, again, appreciate for this nice post.

- Norman

Raghavendra prasad said...

thank you..

Anonymous said...

Hi there, I found your blog via Google while searching for first aid for a heart attack and your post looks very interesting for me.

Anonymous said...

Nice post, kind of drawn out though. Really good subject matter though.

Anonymous said...

Wow, that's crazy man. They should really try to do something to fix that.

Anonymous said...

buy cheap renova no prescription
- [url=http://buycheaprenova.webs.com/]order cheap renova online with no prescription
[/url] - renova canadian


purchase cheap renova with no prescription


renova use
does renova fade brown spots
renova otc
renova strengths
renova hawa


http://buycheaprenova.webs.com/

Anonymous said...

oZzy moved away earlier, I miss his cock, and i am always hungry for making love.

FUCK MY PUSSY!

My blog :: hcg injections
my webpage > hcg injections

Anonymous said...

Indian attires are gaining popularity across the domestic and global fashion industry.



Also visit my web-site ... Ao so mi nam

Anonymous said...

In сompariѕon, an unlocked 16 GB iphone 5 will be similar to the ones οn youг iρhone 4, the iphоnе releаse!

It lets you use one cοntinuοus motion using your fіnger as a stуlus to input keys on уour ρhone when іt's available from Google.

my site said...

awesome post . thanks for share this .