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
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.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.
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 PositionSolution 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: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, for a line follower a proportional controller would be Sufficient.
Here is a Small video of my Line Follower:
Here is a Small video of my Line Follower: