IMDHMIControls LibraryShop main store

Troubleshooting

Why an M221 PID output stays stuck saturated after Kp zero

PLC programming Published 10 min read

Short answer

Setting Kp to 0 removes only the proportional term; the integral accumulated during a long saturation stays in the M221 PID output until error of the opposite sign unwinds it or the controller state is cleared. No anti-windup clamp is documented for the native block, and Ti = 0 adds a +5000 output offset. Characterize the block on a bench PV, or run a hand-rolled PI with explicit clamping on a near-integrating steam loop.

On this page
  1. Why does the PID output stay saturated after Kp is set to 0?
  2. Does the Modicon M221 native PID block have anti-windup?
  3. What does Ti = 0 change in the block output?
  4. Why is the Kp field capped near 10000, and what did rescaling the input change?
  5. Why did a 4 °C negative error barely move the pinned output?
  6. How do you characterize the block before it runs the steam valve again?
  7. When should you hand-roll the PI instead of trusting the native block?
  8. Questions asked

Setting Kp to 0 does not release a saturated PID output on a Modicon M221, and you should stop expecting it to: the gain multiplies only the proportional term, while the integral that built up while the output sat at its limit is stored state the block keeps until error of the opposite sign unwinds it or the controller state is cleared. The M221 advanced functions manual documents the Ti = 0 positional algorithm with its +5000 output offset and documents no anti-windup clamp for the native block, so the working assumption is that integration keeps running while the output is clamped. This article follows a reported steam-valve batch loop that spent several hundred seconds pinned at a 60% output limit, shows the arithmetic that explains what the test saw, and ends with the bench procedure and the decision for each case.

Why does the PID output stay saturated after Kp is set to 0? #

Because Kp multiplies only the proportional term: setting it to 0 leaves the integral the block accumulated during the saturation event untouched, and a parameter edit does not clear that stored value — the output leaves the limit only when opposite-sign error unwinds it.

A PID output is a sum of terms: one tracking the error now, one summing every error since the last reset, and the derivative. Kp sits in front of the proportional term, and in many implementations in front of the integral update as well. Write 0 into Kp on the fly and one of two things happens to the stored integral, and neither looks like a release:

  • If the gain multiplies the integral update, the accumulator stops where it stands: the stored value is frozen and the output sits wherever the clamp puts it, indefinitely.
  • If the accumulator sums the error on its own, it unwinds at error ÷ Ti per second, which at a small reversed error and a long Ti is far too slow to see on the HMI in a minute of watching.

Either way, Kp = 0 is a tuning change, not a reset. In the reported case the output was still pinned with Kp at 0, which is what a stored integral larger than the output limit itself looks like: with the proportional term gone, the clamped sum still rests on the rail.

Does the Modicon M221 native PID block have anti-windup? #

No anti-windup clamp is documented for the native block: the M221 advanced functions manual describes the operating modes and the Ti = 0 positional algorithm with its +5000 output offset, and it does not describe any clamp that stops integration while the output sits at a limit.

Anti-windup has two standard forms: conditional integration, which suspends the accumulator while the output is clamped, and back-calculation, which pulls the stored term back toward the clamped output. The Machine Expert Basic documentation in evidence covers the Assistant's operating modes — PID, AT + PID and AT — and which configuration tabs each enables, and says nothing about either mechanism. The reported behavior reads like integration without a clamp: hundreds of seconds at the limit, a slow release only under a large reversed error, then a turn back toward the limit as the error shrank. That is not proof of the internal algorithm, and it does not need to be: a clamp you cannot document is a clamp you cannot rely on, so design as if it is not there. The mechanics of both countermeasures, and why a loop that lives at its limit needs one, are worked through in this guide to PID integral reset and anti-windup during steady state.

What does Ti = 0 change in the block output? #

Ti = 0 switches the M221 PID to a positional algorithm and adds a fixed +5000 offset to the PID output — documented in the M221 advanced functions manual — so it is a mode change with a large output bias, not a way to switch integral action off.

That offset lands in the block's numeric output before your scaling and limiting see it, so the command at the valve is whatever your conversion makes of the biased number. The reported installation paid for this the hard way: a full test cycle went into diagnosing the offset before anyone connected it to the Ti setting. Find where it bites by reading the signal at three points with the loop held steady: the block's own output, the value after your conversion, and the value after the limit. If the bias is present at the block boundary, everything downstream inherits it. The decision: keep Ti above 0 on this loop, and if the configuration carries Ti = 0, remove it and re-baseline before running any other test.

Why is the Kp field capped near 10000, and what did rescaling the input change? #

The reported limit of about 10000 in the Kp field with a ×0.01 scale tops the internal gain out at 100, an installation observation rather than a manual figure, and rescaling the input range from 0–1000 to 0–10000 was how the installation reached the gain it needed.

The cap matters to the saturation question because of what the workaround did. Rescaling the input multiplies the numeric error by 10 at the same physical temperature: an error of 4 °C worth about 4 counts on the original 0–1000 scale is worth about 40 counts after the conversion. That is why the installation did it, because the effective loop gain rises with error magnitude, but the same factor multiplies the integral: accumulation during saturation runs 10 times faster in counts, and so does the unwind at a reversed error. Every rate in the worked example below carries that factor, so recompute it for your own conversion.

Three checks keep a rescale honest:

  • Apply a known PV value and read it before and after the Conversion block; the scaled number must track the engineering units without drift.
  • Confirm the setpoint path uses the same scale as the converted PV, or the error is wrong before the PID ever runs.
  • After entering Kp, read back the value the Assistant accepted rather than trusting the typed number.

The same read-back discipline applies on the way out: follow the numeric output through limiting and the PWM command to %Q0.1, exactly as you would when scaling a PID real output to analog output counts. If the calculation is healthy but the valve command will not let go, that is its own fault class, covered in why a lost release event leaves an HMI valve command stuck.

Why did a 4 °C negative error barely move the pinned output? #

The unwind rate is gain × error ÷ Ti: at the reported internal gain of 100 with a -40-count error and an example Ti of 200 s, the integral gives back 100 × 40 ÷ 200 = 20 counts per second — small enough to look frozen.

Here is the worked example, with the reported figures where they exist and clearly marked example values where they do not. Reported: the input rescale to 0–10000 counts, so 1 °C corresponds to 10 counts; a 60% output limit; several hundred seconds of saturation. Example values: Ti = 200 s; an output scale of 0–10000 counts, which puts the 60% limit at 6000 counts; an error of +50 °C, or 500 counts, while the batch heated.

The integration factor is gain ÷ Ti = 100 ÷ 200 = 0.5, so the stored term moves 0.5 counts per second for every count of error.

Windup during saturation: 0.5 × 500 counts × 300 s = 75,000 counts stored, which is 7.5 times the whole output span and 12.5 times the 6000-count limit.

Release at the small error: -4 °C is -40 counts, so the accumulator sheds 0.5 × 40 = 20 counts per second. Time for the stored value to fall from 75,000 to the 6000-count limit: 69,000 ÷ 20 = 3450 s, about 58 minutes — for the first tens of minutes the displayed output does not move at all, which is what the reported test saw.

Release at the large error: -59 °C is -590 counts, so the rate is 0.5 × 590 = 295 counts per second and 69,000 ÷ 295 ≈ 234 s, under 4 minutes; the large error visibly releases the output, the small one does not.

The climb back afterward is not a mystery either: on a near-pure integrator, closing the steam valve lets PV fall slowly, the error shrinks toward zero, the unwind rate falls with it, and the output turns around.

Treat the arithmetic as sizing, not as the block's certified internal law — the internal form of this block is not documented in the material at hand. Measure your own unwind rate on a bench PV and compare. If the measured rate is near zero while the block executes every scan with the error reversed, stop tuning and replace the block.

How do you characterize the block before it runs the steam valve again? #

Put the PID on a bench or an isolated controller and drive the PV by hand until you have watched a saturation and release cycle — never characterize on the live batch, where a pinned output holds steam on the vessel with no proof of how the block will let go.

Five steps, one change at a time:

  1. Log the boundary at every update: PV, setpoint, the block's numeric output, its configured limits, and the value that reaches %Q0.1. When the block output and the valve command disagree, the fault is downstream of the calculation and no conclusion about the PID is valid yet.
  2. Confirm the execution cadence before believing any rate. Hold PV and setpoint steady, time the output updates, and compare against the configured loop update time. A PID sitting inside conditional logic, a jump, or a step that is sometimes false skips scans, and every integral number you calculated is wrong; give the block a rung that is true every scan.
  3. Establish an unsaturated baseline. Hold PV and setpoint so the output sits mid-scale, change one input at a time, and confirm each output step in direction and size.
  4. Reproduce the saturation deliberately. Apply a fixed error that drives the output to its limit, record the time in, then reverse the error in controlled steps and log the output at every update.
  5. Test one intervention at a time. A parameter edit alone on one run, a controller power cycle alone on another — the reported case combined its changes, which is why nobody could say which action mattered.

Reading the result: an output that leaves the limit smoothly under a reversed error at roughly the rate the arithmetic predicts means the block integrates without a documented clamp but does release, and it can stay in service with honest limits. An output that stays pinned with a healthy cadence and a reversed error means the block does not belong on this loop.

When should you hand-roll the PI instead of trusting the native block? #

Hand-roll the PI when the loop can sit at a limit for hundreds of seconds: for this steam batch, a ladder PI with conditional integration — no accumulator updates while the output is clamped — is the decision, and the native block stays only if the bench test proves it releases.

A hand-rolled PI is a rung or two of math you can read: error in one consistent scale, an accumulator that pauses while the output is clamped or is back-calculated toward the clamped output, a Ti matched to the process, and limits at what the valve can actually do. When you write it, copy a documented pattern rather than inventing one: the integral accumulator and its anti-windup rules for the Logix5000 PID are laid out in this guide to the Logix5000 PID integral accumulator's anti-windup behavior, and your ladder accumulator should behave the same documented way.

The decision for each case:

What the bench shows Decision
Ti = 0 in the configuration Remove it and re-baseline; never use it to switch integral action off
Pinned with Kp = 0, block executing, error reversed Stored integral: unwind it with a large controlled error or clear the state; the gain edit is not a reset
Release at roughly the arithmetic rate Native block stays: Ti above 0, limits at the valve's usable range, re-verify on the bench after every tuning change
Pinned with healthy cadence and reversed error Replace it with the hand-rolled PI with conditional integration

One safety note belongs beside that table: an independent high-temperature or high-pressure cutout outside this control loop stays on the vessel no matter which PID wins, because a saturated steam command holding the valve open is a process excursion no tuning fix should be asked to cover.

Run the bench first, then commit: prove the block or hand-roll the PI. Those are the two outcomes, and both beat another batch on a pinned steam valve.

Questions asked

Does a controller power cycle clear the saturated M221 PID output?

Power-cycling clears volatile run-time state, but the retained behavior of this block's integral is not something to assume: run it as a bench test instead. Hold the PV steady, cycle power, and log the first updates. If the output leaves the limit after restart and returns only as the loop integrates again, you had stored state; if it pins again immediately, look at execution cadence and input scaling instead.

What output limits should a steam-heated batch loop use?

Set the high limit to what the valve and batch actually need, which in the reported case was the 60% mark, and the low limit at 0, then confirm the valve fully closes at the low end. Limits bound the displayed command, not the integration: on a block without documented anti-windup, internal state can keep growing behind a clamped output, which is why the independent high-temperature cutout stays.

Is Ti = 0 ever the right setting on the M221 PID?

Only when you deliberately want the documented positional algorithm with its fixed output offset, which on a heating loop is almost never: the bias sits in the command before your scaling, and everything downstream inherits it. Keep Ti above 0; to make integral action negligible, enter a Ti so long that the integral barely moves over one batch, then prove the residual drift on a bench PV.

How do you catch a PID that is not executing at its configured update time?

Step the setpoint while the loop is isolated and log the block output against scan time: the interval between output changes is the real update period, and it should match the configured loop time. Conditional logic around the block, such as a jump, an IF, or a sequencer step that is sometimes false, silently skips updates. Move the PID to a rung that is true every scan and repeat the measurement before trusting any tuning.

Keep reading

  • Troubleshooting

    Why a CODESYS TON output stays on after its rung goes false

    A false EN does not reset a CODESYS TON — it stops the block from executing at all, so Q holds the value from the last executed call. Route the process condition to IN, keep the enable permanently true, and the timer resets itself the way the standard intends.

    PLC programming

  • How-to

    Scaling a PLC-5 FLEX analog output from PID 0-4095 to 0-30840

    A PLC-5 PID drives its control variable from 0 to 4095, while a FLEX analog output channel configured for the current loop expects output data from 0 to 30840, so a raw CV gives 6.125 mA at 100 percent. Leave the PID limits at 0 and 100 percent, scale the control variable times 30840 divided by 4095 into a separate integer word, and point the BTW at that word. The CV word and the BTW data word must be different addresses.

    PLC programming

  • How-to

    Connect a TON output to a function block input in TwinCAT ladder

    In TwinCAT ladder, the rung's power flow always lands on a block's first input, so with NT_GetTime it lands on NETID instead of START. Right-click the rung and choose Box with EN to create an enable path, then right-click the short line before START and use Insert at Block... to place a box there, replacing the default AND with TON by typing the name or using Input Assistant with F2.

    PLC programming