Actuator Saturation, Integrator Windup and Anti-Windup
Ask the heater block of the intro to rise by with a well-tuned PI controller and something alarming happens: the temperature overshoots by more than , to over , and takes almost nine minutes to come back. The same controller handles a step perfectly. The difference is the actuator: the heater cannot deliver more than , so for a large step it sits at full power for minutes while the integrator keeps adding up error it cannot act on. When the temperature finally arrives, the integrator holds a huge value that must be "unwound" by an equally long period of negative error: overshoot. This is integrator windup, the most common practical failure of PI and PID loops, and the fix is a few lines of code.
Why it happens
Every actuator saturates: a valve is fully open, a PWM duty cycle reaches 100 %, a motor driver hits its current limit, a heater its maximum power. While is pinned at , the loop is open: the plant receives a constant input whatever the controller says. A proportional or derivative term does no harm (it stops changing when the error stops changing). The integral term, however, keeps integrating:
The controller's internal output climbs far above . When the error changes sign, must fall all the way back below before moves at all: the heater stays at full power after the target is passed. Windup is worse for long saturation (large steps, slow plants, weak actuators) and for small .
Two fixes
Clamping (conditional integration). Stop integrating when the controller is saturated and the error would push it further into saturation:
Simple, no extra parameter, used in most microcontroller PID libraries.
Back-calculation (tracking). Feed the saturation error back into the integrator with a tracking time constant (figure):
While saturated, the integrator is pulled towards the value that makes , with time constant . A common choice is for a PID and a fraction of for a PI; smaller unwinds faster but makes the loop sensitive to noise near the limit. Back-calculation also handles the case where the actuator's real position is measured (a valve that sticks): use the measured .
Other details of a complete design: the actuator rate limit can wind up the integrator too; in a cascade the inner loop's saturation must be reported to the outer controller (Cascade Control); and bumpless transfer is the same tracking idea applied to manual mode (Practical PID). Nonlinearities treats saturation as a nonlinear element in general.
Worked example: a 25 K step of the heater
Given: (K/W), SIMC PI from Model-Based Tuning: , ; heater limits ; setpoint step .
Find: overshoot and settling time (to , 2 % of the step) without anti-windup, with clamping, and with back-calculation ().
Solve: the step asks for at once, so the heater saturates. Even at full power the block needs about to rise (the final value at would be ). During that time the error is large, and without protection the integral grows to many times the that is finally needed. The simulation gives the numbers:
import numpy as np
K, T, theta = 4.0, 300.0, 10.0
Kp, Ti = 3.75, 80.0
Ki = Kp / Ti
umin, umax = 0.0, 14.4
dt, tend, step = 0.1, 1500.0, 25.0
nd = int(theta / dt)
def run(mode, Tt=40.0):
x, I = 0.0, 0.0
delay = np.zeros(nd) # sensor delay line
ys, us, Is = [], [], []
for k in range(int(tend / dt)):
y_meas = delay[k % nd]
e = step - y_meas
v = Kp * e + I
u = min(max(v, umin), umax)
if mode == "none":
I += Ki * e * dt
elif mode == "clamping":
if not ((v > umax and e > 0) or (v < umin and e < 0)):
I += Ki * e * dt
elif mode == "back-calculation":
I += (Ki * e + (u - v) / Tt) * dt
x += dt * (K * u - x) / T # heater block, Euler step
delay[k % nd] = x
ys.append(x); us.append(u); Is.append(I)
return np.array(ys), np.array(us), np.array(Is)
t = np.arange(int(tend / dt)) * dt
for mode in ("none", "clamping", "back-calculation"):
y, u, I = run(mode)
ts = t[np.nonzero(abs(y - step) > 0.5)[0][-1]]
print(f"{mode:16s}: peak rise {y.max():5.2f} K (overshoot {max(0.0, 100 * (y.max() - step) / step):4.1f} %), "
f"settled at {ts:5.0f} s, saturated for {dt * np.sum(u >= umax):4.0f} s, max integral {I.max():5.1f} W")none : peak rise 37.97 K (overshoot 51.9 %), settled at 523 s, saturated for 320 s, max integral 102.3 W
clamping : peak rise 25.00 K (overshoot 0.0 %), settled at 214 s, saturated for 147 s, max integral 6.2 W
back-calculation: peak rise 25.00 K (overshoot 0.0 %), settled at 243 s, saturated for 139 s, max integral 6.2 W
Without anti-windup the block overshoots by almost 13 K and the heater stays at full power for over five minutes; with either fix the loop arrives without overshoot in less than half the time. In the unprotected case the integral term reached several times the heater's whole range: that stored "debt" is the overshoot.
Lab: the linear loop never winds up
The PID lab's actuator has no limits, so it cannot show windup: its PI loop (, , ) overshoots for any step size. A real loop with the same gains would show that overshoot for small steps only, and much more for large ones. Keep this in mind whenever you read step-response specifications: they are small-signal numbers.
Guided lab: windup on the heater block
Hand calculation. For your block, estimate the full-power rise time to the setpoint () and the integral accumulated in that time; predict that large steps overshoot without anti-windup.
Simulation. Change the program to your model and gains; try steps of , and and plot y and u.
What you would measure. The heater on a current-limited supply via PWM, PI in a microcontroller. A small step () behaves the same with or without anti-windup. A large step (limited to above room temperature, so the windup overshoot stays below ) without anti-windup overshoots by several kelvin; with clamping the overshoot drops below about (the sensor's resolution and the model error set the floor). Log to see the saturation interval; it should match the hand estimate within about 20 %.
Hazards and safe setup. This experiment overshoots on purpose: cap the setpoint as above, add a software cut-off at and a thermal fuse, use a heat-resistant base, never leave it unattended; current limit about .
Pitfalls
- Limiting only the output and not the integrator: the output looks right, the integrator still winds up.
- Clamping on alone (without checking the sign of ): the integrator then stays frozen at its wound-up value whenever the error reverses, until the proportional term alone pulls back inside the limits.
- Forgetting that the "actuator" limit may be hidden downstream (a driver's current limit, a PLC output scaling to 0–100 %): the controller must know the real limits.
- Choosing much smaller than the sample time in a digital implementation: the tracking becomes unstable.
Practice
- A PI with sits saturated for with an average error of . How much does the integral term grow without anti-windup?
- Why does a P-only controller not wind up?
- With back-calculation and , how fast does the integrator approach its tracking value while saturated?
Answer
- , about seven times the heater's .
- It has no state: its output depends only on the present error, so it stops pushing the moment the error falls.
- Exponentially with time constant (ignoring the term).
Test yourself
Integrator windup happens when
- the derivative term is unfiltered
- the actuator saturates while the integrator keeps integrating the error
- the sensor is noisy
- the gain is too low
Clamping (conditional integration) stops the integrator when
- the error is zero
- the output is saturated and the error would drive it further into saturation
- the setpoint changes
- the derivative is large
In back-calculation, the integrator input gets the extra term
Why can the PID lab's step responses not show windup?
- its integrator is clamped
- its actuator has no limits
- it has no integral term
- it uses back-calculation