the PID controller
/ pee-eye-dee /
The PID controller is the workhorse of automatic control — the unseen logic inside thermostats, car cruise controls, drones, and factory machinery. It is a feedback controller that decides how hard to correct an error by combining three views of that error: how big it is now, how long it has been building up, and how fast it is changing. Mixing these three in the right proportions gives a controller that is fast, accurate, and smooth all at once, which is why it has stayed in use for nearly a century.
Write the error as e(t) = (target) - (actual). The PID control signal is u(t) = Kp e + Ki times the integral of e dt + Kd times de/dt — three terms with three knobs. The Proportional term Kp e reacts to the present error: bigger error, bigger push. The Integral term Ki integral of e dt accumulates past error, so any small steady offset that lingers eventually builds up enough correction to erase it. The Derivative term Kd e' looks at the trend, easing off as the error shrinks fast, which damps the motion and prevents overshoot — like braking before you reach the target rather than slamming into it.
Each term cures a specific weakness, which is the whole reason for three. Proportional alone is quick but leaves a permanent leftover error (it stops pushing once the error is small). Adding Integral kills that leftover by patiently accumulating it away. Adding Derivative tames the overshoot and oscillation that strong proportional and integral action can cause. Tuned together, they hand you a closed-loop system that reaches the target quickly, sits exactly on it, and gets there without violent swinging.
The honesty is in the tuning. The three gains interact, and a poor choice can make the loop sluggish, leave it oscillating, or drive it unstable; tuning is part theory, part craft. The derivative term in particular amplifies measurement noise (it differentiates, magnifying jitter), so in practice it is filtered or limited. PID is beloved because it is simple and works astonishingly often — but it is not magic, and badly tuned PID is a common cause of equipment that hunts, buzzes, or shakes itself apart.
A drone holding altitude uses PID: if it sags below target, the Proportional term throttles up in proportion to the gap, the Integral term ramps up further if it stays low too long, and the Derivative term eases the throttle as it rises quickly toward target so it does not shoot past. The three together settle it smoothly at the set height.
Present (P), past (I), and trend (D) of the error, mixed by three gains.
PID is not plug-and-play: the three gains interact, and a bad tuning can leave the loop sluggish, oscillating, or unstable. The derivative term also amplifies measurement noise, so it is usually filtered — a raw, untuned PID is as likely to cause trouble as to cure it.