PID controllers are way cooler than the Wikipedia article lets on

The Wikipedia entry on PID controllers is perfectly accurate, but it seems to bury the elegance of the technology and theory. Meanwhile, the article on gyroscopic autopilot (both maritime and aeronautical) makes no mention of PID controllers, despite that being the field in which the theory of PID controllers was developed.

PID controllers are all around us. They make elevators accelerate and decelerate without knocking passengers to the floor or pinning them to the ceiling, they stabilize video for pros and consumers alike, they make anti-lock brakes work, and nearly every other automated task in the software and physical world where the control needs to be adjusted based on observed conditions.

An exciting example of PID controllers can be found in the classic engineering challenge of balancing an inverted pendulum. This can be modeled in Matlab, but it’s rather more exciting to watch:

As it turns out, PID controllers are also at the core of making quadcopters and drones flyable (moar). And that’s the foundation for this video explaining PID controllers:

So here’s my explanation: PID controllers assume that you start with a set point, labeled SP or r(t), and an observed condition or process variable, labeled PV or y(t). The set point (SP or r(t)) could be a desired compass heading, and the observed condition/process variable (PV or y(t)) could be the actual compass heading. A PID controller autopilot uses those two inputs to generate an output that sets the rudder position to steer the ship. Over time, as the wind and currents change and the actual compass heading (PV or y(t)) drifts from the set point (SP or r(t)), the PID controller has to adjust the rudder angle to keep the ship on the same heading.

So, back to the Wikipedia text: if you cut away most of it, the simple beauty starts to emerge. PID, standing for Proportional, Integral, and Derivative, are the three ways the input values, the point (SP or r(t)) and the observed condition/process variable (PV or y(t)) are processed to generate the control output:

  • Term P is proportional to the current value of the SP − PV error e(t). For example, if the error is large and positive, the control output will be proportionately large and positive, taking into account the gain factor “K”. Using proportional control alone in a process with compensation such as temperature control, will result in an error between the setpoint and the actual process value, because it requires an error to generate the proportional response. If there is no error, there is no corrective response.
  • Term I accounts for past values of the SP − PV error and integrates them over time to produce the I term. For example, if there is a residual SP − PV error after the application of proportional control, the integral term seeks to eliminate the residual error by adding a control effect due to the historic cumulative value of the error. When the error is eliminated, the integral term will cease to grow. This will result in the proportional effect diminishing as the error decreases, but this is compensated for by the growing integral effect.
  • Term D is a best estimate of the future trend of the SP − PV error, based on its current rate of change. It is sometimes called “anticipatory control”, as it is effectively seeking to reduce the effect of the SP − PV error by exerting a control influence generated by the rate of error change. The more rapid the change, the greater the controlling or dampening effect.

(Emphasis added.)

The real magic of PID controllers, however, is that they’re a closed loop, a combination of set point, observation, and a reaction to the difference between them. It’s one thing to choose a heading, but it’s another thing to observe the actual heading and adjust to it.

That doesn’t make PID controllers perfect or infallible, and the theories about how to tune them for optimal operation are many, but they’re a start.