Choosing the tracking time
A short
A water heater is switched on cold every morning, and every morning the water goes several degrees past the setpoint and stays hot for a quarter of an hour. The tuning was done with care and the step tests looked correct, so the technician lowers the gain, and the loop becomes slow without losing the overshoot. The cause is not the tuning. The heater reached 100 percent, the model that the tuning rule used stopped being true, and the integral term kept growing with nothing to act on. This lesson covers what the linear model omits: output limits, integral windup, noise, sticking valves and badly placed sensors. #IntegralWindup #AntiWindup #ControlLoops
By the end of this lesson, you will be able to:
The hot water tank of this course has an electric heater and a temperature sensor on the outlet pipe. Near its normal operating point the loop is easy to control. The morning start is different. The water is at 25 °C, the setpoint is 55 °C, and the controller asks for more heat than the heater has. The output stays at 100 percent for several minutes.
During those minutes the loop is open: the heater gives the same power whether the controller asks for 100 or 300 percent. A controller that does not know this keeps summing the error. When the process variable (PV), here the temperature, at last reaches the setpoint, the integral term holds a large value the plant never needed, and only a period of negative error (water that is too hot) can remove it.
The same pattern appears on a pump at full speed and on a valve that is fully open. The linear tools describe the loop between the limits. This lesson describes what happens at the limits and at the sensor.
A controller equation can produce any number. A heater can produce between 0 and 100 percent of its power. Write
When
In the ISA standard form the integral term is
with controller gain
At the moment the process variable reaches the setpoint the error is zero, so the proportional term is zero and the output equals the integral term alone. At steady state the integral term must equal the output that holds the setpoint,
This is why windup overshoot lasts so long. The area above the setpoint is fixed by the excess, and a slow loop spreads it over many minutes.
Clamping (also called conditional integration) stops the integral from changing in the wrong direction while the output is saturated. The rule is:
Clamping needs no extra setting, so it is the most common method in small controllers and in firmware. Its weakness is that the integral holds whatever value it had when saturation began. If that value is far from
Back-calculation does not freeze the integral. It feeds the difference between the delivered output and the calculated output back to the integrator through a tracking time
Between the limits
Choosing the tracking time
A short
The derivative term acts on a rate of change. A setpoint step is a change in zero time, so a derivative that acts on the error produces a very large, very short output pulse. This pulse is the derivative kick. The usual cure is to take the derivative of the measurement
A pure derivative also has a gain that rises without limit as frequency rises, so it amplifies noise. Every practical controller therefore filters the derivative with a first-order filter of time constant
The divisor
A pressure or flow signal carries noise from turbulence, pump pulsation and the electronics. The proportional term multiplies this noise by
A first-order filter on the measurement reduces the noise. In a digital controller with sample time
Here
The filter is not free. It is one more lag inside the loop. At a frequency
and the lag at the crossover frequency
A control valve with a tight stem packing does not move for a small change of signal. The force must rise until it exceeds the static friction, and then the stem jumps. This is stiction. Deadband is the related fault where the stem does not follow a reversal of the signal until the signal has moved by some amount (for example, slack in a linkage).
With stiction and integral action the loop oscillates in a fixed pattern, a limit cycle: the stuck valve leaves a small error, the integral ramps the output until the valve jumps too far, the error changes sign, and the ramp reverses. Its amplitude is set by the size of the jump, not by the tuning. A heavy box on a rough floor behaves the same way: push, nothing, push harder, and it slides past where you wanted it.
No tuning removes this limit cycle: a lower gain or a longer integral time only makes the period longer. To test, put the controller in manual with the output constant. If the oscillation stops, the loop was producing it. If the trend then shows a triangle in the output and a square in the process variable, as in the drawing, suspect the valve. The cure is mechanical (service the packing, fit or calibrate a positioner).
A sensor fitted far from the place where the process changes adds transport delay. For a pipe of length
The process gain
Two loops that share one process disturb each other. A pressure loop and a flow loop on the same pipe are the usual example: when the flow valve opens the pressure falls, the pressure loop raises the pump speed, and the flow changes again. If both loops have similar speeds they can oscillate together even though each one is stable alone. The practical rule is to separate them in speed by a factor of 3 to 5. Tune the loop that matters most to be fast, and tune the other to be slow.
The questions below sort the common causes in the order that costs the least time on site.
Controller gain from the lambda rule:
Integral time:
Output needed at the setpoint. The rise is
First output asked for. The error at
Temperature while the heater is at 100 percent. After the dead time the rise follows a first-order curve towards
Time to reach 55 °C. Set the rise to 30 °C:
Area under the error. During the dead time the error is 30 °C for 40 s, which gives
The total area is
Integral term at the setpoint with no anti-windup:
Excess. The plant needs 60 percent. The integral holds 78.4 percent, an excess of 18.4 percent. To remove it the temperature must spend
The simulation uses a time step of 0.5 s, an exact first-order update and a buffer of 80 past outputs for the 40 s dead time.
No anti-windup. The integral term peaks at 78.5 percent. The temperature overshoots by 2.42 °C (8.1 percent of the 30 °C change) and stays above 55.5 °C for 666 s. ✅
Clamping. The integral term is held at zero while the output is saturated and never exceeds 60.0 percent. There is no overshoot, but the heater leaves the limit after only 107 s (when
Back-calculation,
Back-calculation with
| Case | Overshoot (°C) | Time above 55.5 °C (s) | Time at 100 percent (s) | Integral peak (percent) | Within 0.5 °C at (s) |
|---|---|---|---|---|---|
| No anti-windup | 2.42 | 666 | 250 | 78.5 | 994 |
| Clamping | 0.00 | 0 | 107 | 60.0 | 981 |
| Back-calculation, | 0.00 | 0 | 186 | 60.0 | 402 |
| Back-calculation, | 0.00 | 0 | 77 | 60.0 | 1,064 |
Integral peak. The hand estimate gave 78.4 percent at 314.9 s. The simulation gives a peak of 78.5 percent. The two agree within the 0.5 s time step. ✅
Steady state. At the setpoint the error is zero, so the output equals the integral term, and it must equal
Area above the setpoint. The estimate asked for about 1,100 °C s above the setpoint. An overshoot of 2.42 °C that takes more than 600 s to fall below 0.5 °C is of this size. ✅
Settings.
Loop transfer function. Because
Crossover frequency.
Phase margin. The integrator gives
Proportional term. Noise of 0.05 bar becomes
Peaks. Almost all samples of this kind of noise lie within three standard deviations, so the speed command moves by about
Reduction needed. The requirement of 0.2 percent needs a ratio
Try
Noise ratio.
The filtered noise is
Phase lag at crossover.
This is inside the 5 degree allowance. With the filter in the loop the exact phase margin is 72.84 degrees. ✅
Compare the alternatives.
| Speed noise (percent) | Lag at | Phase margin (degrees) | ||||
|---|---|---|---|---|---|---|
| 0.02 | 0.3333 | 0.447 | 0.0224 | 0.335 | 0.57 | 75.10 |
| 0.05 | 0.1667 | 0.302 | 0.0151 | 0.226 | 1.43 | 74.25 |
| 0.10 | 0.0909 | 0.218 | 0.0109 | 0.164 | 2.86 | 72.84 |
| 0.20 | 0.0476 | 0.156 | 0.0078 | 0.117 | 5.71 | 70.06 |
| 0.50 | 0.0196 | 0.100 | 0.0050 | 0.075 | 14.04 | 62.43 |
| 1.00 | 0.0099 | 0.071 | 0.0035 | 0.053 | 26.57 | 52.49 |
Simulate the filter. The script passes 200,000 random samples with a standard deviation of 0.05 bar through the filter with
Short formula.
"""Windup on the hot water tank (plant A) and a noise filter for thebooster pump pressure signal (plant B). numpy, scipy, matplotlib only."""import numpy as npfrom scipy.optimize import brentqimport matplotlib.pyplot as plt
# ---------------- Application 1: plant A, start from cold ----------------K, TAU, THETA = 0.5, 300.0, 40.0 # degC per percent, s, sLAM = 2.0 * THETAKC, TI = TAU / (K * (LAM + THETA)), TAU # lambda tuning, PI, ISA formY_COLD, R = 25.0, 55.0 # degCDT, T_END = 0.5, 3000.0print("Plant A: Kc = %.2f percent per degC, Ti = %.0f s" % (KC, TI))
def start_up(mode, tt=TI): """mode: 'none', 'clamp' or 'back'. Returns t, y, u, integral term.""" n, nd = int(T_END / DT), int(round(THETA / DT)) a = np.exp(-DT / TAU) buf = [0.0] * nd # dead-time buffer of past outputs x, integ = 0.0, 0.0 # rise above cold, integral term t = np.arange(n) * DT y_log, u_log, i_log = np.zeros(n), np.zeros(n), np.zeros(n) for k in range(n): y = Y_COLD + x e = R - y v = KC * e + integ # output before the limits u = min(100.0, max(0.0, v)) # the heater can give 0 to 100 y_log[k], u_log[k], i_log[k] = y, u, integ di = KC / TI * e * DT if mode == "none": integ += di elif mode == "clamp": if not ((v > 100.0 and e > 0) or (v < 0.0 and e < 0)): integ += di else: # back-calculation integ += di + (u - v) / tt * DT buf.append(u) x = a * x + K * (1.0 - a) * buf.pop(0) return t, y_log, u_log, i_log
print(" case overshoot above 55.5 at 100 % integral (%) within 0.5")print(" (degC) (s) (s) peak min at (s)")fig, axes = plt.subplots(3, 1, figsize=(7, 8), sharex=True)cases = [("no anti-windup", "none", TI), ("clamping", "clamp", TI), ("back-calc Tt=300 s", "back", 300.0), ("back-calc Tt=30 s", "back", 30.0)]for label, mode, tt in cases: t, y, u, i = start_up(mode, tt) outside = np.where(np.abs(y - R) > 0.5)[0] print(" %-19s %7.2f %8.0f %8.0f %6.1f %6.1f %7.0f" % (label, max(y.max() - R, 0.0), np.sum(y > R + 0.5) * DT, np.sum(u >= 100.0) * DT, i.max(), i.min(), t[outside[-1] + 1])) for ax, sig in zip(axes, (y, u, i)): ax.plot(t, sig, label=label)axes[0].axhline(R, color="gray", lw=0.8, ls="--")for ax, name in zip(axes, ("temperature (degC)", "heater (%)", "integral term (%)")): ax.set_ylabel(name); ax.grid(alpha=0.3)axes[0].legend(); axes[2].set_xlabel("time (s)"); axes[2].set_xlim(0, 1500)fig.tight_layout(); fig.savefig("windup_start_up.png", dpi=120)
# hand check of the integral at the moment the temperature reaches 55 degCt_rise = TAU * np.log(50.0 / 20.0)area = 30.0 * THETA + (30.0 - 50.0) * t_rise + 50.0 * TAU * (1 - np.exp(-t_rise / TAU))print(" hand check: reaches 55 degC at %.1f s, error area %.0f degC s, " "integral %.1f percent" % (THETA + t_rise, area, KC / TI * area))
# ---------------- Application 2: plant B, measurement filter -------------K, TAU, THETA = 0.10, 3.0, 0.5 # bar per percent, s, sKC, TI = TAU / (K * (3.0 * THETA + THETA)), TAUSIGMA, TS = 0.05, 0.01 # bar, s (100 samples per second)print("\nPlant B: Kc = %.1f percent per bar, Ti = %.1f s" % (KC, TI))
def loop(w, tf=0.0): s = 1j * w return KC * (1 + 1 / (TI * s)) * K * np.exp(-THETA * s) / (TAU * s + 1) / (tf * s + 1)
def crossover(tf=0.0): wc = brentq(lambda w: abs(loop(w, tf)) - 1.0, 1e-3, 10.0) return wc, 180.0 + np.degrees(np.angle(loop(wc, tf)))
wc, pm = crossover()print(" no filter: crossover %.4f rad/s, phase margin %.2f deg" % (wc, pm))print(" Tf (s) alpha noise ratio sigma (bar) Kc*sigma (%) lag (deg) PM (deg)")for tf in (0.02, 0.05, 0.1, 0.2, 0.5, 1.0): alpha = TS / (tf + TS) ratio = np.sqrt(alpha / (2.0 - alpha)) print(" %5.2f %.4f %8.4f %9.4f %10.3f %8.2f %7.2f" % (tf, alpha, ratio, SIGMA * ratio, KC * SIGMA * ratio, np.degrees(np.arctan(wc * tf)), crossover(tf)[1]))
rng = np.random.default_rng(1) # check the formula on random noisenoise = rng.normal(0.0, SIGMA, 200000)alpha, f, out = TS / (0.1 + TS), 0.0, np.zeros(noise.size)for k, v in enumerate(noise): f += alpha * (v - f) out[k] = fprint(" random check, Tf = 0.1 s: raw %.4f bar, filtered %.4f bar" % (noise.std(), out[1000:].std()))Expected output
Plant A: Kc = 5.00 percent per degC, Ti = 300 s case overshoot above 55.5 at 100 % integral (%) within 0.5 (degC) (s) (s) peak min at (s) no anti-windup 2.42 666 250 78.5 0.0 994 clamping 0.00 0 107 60.0 0.0 981 back-calc Tt=300 s 0.00 0 186 60.0 0.0 402 back-calc Tt=30 s 0.00 0 77 60.0 -27.4 1064 hand check: reaches 55 degC at 314.9 s, error area 4702 degC s, integral 78.4 percent
Plant B: Kc = 15.0 percent per bar, Ti = 3.0 s no filter: crossover 0.5000 rad/s, phase margin 75.68 deg Tf (s) alpha noise ratio sigma (bar) Kc*sigma (%) lag (deg) PM (deg) 0.02 0.3333 0.4472 0.0224 0.335 0.57 75.10 0.05 0.1667 0.3015 0.0151 0.226 1.43 74.25 0.10 0.0909 0.2182 0.0109 0.164 2.86 72.84 0.20 0.0476 0.1562 0.0078 0.117 5.71 70.06 0.50 0.0196 0.0995 0.0050 0.075 14.04 62.43 1.00 0.0099 0.0705 0.0035 0.053 26.57 52.49 random check, Tf = 0.1 s: raw 0.0499 bar, filtered 0.0108 barThe script also saves windup_start_up.png, with the temperature, the heater output and the integral term of the four cases on one time axis.
A PID controller has
The booster pump loop of Application 2 has
The valve in a pressure loop sticks until the controller output has changed by 2 percent. The loop has
The integral ramps at
The pump of Application 2 has a process gain of 0.10 bar per percent at 60 percent speed and 0.16 bar per percent at 90 percent speed. The loop was tuned at 60 percent with
Keep
Repeat the hand estimate of Application 1 for a setpoint of 65 °C (same plant, same settings, start at 25 °C, no anti-windup). Find the time to reach the setpoint, the integral term at that moment and the excess over the output the plant needs.
The rise is 40 °C and
The tank starts cold at 25 °C with a setpoint of 55 °C. The PI controller holds the heater at 100 percent for the first minutes. To hold 55 °C the tank needs 60 percent. What does the heater output do at the moment the temperature first reaches 55 °C?
The loop is the lesson's hot water tank started cold: the water is at 25 °C, the setpoint is 55 °C from time zero, and the PI controller has the lesson's settings, a gain of 5 percent per °C and an integral time of 300 s. The third plot is the integral term alone. At rest it must equal the output that holds the setpoint, which is 60 percent, the gold line. Watch what the integral term does while the output is held at its limit. Back-calculation uses a tracking time equal to the integral time, 300 s. The noise is one standard deviation, and it is the same noise at every run so that you can compare. The first plot shows the reading that the controller sees. The readouts use the true water temperature.
Three questions. Each wrong choice is a mistake people really make, so read the note after you answer.
1. With no anti-windup the integral term of the tank controller peaks at 78.5 percent. The tank needs 60 percent to hold 55 °C. How does the extra 18.5 percent leave the integral term?
2. Clamping and back-calculation both start the tank with no overshoot. With which one is the water within 0.5 °C of the setpoint sooner?
3. The heater is replaced by a smaller one. It gives 80 percent of the old power at most, so the output limit is now 80 percent. The controller has no anti-windup. What happens to the overshoot after a cold start?
No comments yet. Questions, results from your own build, a better way to explain it: all welcome.
Kept on this device only. Nothing is sent anywhere.
Tip: select words in the lesson, or tap a figure or an equation, to put a note right there.
The lesson has changed and these words are no longer in it. Your notes are kept, with the words you chose.