← Articles
SCADA/13 min read/— views

Why Your PID Loop Overshoots Every Time the Valve Hits a Limit

Reset windup is why a well-tuned loop overshoots after saturation. A runnable level-loop simulation: 49.6% overshoot with no anti-windup, 11.0% with the crudest fix.

SCADAControlPLCTroubleshootingCommissioning

The loop is fine until something clamps the output

A level loop that tracks setpoint to within half a percent all day will, once in a while, sail past setpoint by ten percent and take two minutes to crawl back. It almost always happens after the same handful of events: the control valve drove fully open on a big demand, an operator held the loop in Manual for a while and then flipped it to Auto, or the plant just came off a cold start with the setpoint ramping up from zero.

The tuning is not the problem. The problem is the integrator. When the output can't move but the error won't go away, the integral term keeps accumulating against a wall, and that stored-up demand has to be unwound before the output comes back into the controlling range. That's reset windup, and it's the single most common reason a "well-tuned" loop misbehaves at exactly the moments you care about.

Where the integral goes when the output is stuck

Take a plain textbook PID in positional (absolute) form. The integral term is a running sum of error times time. As long as the output — call it the controller output, CV, 0–100% to the valve — is somewhere between its limits, that sum settles wherever it needs to hold the valve steady with zero error. Normal.

Now saturate it. Suppose the level is far below setpoint, the loop calls for more than 100% output, and the valve is already wide open. Physically the loop can do nothing more. But the error is still large and positive, so the integrator keeps piling up, second after second. The internal CV climbs past 100% to whatever the code lets it reach — 143% in the run below, with the integral term alone at 125%. The valve doesn't care. It's pinned at 100%.

Then the level finally crosses setpoint. Error flips sign. A healthy loop would start closing the valve immediately. This one can't, because the integrator is sitting at 125% and error has to spend a long time negative just to drag that sum back down under 100% before the valve moves off its stop at all. In the measured run below that unwind takes 16.4 s past the setpoint crossing, and the valve stays wide open for every second of it while the level keeps climbing. That's your overshoot. The loop isn't sluggish — it's digging out of a hole it dug while the output was saturated.

The same trap springs on any output limit, not just 0/100%. Output rate limits, a downstream "valve can't open past 80% during startup" clamp, a cascade secondary that's maxed out — anywhere the CV the controller computes can't reach the actuator, the integrator can wind up against the gap.

The same loop with four integrators, measured

Arguing about this in prose is cheap, so here is a loop you can run. A tank level integrates inflow minus a constant 4 %/s draw. The valve has 10 s of transport dead time and, wide open, delivers only 5.5 %/s — 1.5 %/s of spare capacity. Cold start from 0% to a 50% setpoint, positional PID at Kp 0.8 valve%/level% and Ti 30 s, 200 ms scan. The loop is genuinely saturated for the first ~80 s, because physics says so, not because the tuning is bad.

def run(mode, Tt=None, secs=1200.0, dt=0.2):
    Kp, Ti, SP = 0.8, 30.0, 50.0           # valve % per level %, reset seconds
    GAIN, DRAW, DEAD = 0.055, 4.0, 10.0    # level %/s per valve %, draw %/s, dead time s
    pipe = [0.0] * int(DEAD / dt)
    pv = I = peak = umax = imax = 0.0
    cross = settle = None
    for k in range(int(secs / dt)):
        t = k * dt
        e = SP - pv
        I += (Kp / Ti) * e * dt
        u = Kp * e + I                     # unlimited controller output
        v = min(100.0, max(0.0, u))        # what the valve actually gets
        if mode == "clamp" and ((v >= 100.0 and e > 0) or (v <= 0.0 and e < 0)):
            I -= (Kp / Ti) * e * dt        # freeze the integrator
        elif mode == "back":
            I += (v - u) * dt / Tt         # back-calculation
        pipe.append(v)
        pv += (GAIN * pipe.pop(0) - DRAW) * dt
        peak, umax, imax = max(peak, pv), max(umax, u), max(imax, I)
        if cross is None and pv >= SP:
            cross = t
        settle = t if (settle is None and cross and abs(pv - SP) <= 0.5) else settle
        if abs(pv - SP) > 0.5:
            settle = None
    return peak, cross, settle, umax, imax, pv

for mode, Tt in (("none", None), ("clamp", None), ("back", 30.0), ("back", 10.0)):
    print(mode, Tt, [round(x, 1) if x else x for x in run(mode, Tt)])
Integrator treatmentPeak levelOvershootUnlimited u peakIntegral peakBack inside ±0.5%
none99.6%+49.6%143%125%342 s
freeze (clamping)61.0%+11.0%102%82%260 s
back-calculation, Tt = Ti = 30 s71.6%+21.6%123%92%271 s
back-calculation, Tt = 10 s62.9%+12.9%114%84%262 s

All four settle at 50.00%, so a trend caught an hour later shows four healthy loops. The untreated one overshoots 4.5 times as far and takes 82 s longer to come back inside half a percent. In a real tank, 99.6% on a 50% setpoint is the overflow alarm.

Two honest caveats. This is one plant and one tuning, so the ordering of clamping against back-calculation is not a general result — clamping winning here is a product of the integral being at 82% when the limit was hit, which happened to be close to the 73% the valve needed. What is not plant-specific is the gap between the first row and all the others. And Tt = Ti, the textbook starting point (Åström and Hägglund's PID books, not a standard — no standard specifies Tt), was the worst of the three fixes in this run. Tt is a knob to turn against your own loop, not a value to copy.

Anti-windup: stop integrating into a wall

Every serious controller solves this. The differences are in how gracefully they let go.

Clamping / conditional integration is the crude one. When the output is saturated, you simply stop updating the integrator — freeze it — or you only allow integration in the direction that would bring the output out of saturation. It's a few lines: if (CV >= CV_max && error > 0) hold_integral; and the mirror case at the low limit. It works, it's cheap, and it's what a lot of homebrew PLC PID blocks do. The weakness is that it's binary. The integrator sits frozen at whatever value it had when it hit the limit, which may still be well above what's needed, so you get a smaller version of the same delayed recovery.

Back-calculation is the one I reach for when the vendor block offers it, with the table above as a reminder to check rather than trust it. Instead of freezing, you feed the difference between the limited output and the unlimited output back into the integrator through a gain, so the integrator is continuously pulled toward a value consistent with the saturated output. The tuning knob is a tracking time constant, Tt — how fast the integrator gets desaturated. A common starting point is Tt near the integral time Ti, or the geometric mean of Ti and derivative time Td when there's derivative action. Smaller Tt unwinds faster — dropping Tt from 30 s to 10 s in the run above cut the overshoot from +21.6% to +12.9% — but it can make the exit from saturation twitchy, so sweep it rather than taking either number on faith. The payoff is that when the output comes off the limit, the integrator is already sitting at a sane value, so the loop hands control back smoothly instead of lurching.

External reset (a.k.a. reset feedback) is the same idea done through the loop structure rather than a bolt-on. The integral is implemented as a positive feedback of a filtered output signal, and you feed back the actual actuator or downstream measurement as that signal. If the valve is stuck at 100%, the fed-back value is 100%, and the integrator naturally can't demand more than that. DeltaV and Foxboro-style controllers lean on this heavily, and it's the correct backbone for cascade — the primary's external reset comes from the secondary's measured PV, so the primary automatically stops winding up whenever the secondary can't keep up. If you build cascade with two independent windup-clamped blocks and no reset feedback between them, you've rebuilt the windup problem one level up.

If you're writing the loop yourself and you get to pick, the velocity (incremental) form sidesteps the worst of this for free. Instead of computing an absolute output, you compute the change in output each scan and add it to the previous output. Because there's no explicit integrator sum being stored, there's nothing to wind up — when the output is clamped at the limit, the accumulated position simply doesn't advance past it. You still want limit handling, but the ugly unwind-from-143% behavior is gone by construction. Running the same plant with out = clamp(out_prev + Kp*(e - e_prev) + (Kp/Ti)*e*dt) and no anti-windup logic at all peaks at 61.1%, within 0.1% of the clamped positional form, for none of the code. It crosses setpoint 26 s later, which is the price.

Which form you actually have is not something the standard settles. IEC 61131-3's standard function block library covers bistables, edge detection, counters and timers — there is no PID block in it. Every PID you have ever configured came from the vendor's library or PLCopen, which is exactly why the windup behaviour differs between two controllers that both say "PID" on the faceplate.

Manual-to-Auto is the same bug wearing a different hat

The overshoot after an operator flips Manual → Auto is windup's twin. In Manual, the operator is moving the output directly and the integrator isn't controlling anything. If the block keeps integrating the error the whole time it sits in Manual, then at the instant of transfer the integrator can be at some wild value that has nothing to do with the current output, and the CV jumps — a "bump."

The fix is bumpless transfer, and the mechanism is the same tracking machinery as anti-windup: while the loop is in Manual (or being forced/overridden), you make the integrator track so that the computed auto output equals the current manual output. Then at the moment of transfer, auto picks up exactly where manual left off, zero jump, and the loop eases from there. Any block that claims bumpless transfer is doing output tracking internally, and the same feature usually covers "output forced by interlock" and "downstream took control" as well as the plain Manual/Auto case.

Numbers from the same plant, operator holding Manual at 40% for 120 s while the setpoint stays at 50% and the level drains away:

Integrator in ManualIntegral at transferFirst Auto outputJump
left integrating the error141.3%100.0% (clipped from 181.3%)+60.0%
tracked to the manual output0.0%40.0%0.0%

A 60% step onto a valve is a water hammer, not a control action. The tracking case starts from the 40% the operator left and ramps from there.

A few things I check at commissioning, because vendors implement this unevenly:

  • Force the output to a limit and watch the unwind. Drive the PV so the loop saturates, hold it, then release. If the valve doesn't start moving the instant PV crosses setpoint, windup handling is off or misconfigured. On the simulated loop the untreated case keeps the valve at 100% for 16.4 s past the setpoint crossing while every treated case has already left the limit — that is the thing to watch on the trend. This is a two-minute test and it catches the exact failure operators complain about.
  • Bump Manual → Auto at several output levels, not just at 50%. Do it with the PV on setpoint and with the PV off setpoint. The output should not jump; if it does, tracking isn't wired.
  • Check the startup case. A setpoint ramping from zero on a cold start is a slow-motion saturation — confirm the loop doesn't wind up during the ramp and dump the whole stored demand the moment the process comes alive.
  • On cascade, break the secondary. Put the secondary in Manual or drive it to its limit, then watch the primary. With proper external reset the primary should stop winding up; without it, the primary quietly saturates while looking healthy on the faceplate.

The knob people reach for is usually the wrong one

When a loop overshoots, the reflex is to detune — drop the gain, lengthen the reset. Sometimes that's right. But if the overshoot only shows up after saturation or a mode change and the loop is otherwise crisp, detuning is treating a symptom. You'll make the loop sluggish everywhere to paper over misbehavior that only happens at the limits, and the overshoot won't fully go away because the integrator is still unwinding from wherever it wound up to. Fix the windup first — turn on back-calculation or reset feedback, verify bumpless transfer — and then judge whether the tuning actually needs to change. Most of the time it doesn't.

One more thing worth knowing before you trust a block: put the derivative on the measurement, not on the error. Derivative on error gives you a giant spike (derivative kick) every time an operator moves the setpoint, and on a valve that spike is a physical slam. Nearly every industrial block defaults to derivative-on-PV for this reason, but it's a settable option often enough that it's worth confirming rather than assuming — same as everything else in a PID block, which is far less standardized than its three-letter name suggests.