PDA

View Full Version : Wats PID n how to implemet for faster LFR



IMMORTALDEATH
05-24-2008, 01:26 AM
Hiii!!!!! guys , i made a lfr but wasnt tat quick enough , i wont to know wats PID , i read abt it but wasnt understandg the constants they were implementing n how were they calculating it , one example is from amoldeshmukh sites n from ikalogic.com.

Can ny one tell me , on wat basis those constants are selected.

docel
05-24-2008, 08:45 AM
Google says :
It can be as complicated as this-
http://www.engin.umich.edu/group/ctm/PID/PID.html#hint

Or as simple as this-
http://img341.imageshack.us/img341/7605/figure011c166ect4.th.png (http://img341.imageshack.us/my.php?image=figure011c166ect4.png)

....Take your pick!!!

ankitmutha
10-13-2008, 01:02 AM
hey Docel,..
plz put some light on the circuit diagram. and plz let us know how do we use PID in motor control for LFR.
Actually im working on a LFR myself :)

i read some articles on PID but all contained the same thing as the link u provided here... a lot of theory with less talk on how to relate it to motor control in LFR.

All those who have worked with PID plz let us know in very simple words what actually is PID control system.. and more about how do we implement in LFR. Plz provide simple theory and strictly relating to LFR system.

If u have some good link that's relevant plz share.

By the way im using AtMega8, 2xDCMotors(250RPM), 8xIR LED-Photodiodes, LM324 and some passive components for my LFR.
suggestion invited for improvement with respect to better controlling and better speed.

ppppking04
10-13-2008, 10:17 AM
Before someone bombards you with more equations and more of theory, I'll request you to answer a few questions:

1. Have you made a line follower yourself?
2. What was the basic program you were using? Control part of the program (like if(right_sensor under line) turn_left) etc
3. Can you identify the biggest difference between the performance of the following two videos?

3.1. http://www.youtube.com/watch?v=Kvk7cvBOm1g and
3.2. http://www.youtube.com/watch?v=JDxIorDI1VQ

besides the speed difference, from control point of view

and a couple of personal questions :
1. If I told you the line is 10 cm to the left, how fast would you move to the left?

2. If I told you the line is 10 cm to the left, and for the last 10 secs you've been moving to the right, how fast would you move to the left?

3. If I told you the line is 10 cm to the left, and for the last 10 secs you've been moving to the right and you know from previous experiences that you generally tend to stop 2 cm away from the line, how fast would you move to the left?

Try answering is simple terms like fast, faster and so on for the last three questions. If you can reason these out, you practically know PID.

ashish_agarwal123456
10-13-2008, 11:23 AM
what ppppking04 said should be enough to implement a pd/pid algo. but if you want more explanation, here is what i figured out recently....

consider following sensor arrangement
12345
. . . . .

1) first thing you need to understand is inertia. when you are using motors they need time to increase or decrease speed. now for a while forget inertia. you have motors which can change speed from min to max instantly. so what you need to follow a line is just a signal that tell you current possition. you adjust your motor speed accordingly. this is called the proportional factor. more the error, more correction you need. so if line is below 3 no correction. if below 5 severe correction.

2) but as inertia is present it effects this approach. say you are moving on straight line and your line is below 5. you applied severe correction. this will cause the LF to take sharp turn. while turning line will be below 3. you stop the correction but till the speed will be balanced, it would have moved to 2 or even 1. so it will oscillate. to avoid this following approach is used. if because of the effort made in previous time your LF is now having less error you decrease your correction level for this time. try to adjust it so that the settling time is minimum for straight run.

3) another condition occur when you encounter a turn after straight run. line is below sensor3. no correction. because of turn line below sensor 4. you made slight correction. now if the turn is sharp then despite of the correction applied previously the error is increasing. say now line is below 5. so you can understand that you need to increase the correction level than what previously set. this enables LF to take fast turns.

4) in a simple form above two points means- if after previous effort condition is better then decrease the corrections. if after previous effort condition worsen, increase the correction. this factor is called differential factor. it depends on difference between present error and previous error.

5) now come integral term. its the most suspicious term out there. it can improve you performance slightly but there is a greater chance that it will degrade the performance. thats why this term need a lot of testing. one situation when this is useful is when there is a small difference between motor rpm. say you are moving on a straight line. only term you are using is proportional. line is below 3. now it should continue to move straight but because of rpm mismatch it move above 4. proportion will cure it. but again it will move to 4. now you take a integral term. it accumulates the errors. so after your LF has stepped out of line a few times, its value is large enough that it can provide cure for misalignment before it actually happens. thus improving performance. same applies for very smooth turns.

6) but suppose you are having a sharp turn. so it will take some time for the LF to come back to centre. in this time your integral term will pile up and will cause severe oscillations. remedy is to set a limit for I term. if it increase above it you know its a sharp turn and so take steps to cure the I term.

ankitmutha
10-14-2008, 01:27 AM
@ppppking04
yes i made a simple LFR using two sensors.

The code tested three conditions:
1)If Line is below both the sensors turn both motors on.
2)If line is under left sensor and not under right sensor, turn left motor off and turn right motor on.
3)If line is under right sensor and not under left sensor, turn right motor off and turn left motor on.

I saw those videos.
The difference that i found in control systems of the two:
1)It has a very primitive control with i guess not more than one condition to check and that being if line under sensor move away from line and when line is not under sensor turn towards line. It seems to be a basic line follower with edge following algorithm.

2)The japanese LFR. But obv. there're much faster. but apart from that it has an extensive control algorithm.
U can notice the LFR moves smoother and faster and can take sharp turns unlike the prev one which looses line on turns.
LFR can even find line if it looses it on turns.. which can be seen in the sec competitor.
I guess they're using just more than one sensors and they have more test conditions than the prev one.
one sensor test conditions can be two(2^1) but for a LFR with for example 6 sensors test conditions can be 2^6 or 64!!!
So this helps in improving control over motor speeds better. A better control and variation can be produced in the motor movements.

I did not get wat u meant by 10 cm to left?? or 10sec to right? or how fast will u move to left??

But can presumably think that the first question answers Wat P term is 2nd one about I term and the 3rd about D term.

@ashish
very nice explanation. really in simple words.


@both
okay the bottom line is i get wat P I D terms are.. i think overall this PID control is just a new term of a knowledge that we all already have.

@all
Now the ques is how do we code it??
can u ppl give some ideas about coding PID.??

i can understand for the P term... just find out Kp constant for the LFR by hit and try and increase or decrease motor speeds Kp times depending on how far the line is from center or the correction required.

For D term just remember prev correction u made.. and depending on the difference between current state and prev state make a correction Kd times the prev correction.

For I term i guess we need to add up the Ki times corrections made so far to the present correction....? im not sure of this one. plz guide.

And One imp thing how do we find the values of these constants Kp,Kd,Ki
in LFR???? Hit and try?? any specific instructions to increase hit rate i mean to how to find out these constants efficiently??
Plz give some ideas for I and D terms.

@all
And plz give some idea regarding this too... the problem is i'm stuck with 150RPM motors and i know my LFR can not be any faster than 27cm/s ( or half of max possible 54cm/s with 3.5cm wheel). Im a newbie i want to know hows this speed?? will it stand any chance in a state level competition. Im talking of Robotrax in techfest of MNIT Jaipur.
link: http://www.mnit.ac.in/neuron/events/robotrax/

plz post ur experiences here.

ashish_agarwal123456
10-14-2008, 06:46 PM
there are some methods to tune the constants but they are useful only if you know value of all other constants (like friction, skid, etc). so they are of no use. the only thing left is hit and try.
there are some explanation to increase the hit accuracy on wikipedia (pid). in general for a rough idea- if Kp=8 then put Kd=4 Ki=1. its just rough values.

you are right about the programming part. I term = previous_I +Ki(error_now). but initially usew a pd algo only. test an tune it. add I later.

speed is not a greater issue until the track is made of very smooth turns and long straight lines.it depends on track. still you can use a slightly bigger tyres or faster motor and then use external control to decrease speed if needed. i dont think there will be very speedy competition here. moreover the problem statement need you to stop periodically. so speed wont be much issue.

is the competition is just after 2 days?

ankitmutha
10-14-2008, 10:49 PM
yes my fren.. ur in jaipur.. u must participate that way i can have chance to meet u.. yes its in two days and my bot is still not ready..

i'l try PID myself and let u know the results and my experience.

ashish_agarwal123456
10-15-2008, 09:33 AM
i am a pass out.... so not allowed.....