|
Concept of PID explained
I have seen tons of references to it, some more advanced theory, which just confused me a bit more. Leaving me still confused as to how exactly PID works, and how it is implemented. I know what it does.
From researching around online, I have found some still advanced stuff, but nothing to really explain it that well and I want to make sure that I have the elements right before I learn it the wrong way and have to learn again later.
Ok on our imaginary robot, we will call each of the loops when the PID loop is called 1 "tick" when the motors go full speed forward (254) for 1 tick, we get 127 up counts, and full reverse(0), we get 127 down counts.
Now for the PID stuff.
The P, sees that if the desired speed is 200, which means there should have been 73 ticks (200-127) however there was only 47 ticks, so the motor's power would be changed to 200 + (73-47)*kP. Is this right?
I've had calculus so I understand the concept of integration, but for the I of the PID loop it would be something like this:
(S) would be the current desired speed, -127 so that zero is neutral
(S-x) would be the desired speed, x loops ago
(A) would be the current actual speed
(A-x) would be the actual speed x loops ago
How the I would be implemented would be:
Motor value from P + (( (S)+(S-1)+(S-2)...+(S-x) )-( (A)+(A-1)+(A-2)...+(A-x) )) * kI
It would be keeping track of the difference in motor speed versus desired speed for the past x loops, and use that to affect the motor output also. Is this how the I part works?
As for the D component, I am still a little more confused than the others.
From what I understand, you take the difference from the previous loop, subtract the difference in this loop, to see if the error is decreasing or increasing. Multiply this by kD and subtract it from the motor value from the I section.
Is that how PID works for drive motors? I know that it is different for things that have position controlled rather than velocity.
When I read the usual posts about it it seems rather hard to understand, but that doesn't seem so hard looking back over what I have up there.
__________________
2005 Philly #1 seeded team, highest average points, and semi-finalists
Thanks to 103 and 484 for being alliance mates.
|