PLC PID Tuning Complete Guide: Kp, Ki, Kd for Real Industrial Loops
PID tuning for PLCs from first principles. Ziegler-Nichols, Cohen-Coon, and the practical trial-and-error method that actually ships. With worked examples and common anti-patterns.
Every industrial automation engineer learns PID the same way: read two paragraphs of theory, stare at a Bode plot for five minutes, then get handed a misbehaving loop at 2 AM during commissioning and told to make the overshoot go away. This guide is for that engineer.
We'll cover what each term actually does in a PLC context, the three tuning methods worth knowing, how to implement anti-windup, and the eight anti-patterns that turn a simple loop into a process-shutdown nightmare. All examples work in TIA Portal's PID_Compact, Studio 5000's PIDE, and pure IEC 61131-3 — and each is runnable in a browser simulator if you want to practise tuning without risking a $500k batch.
Table of Contents
- What PID Actually Does
- The Three Terms in Plain English
- PID in PLC Function Blocks
- Method 1: Trial and Error (the honest one)
- Method 2: Ziegler-Nichols
- Method 3: Cohen-Coon
- Anti-Windup: the Thing Everyone Forgets
- Common Tuning Anti-Patterns
- Process-Specific Guidelines
- From Simulation to Real Hardware
What PID Actually Does
A PID controller takes the error — the difference between the setpoint (what you want) and the process variable (what you're measuring) — and uses it to compute the manipulated variable (what the PLC tells the valve, the drive, or the heater to do).
In plain arithmetic:
output = Kp * error + Ki * ∫error·dt + Kd * d(error)/dt
That's it. Three terms summed together. Kp scales the current error, Ki integrates the history of the error, Kd looks at how quickly the error is changing. Everything else — tuning methods, anti-windup, cascade loops — is elaborations on those three terms.
The Three Terms in Plain English
Proportional (Kp) answers "how big is the error right now?" If the temperature is 10 °C below setpoint and Kp is 2, the proportional contribution is 20 units of heater output. Double Kp, double the response. Kp alone will get you close to setpoint quickly but leaves a persistent offset (steady-state error).
Integral (Ki) answers "how long have we been off?" If you're 1 °C below setpoint for 60 seconds, the integral accumulates 60 °C-seconds of error and ramps the output up until the offset vanishes. Integral is what eliminates steady-state error; too much integral causes overshoot and oscillation.
Derivative (Kd) answers "how fast is the error changing?" It brakes aggressive moves. If the temperature is climbing fast toward setpoint, derivative subtracts from the output before the process overshoots. Derivative is useful on slow, well-behaved processes (temperature, level) and dangerous on noisy ones (flow, pressure) — it amplifies measurement noise and will make your actuator chatter.
The ugly truth: most industrial loops run PI only, with Kd set to zero. PI handles 80 % of real loops. Add D only when you know the process is slow and the measurement is clean.
PID in PLC Function Blocks
Every major PLC platform ships a tuned PID function block. The semantics differ slightly — know your platform.
Siemens TIA Portal — PID_Compact (S7-1200/1500):
- Gain (
Gain) is what most of the world calls Kp. - Integral time (
Ti) is expressed in seconds — period, not gain. Larger Ti → less integral action. Ki equivalent = Gain / Ti. - Derivative time (
Td) also in seconds. Kd equivalent = Gain × Td. - Built-in auto-tuning via the
Stateparameter. Commissioning-mode tuning is good for most loops; fine-tune manually after.
Rockwell Studio 5000 — PIDE (ControlLogix):
- Proportional gain (
PGain), integral gain (IGain), derivative gain (DGain). Gains, not times — so units align with the math above. - Autotune built in via
AutotuneFB. Runs a step test and computes initial gains. - Set
ManualModeto 1 when commissioning; bump ControlVariable manually while watching the response, then tune.
Pure IEC 61131-3 (Codesys, Beckhoff TwinCAT, OpenPLC):
- Function block naming varies by library —
PID,FB_CTRL_PID,PID_FB. Check your library. - All expose some combination of Kp, Ki/Ti, Kd/Td plus output limits and anti-windup.
Regardless of block, the work is the same: set reasonable limits, disable Kd initially, tune Kp until overshoot is acceptable, add Ki slowly until steady-state error closes.
Method 1: Trial and Error (the honest one)
This is how 80 % of loops are actually tuned in the field.
- Set Kp to a small value, Ki and Kd to zero. Start conservative. For a temperature loop, Kp = 1 is a fine starting point.
- Bump the setpoint by 10 % of operating range. Watch the process variable.
- If the response is too slow, double Kp. Bump again.
- Keep doubling Kp until you see oscillation — the process variable starts overshooting and swinging around setpoint.
- Back Kp off to about half that value. This is your working proportional gain.
- Add Ki = Kp / (process time constant) as a starting point. For a temperature process with a 60-second time constant, start with Ki = Kp / 60.
- Observe. Steady-state error should close within about three time constants. If it closes too slowly, increase Ki. If the response develops a new oscillation around setpoint, decrease Ki.
- Add Kd only if overshoot remains excessive and the measurement is clean. Start Kd = Kp / 10 × time constant. Increase cautiously. If the output chatters, Kd is too high or the measurement is too noisy — back off.
The total exercise takes 30 minutes on a well-behaved loop, longer on a slow process like a 5,000-litre reactor that takes 20 minutes to respond to any input. Budget accordingly.
Method 2: Ziegler-Nichols
The textbook method. Reasonable starting point for processes you don't know well.
Ultimate gain method:
- Set Ki and Kd to zero.
- Increase Kp until the process oscillates with sustained, non-decaying oscillations at the setpoint. Call this gain
Ku(ultimate gain). - Measure the period of oscillation. Call it
Pu. - Apply the Ziegler-Nichols gains:
| Controller | Kp | Ki | Kd |
|---|---|---|---|
| P only | 0.5 × Ku | — | — |
| PI | 0.45 × Ku | 1.2 × Kp / Pu | — |
| PID | 0.6 × Ku | 2 × Kp / Pu | Kp × Pu / 8 |
Ziegler-Nichols was derived for fast-responding processes in the 1940s. It typically produces aggressive tuning with significant overshoot — often 25 % overshoot on a step response. That's fine for a lab demo, problematic in production where overshoot on a temperature loop might trip a high-temperature alarm or scorch a product batch.
Treat Z-N as a starting point. After applying the numbers, back Kp off by 20–30 % and reduce Ki similarly for anything where overshoot matters.
Method 3: Cohen-Coon
Better than Ziegler-Nichols for processes with significant dead time — think long pipes, large tanks, slow heat transfer.
- Put the loop in manual mode.
- Step the output by ~10 % and record the response.
- From the response curve, measure:
- Dead time (L) — time between step and first process variable movement.
- Time constant (T) — time from first movement to 63 % of the final value.
- Process gain (K) — (final PV change) / (output step).
- Apply Cohen-Coon gains:
| Controller | Kp | Ki | Kd |
|---|---|---|---|
| PI | (T / (K·L)) × (0.9 + L/(12T)) | Kp × (L × (30 + 3L/T)) / (9 + 20L/T) | — |
| PID | (T / (K·L)) × (4/3 + L/(4T)) | Kp × (L × (32 + 6L/T)) / (13 + 8L/T) | Kp × (4L / (11 + 2L/T)) |
Cohen-Coon works better than Z-N on processes where dead time is more than 10 % of the total response time. On fast, responsive loops (flow, pressure) it offers no advantage and is harder to apply than trial and error.
Anti-Windup: the Thing Everyone Forgets
Integral windup is the single most common PID failure mode in industrial code. Here's how it happens:
- The process is stuck — maybe a valve is fully open but the flow won't reach setpoint because upstream pressure is low.
- The integral term keeps accumulating error because the error won't go away.
- The internal integrator grows to enormous values — far beyond what the actuator can physically deliver.
- Conditions change, the process starts moving, the output should come down — but the accumulated integral is so large the PID output stays saturated for minutes.
- Operators watch the process overshoot catastrophically while the loop "unwinds" its integrator.
Fixes:
1. Clamp the integrator directly. When the output hits its upper or lower limit, freeze the integrator. Siemens PID_Compact and Studio 5000 PIDE both do this automatically — but only if you set the output limits correctly in the function block.
2. Back-calculation anti-windup. More sophisticated — the integrator is driven back by the difference between the commanded output and the saturated output. Better for fast processes; overkill for most plants.
3. Conditional integration. Integrator runs only when the output is not saturated. Simple and effective; almost all commercial PID blocks support it as an option.
Always set your output limits (OutMax, OutMin) to physically achievable values. Don't leave them at ±100 % if the actuator range is 0–100. Anti-windup cannot protect you if the limits are wrong.
Common Tuning Anti-Patterns
Seen too many times to count:
- Copying tuning gains between loops. "This loop tunes at Kp=2.5, let me try that on the next one." Gains are dimensional — they depend on engineering-unit scaling, actuator range, and process dynamics. Never copy; always re-tune.
- Turning off integral to "stabilise" a loop. A persistent oscillation is not fixed by removing integral. It means Kp is too high or the process has changed. Removing integral just gives you steady-state error plus the oscillation.
- Using derivative on flow. Flow measurements are inherently noisy. Derivative amplifies noise and makes valves chatter, wearing out actuators in months. Kd = 0 on flow, always.
- Manual mode forever. A loop in manual mode for six months is not a loop. Commission properly or accept that the operator is the control system.
- Tuning at the wrong operating point. A valve with a linear characteristic at 50 % open has a non-linear characteristic at 90 % open. Tune at your normal operating range, not on a bench.
- Cascade loops that aren't synchronised. Outer loop update rate should be slower than inner loop settling time — typically outer is 3–5× slower. Otherwise the outer loop confuses the inner loop and both oscillate.
- Letting the PID drive outside physical limits. A PID output of 110 % means nothing to a valve that opens to 100. Clamp at the function block; don't rely on downstream logic.
- Forgetting to disable PID during startup. Many processes need a specific startup sequence (pre-heat, pre-fill, flush) before PID control takes over. Starting PID from zero setpoint on a cold process often produces a wild first response. Use bumpless transfer from manual to auto.
Process-Specific Guidelines
Rough starting points when you're staring at an unfamiliar loop:
| Process type | Typical Kp | Typical Ti (sec) | Typical Td | Notes |
|---|---|---|---|---|
| Flow | 0.1–1 | 0.5–5 | 0 | Noisy; PI only; fast response |
| Pressure (gas) | 0.5–3 | 5–30 | 0 | PI usually enough |
| Pressure (liquid) | 1–5 | 10–60 | 0 | Often PI with slow Ki |
| Temperature (fast) | 1–5 | 30–300 | 0–30 | PID often justified |
| Temperature (slow, large vessel) | 2–10 | 300–1800 | 60–300 | PID with long times |
| Level (linear tank) | 1–3 | 60–600 | 0 | PI; avoid Kd |
| Level (conical tank) | 0.5–2 | 300–1800 | 0 | Non-linear — consider gain scheduling |
| pH | 0.1–1 | 60–600 | 0 | Non-linear near setpoint; requires care |
These are order-of-magnitude starting points, not recipes. Every real process deviates. Budget tuning time accordingly.
From Simulation to Real Hardware
Tuning in a simulator is safe, fast, and (critically) consequence-free. Real hardware is none of those. Three things change when you move from sim to plant:
- Process noise. Real signals have noise. Your simulator's clean temperature reading becomes a 0.2 °C jitter on a real thermocouple, and your clean Kd = 1 becomes actuator chatter on real hardware.
- Actuator dynamics. A simulated valve that moves instantly from 0 % to 100 % is a real valve with 5 seconds of stroke time and 2 seconds of backlash. Tuning that worked in sim often looks sluggish on real hardware.
- Coupled loops. Plants have cross-coupling. Changing the flow setpoint moves pressure, which moves the level in the downstream tank, which moves the next flow. Tune loops in the order they cascade: innermost first, each time putting the outer loop in manual while you work.
Use a simulator to develop the intuition — what does higher Kp feel like, what does too-fast Ki look like. Use real commissioning time to close the gap between sim and plant.
Key Takeaways
- PI covers 80 % of real loops. Default Kd to zero until you're sure the process is slow and the measurement is clean.
- Trial and error is a legitimate, widely-used tuning method. Don't be embarrassed to use it.
- Ziegler-Nichols is aggressive; back its suggested gains off by 20–30 % for production work.
- Anti-windup is non-negotiable. Every PID function block needs correct output limits and windup protection enabled.
- Know your function block:
PID_Compact(Siemens),PIDE(Rockwell), or the IEC equivalent in Codesys/TwinCAT. - Tune at the real operating point with real process dynamics, not on a bench or at startup.
Related Reading
- Temperature control PLC programming guide
- Pump control PLC programming guide
- VFD programming PLC control guide
- PLC programming best practices
Once theory lands, tune a loop yourself in the browser — the feedback from changing Kp and watching the curve respond is worth more than ten blog posts.


