I have a line following differential drive robot with a PID control. I successfully tuned (try and error) the P,I,D constants for a good stability in low speeds, but when I increase the speed, everything goes sideways.

Therefore I want to solve this with a bit of a mathematical approach.

I started logging the error (setpoint-present sensor value;input for PID) and output (from the PID; motors get values: left = speed-output, right = speed+output).

My question is, whether it is possible to use this data in order to further improve the PID?


1 Answer 1


Yes, it is possible. Though remember, what you are measuring is error between measured value (which for your robot is direction that it is heading in 2D) and desired value (which is direction it should be heading). To use more mathematical and complicated methods, you have to know absolute heading of robot and be able to measure its step response. For robot like that it would be response to i.e. 45 degree angle drawn on track. Also, check this question for good PID tuning strategies.

With trial-error method You can do well, but remember - winning robots have:

  • wheels speed measurement (i.e. encoders) - best way to compensate loss of voltage on battery during run,
  • clean and well made tires - clean before every run to get best results,
  • proper line sensors alignment - far forward and close to each other (distance smaller than 19mm sensor to sensor).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.