Komli

Thursday, May 15, 2008

line follower with software diff

A simple line follower not following a curve can make a large diff jst by changing the software tats u r programme . Its always better tpo use more sensors than just a couple of them , use arnd 8 sensors rather than 4 r 6 . Now wat diff can a change in algo make , u can use PWM and PID control to make it more perfect bot .Even a Closed loop control system formed with the above two can be used.

PID CONTROL :
A proportional integral derivative controller (PID controller) is a common method of controlling robots. PID theory will help you design a better control equation for your robot.
Shown here is the basic closed-loop (a complete cycle) control diagram:



The point of a control system is to get your robot actuators (or anything really) to do what you want without . . . ummmm . . . going out of control. The sensor (usually an encoder on the actuator) will determine what is changing, the program you write defines what the final result should be, and the actuator actually makes the change. Another sensor could sense the environment, giving the robot a higher-level sense of where to go.

To get you started, here are a few terms you will need to know:

error - The error is the amount at which your device isnt doing something right. For example, if your robot is going 3mph but you want it to go 2mph, the error is 3mph-2mph = 1mph. Or suppose your robot is located at x=5 but you want it at x=7, then the error is 2. A control system cannot do anything if there is no error - think about it, if your robot is doing what you want, it wouldnt need control!

proportional (P) - The proportional term is typically the error. This is usually the distance you want the robot to travel, or perhaps a temperature you want something to be at.

derivative (D) - The derivative term is the change in error made over a set time period (t). This is usually the velocity of your robot. So if your robot was at x=5 about one t ago, and is at x=7 now, then the derivative term is 7 - 5 = 2/t. If you are using a microcontroller, you can calculate the time with this timer tutorial.

integral (I) - The integral term is the rate of change in the error made over a set period of time (t). This is usually the acceleration of your robot. If your derivative term was 2/t a second ago, and it is 2/t now, your integral term is 2 - 2 = 0/t^2. Thats an acceleration error of zero . . .

tweak constant (gain) - Each term (P, I, D) will need to be tweaked in your code. There are many things about a robot that is very difficult to model mathematically (ground friction, motor inductance, center of mass, ducktape holding your robot together, etc.). So often times it is better to just build the robot, implement a control equation, then tweak the equation until it works properly. A tweak constant is just a guessed number that you multiple each term with. For example, Kd is the derivative constant. Idealy you want the tweak constant high enough that your settling time is minimal but low enough so that there is no overshoot.

One example of only P control can be seen here: taken from amol deshmukhs site ,



This is a small line following robot designed to follow a white line drawn on a black surface. The software can be changed to interchange the colours. The software still has lot's of room for improvement but works well. It constantly corrects wrong moves using feedback mechanism which forms a closed loop control system.


mechanical design It has two DC motors in wheelchair design. Direction of the robot is controlled by controlling speeds of the two motors. Lets say the speeds are
Right wheel : SpeedR
Left wheel : SpeedL
To control the speed of the motor controlled power is fed by PWM ( Pulse Width Modulation ) technique.


electronic design Processor AVR ATmega16 [ the ADC feature comes in handy to read output of sensors ]
Motor driver : L293D ( 2 )
Sensors : IR LED-photodiode pair ( 2 )( non-modulated )
Power supply : Li-Ion cells ( 2 ) 1700mAHr giving 8V regulated with voltage regulator.


control algorithm and software
Lets say the two sensor outputs, i.e. the intensity of reflected light sensed at the two sensor positions is
Sensor Left : SensL
Sensor Right : SensR

If Err is the error of sensors from mean position then it will be proportional to the difference between the two sensor readings
Err = K * ( SensR - SensL )
Where K is constant of proportionality

If Err is a +ve quantity then we must drive Left motor a bit faster than the right i.e. the speed of right motor must be increased a bit and speed of motor right be decreased a bit
SpeedL = CntrSpeed + Kp * Err
SpeedR = CntrSpeed - Kp * Err

This is called Proportional Control


Check for my next post on 8 sensors using PD control wth algo.

The above one is only P control n taken from this site

http://www.me.iitb.ac.in/~adeshmukh/linefollower.php


1 comment:

Mayank Sharma said...

Don't mind but can u please upload the c code n the connection u had done to make the LFR using PID algo n ya plzzz let us understand the code by xplaing it ... thankxx