How it works
The control law is a weighted sum of the present, the past, and the future of the error e(t) = setpoint − y(t):
u(t) = Kp·e(t) + Ki·∫e(τ)dτ + Kd·de/dt
That signal u(t) drives the plant. Here the plant is a 2nd-order system — G(s) = 4 / (s² + 2.828s + 4), a unit-gain Butterworth response with natural frequency ωₙ = 2 rad/s — which is a faithful stand-in for anything with inertia and a bit of damping: a motor, a heater, a suspension. Each gain pulls a different lever:
- Proportional (Kp): force proportional to current error. More Kp means faster response but more overshoot, and on its own it always leaves a steady-state offset.
- Integral (Ki): accumulates error over time, driving the steady-state error to zero — at the cost of phase lag, so it adds overshoot and ringing.
- Derivative (Kd): reacts to the rate of change, damping oscillation before it builds. It improves stability but amplifies measurement noise.
The lower trace plots u(t) itself, clamped to ±10 — real actuators saturate, and watching the control effort hit its rails explains a lot of sluggish responses.
Tuning without guesswork
The gains interact in non-obvious ways, so blind fiddling rarely converges. The classic Ziegler–Nichols recipe gives a principled starting point: with Ki = Kd = 0, raise Kp until the loop oscillates with constant amplitude — that's the ultimate gain Kᵤ, with oscillation period Tᵤ. Then set:
Kp = 0.6·Ku Ki = 2·Kp/Tu Kd = Kp·Tu/8
It tends to overshoot, but it lands you in the right neighbourhood; fine-tune by hand from there. The deeper lesson is the universal trade-off — speed buys overshoot, integral action buys accuracy at the price of stability margin, and derivative action buys damping at the price of noise sensitivity. There is no free lunch, only a sweet spot.
The knobs
- Proportional Kp — present-error gain. Raises responsiveness; too high and the loop rings or goes unstable.
- Integral Ki — past-error gain. Eliminates steady-state offset; too high adds overshoot and slow oscillation.
- Derivative Kd — future-error (rate) gain. Damps overshoot; too high amplifies noise.
- Setpoint — the target the plant output is driven toward; the step the controller must chase.
Further reading
- PID controller (Wikipedia)
- Åström & Hägglund, PID Controllers: Theory, Design, and Tuning