PID controller
A proportional-integral-derivative controller chases a setpoint by combining three error signals. Adjust the gains and watch overshoot, oscillation, and steady-state error appear and disappear.
How a PID controller works
A PID controller is the most widely used feedback controller in engineering. It computes a control output u(t) from three terms, each responding to a different aspect of the error e(t) = setpoint − actual. The output is:
u(t) = Kp e(t) + Ki ∫ e(τ) dτ + Kd de/dt
The proportional term Kp e(t) responds to the present error. It pushes the system toward the setpoint in proportion to how far away it currently is. A high Kp gives a strong response but can cause overshoot and oscillation. A low Kp is sluggish. With proportional control alone, there is almost always a steady-state error: the system settles near the setpoint but never quite reaches it, because as the error shrinks, so does the corrective force.
The integral term: memory
The integral term Ki ∫ e(τ) dτ responds to the accumulated past error. It sums up all the error over time. If the system has been sitting below the setpoint for a while, the integral grows and pushes harder. This eliminates steady-state error — the integral keeps building until the error is truly zero. But the integral also has a dark side: integral windup. If the system is saturated or slow, the integral accumulates a large value that takes time to unwind, causing overshoot. In practice, engineers use anti-windup techniques to clamp the integral term.
The derivative term: anticipation
The derivative term Kd de/dt responds to the rate of change of the error — a prediction of the near future. If the error is shrinking rapidly, the derivative acts as a brake, reducing overshoot. If the error is growing, it adds urgency. The derivative is the damping term: it smooths out oscillations and makes the response crisper. However, derivative control is sensitive to noise — rapid fluctuations in the measurement produce large, jittery derivative values. In real systems, the derivative is typically filtered.
Tuning and trade-offs
PID tuning is the art of balancing speed, stability, and accuracy. The Ziegler-Nichols method (1942) provides initial gain values by pushing the system to the edge of oscillation: increase Kp until the system oscillates at a constant amplitude (the ultimate gain Ku), measure the ultimate period Tu, then set gains from a lookup table. Modern methods use frequency-domain analysis, optimization, or adaptive control, but the core tension remains: fast response versus smooth settling, zero steady-state error versus stability.
Where PID lives
PID controllers regulate temperature in ovens, altitude in drones, speed in cruise control, position in robotic arms, and pH in chemical reactors. The algorithm runs on everything from a microcontroller to a mainframe. Roughly 95% of all industrial control loops use PID or a variant. Its power comes not from sophistication but from generality: three knobs, and they cover an enormous range of systems. The simulation above models a second-order system (mass with damping) driven by the PID output as a force. Try the presets to see how the same system behaves under very different tuning strategies.