The Algorithm Running
Everything Around You

Right now, in the room where you're reading this, there is almost certainly a PID controller operating. If you have a thermostat, it's using some form of PID or its simpler predecessor. If you have a refrigerator, it's there. If there's a computer nearby — the fans controlling CPU temperature are PID-controlled. The power supply regulating your device's voltage is PID-controlled. If you drove here, your car's engine management system ran dozens of PID loops every second. If there's a factory within a few kilometers, hundreds or thousands of PID controllers are running the pressure, temperature, flow, level, and concentration of industrial processes.

The PID controller — proportional-integral-derivative — was formally described in 1942 by John Ziegler and Nathaniel Nichols at Taylor Instruments. It's been the dominant industrial control algorithm ever since. Approximately two billion PID controllers are estimated to be in operation globally. Most engineers who implement them couldn't precisely explain why the derivative term works. That gap between deployment and understanding is worth examining.

"Two billion PID controllers are running the world right now. It's the most successful algorithm ever deployed. And most people have no idea it exists."

What problem PID solves — and why feedback is the key

The problem PID solves is regulation: keep a physical quantity at a desired value (setpoint) despite disturbances and measurement noise. Temperature in a furnace. Pressure in a pipeline. Speed of a motor. pH of a chemical reactor. Level of liquid in a tank. The physical quantity being controlled is the process variable (PV). The desired value is the setpoint (SP). The difference between them is the error (e). The PID controller's job is to produce a control output — throttle position, valve opening, heater power — that drives the error toward zero.

Without feedback, this is impossible to do reliably. An open-loop controller (a timer-based oven, a fixed-speed conveyor) sends commands based on a model of how the system should behave, without measuring whether it actually behaved that way. If the model is wrong — different load, different ambient temperature, component aging — the error accumulates uncorrected. Feedback closes the loop: measure the outcome, compare to the desired outcome, adjust the input based on the difference. A thermostat is the simplest possible feedback controller: if temperature is below setpoint, turn on heat. If above, turn it off. This bang-bang control works but is rough — the temperature oscillates around the setpoint rather than settling precisely at it.

📜 The First Automatic Controller

James Watt's centrifugal governor, patented in 1788, is one of the first documented automatic feedback controllers. Two weighted balls on hinged arms spin with the engine shaft. As speed increases, centrifugal force throws the balls outward, which mechanically throttles the steam valve, slowing the engine. It's a pure proportional controller — correction proportional to speed deviation — and it worked well enough to make steam engines practical for driving machinery. Watt's governor also demonstrated the problem that every proportional-only controller has: "hunting" — oscillation around the setpoint. The balls would overshoot, throttle too far, slow the engine, the balls would drop, the throttle would open again — a cycle that persisted at some frequency and amplitude. This fundamental problem of proportional control — and its solution through integral action — wasn't fully analyzed mathematically until the 1930s.

The three terms — what each actually does

The proportional term (P) applies a correction proportional to the current error: output_P = Kp × e(t). Large error → large correction. Small error → small correction. The problem: a purely proportional controller always has a residual steady-state error. To maintain any correction at all, the error must be nonzero. The system settles at a point where the error is just large enough to produce the correction needed to hold steady state — and that error is the proportional offset. Higher Kp reduces the offset but reduces stability margin and increases tendency to oscillate.

The integral term (I) applies a correction proportional to the accumulated past error: output_I = Ki × ∫e(t)dt. If any error persists over time, the integral accumulates and keeps growing until the correction is large enough to eliminate the error. This eliminates the steady-state offset that haunts pure P control. But integral action is slow (it takes time to accumulate), and if the system is slow to respond, the integral accumulates past the point needed — driving the output well above setpoint before backing off. This integral windup causes large overshoots and long settling times. Anti-windup schemes — clamping the integrator output, resetting the integral on saturation — are essential in practical implementations.

The derivative term (D) applies a correction proportional to the rate of change of error: output_D = Kd × de/dt. It's predictive: if the error is changing rapidly, the derivative term applies a large correction in the opposing direction before the error gets too large. This damping action reduces overshoot and allows higher proportional gains. The derivative term is essentially applying the brakes before you reach the target rather than after you've passed it. The catch: derivative amplifies noise. Any measurement noise gets differentiated, creating large, rapid fluctuations in the derivative output. This is why most industrial PID controllers apply derivative only to the measured process variable, not the error — this "derivative on measurement" avoids the step changes in derivative output that occur when the setpoint changes.

🎯 The Shower as a PID Controller

You are a PID controller when you adjust a shower. You measure the water temperature (process variable), compare it to your desired comfortable temperature (setpoint), and adjust the hot/cold knob (manipulated variable) based on the error. Your proportional response: if it's much too cold, you turn the hot way up; if slightly too cool, you turn it a little. Your integral response: if it's been slightly cold for a while, you keep gradually increasing the hot even past your initial adjustment. Your derivative response: if the temperature is rapidly dropping, you preemptively turn up the hot before you're uncomfortable. And you know the shower's lag — how long between turning the knob and feeling the change — which is exactly the dead time that makes PID tuning difficult. A shower with a very long lag (common in hotels) is harder to control — you keep overcorrecting because the feedback is so delayed.

🤔 If PID has been around since 1942, why hasn't something better replaced it?

Better algorithms do exist for specific classes of problems — Model Predictive Control (MPC), adaptive control, fuzzy logic, neural network controllers — and they're used in specialized applications. But PID persists for several reasons. First, it works: for the majority of single-variable, moderately fast processes with modest dead time, a properly tuned PID is entirely adequate. Second, it's understandable: a control engineer can intuitively understand what each term does and tune it by inspection or with simple rules. Third, it's robust: PID degrades gracefully — a poorly tuned PID is usually just slow or slightly oscillatory, not unstable. Fourth, it's implemented in every DCS (Distributed Control System) and PLC ever made — switching to a different algorithm requires software changes, retraining, and re-certification that is expensive and operationally risky. The installed base of 2 billion PID controllers is not replaced by superior alternatives; it's replaced when the hardware wears out and better hardware happens to come with better algorithms. Process control conservatism isn't stubbornness — it's appropriate caution in industries where instability has catastrophic consequences.

🤔 How does a self-driving car's control system relate to PID?

Autonomous vehicle control uses a hierarchy of control loops, with PID at the bottom. At the lowest level, individual actuators — throttle, brakes, steering motor — are controlled by PID or similar loops that respond at millisecond timescales to maintain commanded values. A level up, lateral control (lane keeping) and longitudinal control (speed, following distance) use PID or more sophisticated controllers (MPC is common for lateral control because it can handle constraints — "don't steer past the lane boundary"). Above that, trajectory planning calculates the desired path and speed profile. Above that, behavioral planning decides what maneuver to execute. At the top, mission planning determines the route. Each layer produces setpoints for the layer below. The PID controllers at the bottom never know they're in an autonomous vehicle — they just know they have a setpoint and a measured value and their job is to minimize the error. The complexity of autonomous driving is concentrated in the perception, prediction, planning, and decision-making layers — the control execution layer is relatively conventional.

Sort Exercise

PID Term Actions

Drag to rank these PID terms from fastest-responding (top) to slowest (bottom).

  • Proportional (P) — reacts to current error magnitude
  • Integral (I) — reacts to accumulated past error, slowest
  • Derivative (D) — reacts to rate of change of error, predictive

Key Terms — PID Control

PID Controller
Proportional-Integral-Derivative controller. Dominant industrial feedback algorithm since 1942. ~2 billion in operation.
Proportional Offset
Residual steady-state error in a P-only controller — error needed to produce the correction that maintains equilibrium.
Integral Windup
Excessive accumulation of integral term while output is saturated — causes large overshoot when saturation clears.
Derivative Kick
Large transient derivative output when setpoint changes suddenly — avoided by applying derivative to measurement rather than error.
Dead Time
Delay between applying a control output and seeing any change in the process variable. Makes PID tuning difficult.
Model Predictive Control
Advanced control using a process model to optimize future inputs over a rolling horizon. Handles constraints and dead time better than PID.