Process (output instruction)

PID: Proportional Integral Derivative

Closed-loop proportional, integral and derivative control on an analog process value.

Also called: PID loop, closed loop control, process controller.

PID(number, pv, sp, kp, ki, kd, min, max, db, ff, manTag, man)

Arguments

NameWhat it isAcceptsDefault
destinationWhat the instruction acts ona registerrequired
pvMeasured value (PV)a tagnone
spSetpoint (SP)a number or a tag50
kpKpa number1
kiKia number0
kdKda number0
minOut mina number0
maxOut maxa number100
dbDeadbanda number0
ffFeed-forwarda number or a tag0
manTagManual mode bita tagnone
manManual outputa number or a tag0

Arguments are positional and this table is generated from the simulator's own instruction registry, so it always matches what the engine accepts.

What it does

Everything else on this reference is on or off. PID is the instruction for the things that are not: a temperature, a pressure, a flow, a level. It compares where the process is against where it should be and works out how hard to drive the valve, the heater or the drive to close the gap.

The three terms answer three different questions. Proportional asks how far off are we now, and acting on it alone always leaves a steady offset, because as the error shrinks so does the correction. Integral asks how long have we been off, and it is what finally removes that offset. Derivative asks how fast is it moving, and it damps the approach so the process does not overshoot.

Tune in that order and start with proportional only. Raise the gain until the process responds briskly and just begins to oscillate, back it off, then add enough integral to walk out the remaining offset. Most loops never need derivative at all, and on a noisy measurement it does more harm than good.

This implementation is the positional form. The integral term is clamped to the output range so it cannot wind up while the output is already saturated, and the derivative acts on the measurement rather than the error, so a step change in setpoint does not kick the output. There is a deadband to ignore small errors, a feed-forward input added straight to the output, and a manual mode bit whose manual value the integrator tracks, so switching back to automatic is bumpless. A false rung resets the integrator and parks the output at its minimum.

A rung you can run

A loop with a plant to control

RUNG 1Loop_EnablePID Heater_OutputPIDRUNG 2Loop_EnablePROC Tank_TempPROC Heater_O…RUNG 3Tank_Temp> 75High_Temp_Alarm
XIC(Loop_Enable)PID(Heater_Output,Tank_Temp,60,4,0.5,0,0,100)
XIC(Loop_Enable)PROC(Tank_Temp,Heater_Output,1,0.3,20)
GRT(Tank_Temp,75)OTE(High_Temp_Alarm)

The first rung is the controller and the second is a simulated tank for it to act on, so the loop is closed and it will actually settle. Turn on Loop_Enable and watch Tank_Temp climb from 20 towards the setpoint of 60 while Heater_Output backs off as it arrives. Then change the gain of 4 to 20 and run it again to see the same loop overshoot and hunt.

Run this rung in the simulator

What it is called on other controllers

PlatformEquivalent
Rockwell (Studio 5000)PID, or PIDE in the process library
Siemens (TIA Portal)PID_Compact
Mitsubishi (GX Works)PID
CODESYS and IEC 61131-3PID, from the utility library

Common mistakes

  • Starting with all three terms set. A loop with integral and derivative in from the beginning is almost impossible to reason about when it misbehaves. Proportional first, alone, and add the others one at a time.
  • Too much integral. It is the term that hides its damage: the loop looks fine in steady state and then overshoots badly after any disturbance, because the integrator spent the whole excursion accumulating. If a loop cycles slowly and endlessly, suspect integral before anything else.
  • Leaving derivative on a noisy signal. Derivative acts on rate of change, and noise is nothing but rate of change, so it turns a slightly jumpy measurement into a violently jumpy output.

Practise it

Interactive exercises that use PID. Each one checks your ladder against a real scan.

Related instructions

All ladder logic instructions