Software > Software

PID is pretty complicated to me

(1/4) > >>

S. Karim:
Actuator_Output = Kp*P + Ki*I + Kd*D

If I want to drive a sraight line, as straight as possible with my robot fixing errors when it veers off a tiny bit, whats the code I have to whip up to control left and right wheels?

Not sure I understand the PID equation at all. Could someone give some pseudo-code and examples of how to implement this with 2 motors trying to equalize themselves?

Steve Joblin:
There is a very good tutorial on PID on the Parallax forums under the "Stamps in Class" section.  I am not quite sure that PID algorithm is necessary for traveling a straight line... I think that wheel encoders with a simple counter is all that is required.

S. Karim:
im not allowed to use encoders for now. what is PID used for then??

Admin:
What sensors are you using to know if you are going straight or not? How big/heavy is your robot?

For small slow robots, this is how I would do it:

Left_wheel_speed = tweak_constant * (current heading - location of straight line) + another_constant
Right_wheel_speed = - tweak_constant * (current heading - location of straight line) + another_constant

This is a simple PD controller that will work after a few experiments trying different constants.

JesseWelling:
This article helped me understand PID a bunch...
http://www.embedded.com/2000/0010/0010feat3.htm

Navigation

[0] Message Index

[#] Next page

Go to full version