№ 41 · engineering

How cruise control holds a speed without knowing the car or the road

Cruise control does not know how heavy the car is, how steep the road is, or which way the wind blows. It knows one number: how far the speed is from the speed you asked for. That is enough.

Measure the miss, push back

A feedback controller is a rule that takes the difference between what you want and what you have and turns it into an action. The difference is called the error. In cruise control the error is set speed minus actual speed; the action is how far to open the throttle. Slow means more throttle. Fast means less. The controller repeats this many times a second and never needs to know why the speed changed.

Why one number is enough

The alternative is to work everything out in advance: the car's weight, the slope, the drag, the engine's torque at this speed and gear. Get any of it wrong and the car settles at the wrong speed with nothing to correct it. Feedback replaces knowledge with measurement. Whatever slows the car, the error grows and the controller pushes harder. That is why the same three-term rule, called PID, runs cruise control, building thermostats and most industrial loops: it works on systems nobody has modelled well. One 2010 paper argues this is exactly why PID is everywhere: sampled in time, a well-tuned PID behaves like a controller that re-estimates a crude local model of the system from recent measurements at every step, so it needs no model in advance.

The three terms

Proportional. Throttle proportional to the error: twice the error, twice the extra throttle. The obvious rule, with a flaw you can see on a hill. Climbing takes more throttle than flat road. A proportional controller can supply that extra throttle only if the error is not zero, so the car settles a little below the set speed and stays there. That leftover gap is the steady-state error. Raising the gain shrinks it but never removes it, and a large enough gain makes the car surge: the throttle responds to a speed already a fraction of a second old — in any real car it acts through engine and sensor delays — so it overshoots, then over-corrects, repeatedly.

Integral. Add up the error over time and add throttle in proportion to the running total. A small, persistent gap does not stay small to the controller: the total keeps growing, and the throttle with it, until the gap closes. When the error reaches zero the total stops changing and holds the throttle the hill needs. This is how the leftover gap is removed. If a steady state exists, an integral term makes the error there exactly zero, without knowing the slope or the mass.

Derivative. Watch how fast the error is changing and push against the change. When the speed is climbing back toward the set point quickly, the derivative term eases off before it arrives. It acts as a brake on the correction itself, so an oscillating loop settles faster. Too much and the controller reacts to noise in the speed reading instead of the speed.

Interactive Leave Ki and Kd at zero and watch the speed settle below the line once the hill starts; raise Ki until the gap closes; then push Kp to the right and watch the car hunt.

A 1600 kg car in fourth gear holding 20 m/s meets a 4° grade at t = 5 s, ramping in over one second; the engine torque curve, air drag, rolling friction and the pull of gravity on the slope are the ones in Åström and Murray's cruise-control model. Throttle is clamped between 0 and 1 and the integral term stops accumulating while the throttle is pinned. Two simplifications: the engine answers the throttle through a 0.5 s lag, and the speed reading the controller sees is 0.2 s old — a stand-in for real sensing and drivetrain delays, and the reason a very high gain hunts here as it does in a real car. No wind, no gear changes, no noise in the speed sensor.

In short

A feedback controller acts on the error, not a model of the world. Proportional action pushes against the error but needs some error left over to hold a load, so a hill leaves the car slightly slow. Integral action accumulates that leftover and keeps pushing until it is gone. Derivative action leans against fast change so the correction does not overshoot. Push any gain too far and the loop chases its own delayed reaction, and the car hunts instead of holding.

Where this comes from

  1. A mathematical explanation via "intelligent" PID controllers of the strange ubiquity of PIDs linked only, not reproduced
    Brigitte D'Andrea Novel (CAOR), Michel Fliess (INRIA Saclay - Ile de France, LIX), Cédric Join (INRIA Saclay - Ile de France, CRAN), Hugues Mounier, Bruno Steux (CAOR) · arXiv:1005.0440 · 2010
    arxiv.org/abs/1005.0440
  2. Feedback Systems: An Introduction for Scientists and Engineers, 2nd ed. (§1.6, §4.1, §11.1; free PDF linked from the book site) linked only, not reproduced
    Karl Johan Åström and Richard M. Murray · 2020
    fbsbook.org