Almost every regulated quantity in the built world — the temperature of a reactor, the altitude of a drone, the speed of a cruise-controlled car, the position of a hard-drive head — is held in place by some variant of a single, century-old idea: the PID controller. It is worth understanding not because the mathematics is hard (it isn't) but because the three terms it adds together correspond to three very human ways of responding to being off-target.
Let's build it from one question.
The question
You are steering a system toward a setpoint — a desired value. At each moment the system is actually at . Define the error:
The whole job of a controller is to choose a control action — how hard to push — based on this error. The question is simply: given the error, how hard should I push?
There are three sensible answers, and PID uses all three at once.
P — push in proportion to how wrong you are
The most obvious rule: the bigger the error, the harder you push.
If the room is far below the target temperature, open the heat valve wide; as it approaches, ease off. This is the proportional term, and on its own it does a lot.
But it has a stubborn flaw. To keep pushing, a proportional controller needs a non-zero error — push is proportional to error, so when the error reaches zero, so does the push. In any system that needs continuous effort just to stay put (holding a heavy door against a spring, say) the controller settles at a steady offset: close to the target, never quite on it. This leftover gap is called steady-state error.
I — remember how long you've been wrong
The fix is to react not just to the present error but to its accumulation over time. If a small error persists, let it pile up and gradually increase the push until the error is gone.
This is the integral term. It is patient and stubborn: as long as any error lingers, the integral keeps growing and keeps demanding more action, which is exactly what eliminates steady-state error. The cost is that accumulated history makes the controller sluggish to reverse — push too hard on the integral and the system overshoots, then has to unwind the accumulation, often oscillating on the way.
D — anticipate where you're heading
The third instinct is foresight. If the error is shrinking fast, you are about to overshoot — so start easing off now, before you arrive. React to the rate of change of the error:
This is the derivative term. It is a damper. It does nothing at steady state (a constant error has zero slope) but it resists rapid change, smoothing the approach and reducing overshoot. Its weakness is noise: differentiation amplifies the jitter in a measurement, so in practice the derivative term is almost always filtered.
Putting it together
Add the three responses and you have the full controller:
Three gains, three jobs:
- — reacts to the present error. Speed.
- — reacts to the past, accumulated error. Eliminates steady offset.
- — reacts to the predicted future error. Damping.
Present, past, future. That is the whole grammar of PID, and it is why the controller feels less like a formula and more like a temperament.
Tuning, briefly
Choosing the three gains is the real craft. A common starting recipe:
- Set and to zero. Raise until the system responds briskly but begins to oscillate.
- Add to drive the steady-state error to zero, accepting a little more overshoot.
- Add to tame the overshoot and settle the response.
Formal methods (Ziegler–Nichols, pole placement, frequency-domain shaping) make this systematic, but the intuition above is what you reach for when a real loop is misbehaving in front of you.
e(t) u(t) y(t)
r --->( + )---> [ P + I + D ] ---> [ plant ] ---+--->
^- |
|________________________________________|
(measured output)
The diagram is the same loop the steam-engine governor drew mechanically two centuries ago — only now the box in the middle holds three terms instead of a linkage, and we get to choose its temperament.
This is a sample technical article included with the Kybernetes template. Equations are written in LaTeX-style notation; to render them in the browser you can drop in a math library such as KaTeX or MathJax. Replace this file with your own in the /articles folder.
Playground
Tune the controller yourself — drag the sliders and watch the loop respond.
And here is how pole locations shape the response — drag the pole around the s-plane: