PID Control
The PID controller sums proportional, integral, and derivative action on the error, covering most industrial control needs with three tunable gains.
The Three Terms
A PID controller computes the plant command from the error e(t) = reference minus measurement as u(t) = Kp*e + Ki*integral(e dt) + Kd*de/dt. Each term addresses a different aspect of performance.
- Proportional (Kp): acts on present error; larger Kp gives faster response but more overshoot.
- Integral (Ki): acts on accumulated past error; it eliminates steady-state offset.
- Derivative (Kd): acts on the error's rate of change; it adds damping and anticipates.
Why each term exists
Proportional-only control leaves a steady offset because a nonzero command requires a nonzero error. The integral term fixes this: it keeps accumulating until the error is exactly zero. The derivative term counteracts the overshoot that high proportional and integral gains introduce, by pushing back when the error is closing quickly.
In Laplace form
The ideal PID transfer function is C(s) = Kp + Ki/s + Kd*s. The integral 1/s contributes infinite DC gain (killing steady-state error) and the derivative s contributes phase lead near crossover (adding stability margin).
Practical refinements
- Derivative filtering: pure derivative amplifies noise, so Kd*s is replaced by Kd*s/(1 + s/N) with a filter pole.
- Anti-windup: when the actuator saturates, the integrator is clamped to stop error accumulating uncontrollably.
- Setpoint weighting and derivative-on-measurement avoid a 'derivative kick' on step setpoint changes.
def pid_step(e, e_prev, integ, Kp, Ki, Kd, dt):
integ += e * dt
deriv = (e - e_prev) / dt
u = Kp*e + Ki*integ + Kd*deriv
return u, integ
PID remains dominant because it needs no accurate plant model and its three gains map onto intuitive behavior. Most temperature, flow, pressure, and motion loops in industry are PID. Its limits appear with long delays, strongly coupled multivariable plants, and hard constraints, where model-based methods like MPC do better.