PID Control Explained Simply: How Robots Stay on Track
A PID controller keeps a motor or robot at a target using three ideas: how far off now, how long off, and how fast it is changing.
Short answer: a PID controller keeps something at a target value, such as a motor at 100 rpm or a robot on a line, by combining three signals: P (how far off you are now), I (how long you have been off), and D (how fast the error is changing). Details are in the PID controller entry.
Driving a car at 60 km/h
- P, proportional: the further below 60 you are, the harder you press the pedal.
- I, integral: if you stay a little below 60 for a long time, press a bit more to remove the lingering gap.
- D, derivative: if you are approaching 60 fast, ease off early so you do not overshoot.
The formula in one line
output = Kp ร error + Ki ร (sum of past errors) + Kd ร (change in error)
Kp, Ki and Kd are three numbers you tune. This works because of feedback: the robot measures, compares with the target, and corrects.
What goes wrong without each part
- Only P: the robot settles slightly short of the target, or oscillates if P is too large.
- Too much I: it overshoots and swings back and forth.
- No D: it overshoots when it moves quickly.
Simple tuning recipe
- Set Ki and Kd to zero.
- Raise Kp until the robot reacts quickly, then back off a little when it starts to wobble.
- Add Kd to calm the wobble.
- Add a small Ki only if a steady gap remains.
Where you will use it
Line-following robots, balancing robots, drone stabilisation, motor speed control, and temperature control. You can try it on an Arduino with a motor and an encoder.
FAQ
Do I need to know calculus? Not to use it. The idea is just "present error, accumulated error, rate of error".
Is PID the only controller? No, but it is the most common starting point and is used everywhere.
Was this article helpful?
Learn deeper
Master every concept mentioned in this article โ for free.
R2BOT's Atlas has 480+ robotics concepts explained in simple language, with sources.
Explore R2BOT Atlas โ