PID Control with PLCs

PID Control with PLCs: Commissioning the Complete Loop, Not Just the PID Block
A PID instruction can be dropped into a PLC program in a few minutes. That does not mean the control loop is ready to run.
Before tuning begins, the PLC must receive a trustworthy process measurement, convert it into the correct engineering units, execute the controller at a suitable and repeatable interval, limit the output correctly and deliver that output to a valve, VFD or other actuator that actually responds as expected.
A practical PLC control loop therefore looks more like this:
Sensor → Input module → Scaling → PID controller → Output or network command → Actuator → Process → Sensor
If any part of this chain is wrong, changing Kp, Ki or Kd may only hide the real fault.
For the wider hardware side of the system, see our PLC and I/O section.
Start with SP, PV and CV
Most PLC PID blocks revolve around three basic values.
SP — Setpoint: the process value you want.
PV — Process Variable: the process value you actually measure.
CV or MV — Control / Manipulated Variable: the output used to influence the process.
In a pressure-control application, for example:
SP = 6 bar
PV = measured discharge pressure
CV = pump-speed reference
The PLC compares SP and PV and changes the output to reduce the control error.
The mathematics are important, but commissioning normally fails first at the interfaces around the mathematics.
A 4–20 mA input is not automatically a pressure value
Suppose a pressure transmitter measures 0–10 bar and produces a 4–20 mA signal.
4 mA = 0 bar
20 mA = 10 bar
The PLC input card converts that current into a raw digital value. The program then has to convert the raw value into bar before it is useful as a process variable.
This scaling stage is easy to underestimate.
If the actual process is at 6 bar but the PLC scaling reports 5.2 bar, the PID controller sees a false error and increases its output. The controller may be mathematically correct while the machine behaviour is completely wrong.
Verify the instrument, wiring, input channel and engineering scaling before tuning the loop.
The signal side is explained further in industrial analog signals and 0–10 V / 4–20 mA signals.
The PID instruction needs a real time base
Integral and derivative action depend on time. A PLC PID instruction should therefore not be treated like ordinary logic that can be executed at unpredictable intervals without consequence.
Many controller families provide a periodic task, cyclic interrupt or similar mechanism for this reason.
The correct update interval depends on the physical process. A large oven may require a relatively slow control cycle. Pressure or flow control may need a faster one. A high-speed tension or motion application may be faster again.
The fastest possible task is not automatically the best PID task.
The controller period should be chosen in relation to sensor response, process dynamics, actuator response and the capabilities of the PLC.
See time delay and process dynamics in PID control for the wider control-theory side.
PLC scan time and PID update time are not necessarily the same thing
A PLC may scan normal machine logic every few milliseconds while a temperature controller only needs to calculate a new output much less frequently.
The same controller can therefore contain tasks with very different timing requirements.
For example:
machine interlocks may require fast regular execution,
communications may run separately,
temperature PID may be relatively slow,
pressure PID may require a shorter interval.
The program structure should reflect the physical process rather than forcing every function into the same timing model.
The analog input must also update fast enough
There is little value in executing a PID calculation every 100 ms if the process value reaching the CPU only changes every 500 ms.
The controller would repeatedly calculate with old information.
For a complete loop, consider:
sensor response → input-module update → digital filtering → PID execution → output update → actuator response → process delay.
Heavy filtering can make a noisy PV look attractive on the HMI while quietly adding enough delay to damage control performance.
This is one reason commissioning should use the actual signal path rather than only the PID block display.
Control direction must be proven before Auto mode
The controller must know whether increasing its output drives the process variable up or down.
For a heater, more output normally raises temperature.
For cooling, more output may lower temperature.
A valve can also behave differently depending on whether it controls supply, return, bypass or relief flow.
If the control action is reversed incorrectly, the PID controller amplifies the error instead of correcting it.
A small manual output test is often the safest way to establish process direction before enabling automatic control.
Not every PLC uses the same PID equation
This is one of the most important details when moving between PLC brands.
One block may use:
Kp, Ki and Kd
while another may use:
Kp, Ti and Td.
Those parameter sets should not be treated as interchangeable numbers.
Controllers may also support different equation forms, such as independent and dependent gain structures. Some allow the derivative term to act on the error; others can apply derivative action to the process variable to reduce the effect of a setpoint step.
Never copy PID numbers from one PLC family into another controller until the equation, units and parameter definitions have been checked.
Our PID gain and tuning page covers the general effect of these adjustments.
P, I and D are only useful when you know what the block means by them
Proportional action reacts to the present error. Increasing proportional action can tighten the response, but excessive gain can create oscillation or instability.
Integral action responds to error that remains over time and is commonly used to remove steady-state offset.
Derivative action responds to rate of change and can provide damping in appropriate processes. It is also sensitive to noisy measurements.
Derivative action should not be described simply as “predicting the future”. Its practical behaviour depends on the algorithm and on whether it is applied to error or process measurement.
For the fundamentals, see the P, I and D components of PID control.
Every physical actuator has limits
The PLC may calculate whatever value the equation produces, but the real machine cannot deliver unlimited output.
A control valve normally operates inside a defined travel range.
A heater cannot provide more than its installed power.
A VFD may be restricted to a minimum and maximum permitted frequency.
Therefore the PID output limits should correspond to the usable range of the process equipment.
Consider a pump that must not operate below a certain frequency. A PID output of 0% cannot automatically be interpreted as 0 Hz if the machine logic requires a higher minimum running speed.
PID output scaling and machine operating limits are related, but they are not the same configuration.
Output saturation can create integral windup
Imagine that a pump is already at maximum speed but pressure remains below the setpoint.
The controller cannot increase the physical output any further.
If integral action continues to accumulate the remaining error, the internal integral term can become very large. When process conditions later improve, the controller may stay at an unnecessarily high output for too long.
This is integral windup.
Depending on the PLC family, the PID function may provide output limiting, integral hold, tracking or other anti-windup behaviour.
These features should be understood before a loop is commissioned, especially when saturation is common during startup or load changes.
Manual mode is a commissioning tool, not just an operator feature
Before automatic control is enabled, manual mode can answer several important questions.
Command the pump to a modest speed or move a valve to a controlled position and check:
Does the actuator respond?
Does PV move in the expected direction?
Does the sensor show approximately the physical process change?
Is the output scaling correct?
If those answers are not known, automatic tuning is premature.
Manual-to-Auto transfer should not create a process kick
Suppose the plant is stable in manual mode at 42% output.
If automatic control is enabled and the internal PID state immediately demands 78%, the output can jump and disturb the process.
Many industrial PID implementations include tracking, initialization or bumpless transfer functions to avoid this behaviour.
The correct method depends on the PLC instruction being used.
Startup deserves the same attention. After a CPU restart, the application should define whether the PID resumes automatically, remains inactive or requires process conditions to be validated first.
Example: constant-pressure control through a PLC and VFD
A common architecture is:
Pressure transmitter → PLC analog input → PID → VFD speed reference → Pump
The transmitter may provide 4–20 mA over a 0–10 bar range.
The PLC scales the input into bar and supplies it to the PID block as PV.
The required pressure becomes the setpoint.
The PID output becomes the motor-speed command.
If pressure falls because process demand increases, the controller increases the pump command. As pressure returns toward the setpoint, the required correction decreases.
The process-specific behaviour is covered in PID pressure control.
The drive-specific alternative is covered in PID control with a VFD.
Should the PID run in the PLC or inside the VFD?
There is no universal answer.
For a simple single-pump pressure system, wiring the transmitter directly to a VFD with built-in process PID may produce a compact and reliable solution.
A PLC becomes more attractive when the application also has to coordinate:
multiple pumps,
standby rotation,
valves,
tank levels,
minimum-flow requirements,
different operating modes,
plant interlocks,
recipe-dependent setpoints.
In that situation the process logic may be easier to understand and maintain when the PID loop is part of the wider PLC control strategy.
The important question is not “Which device is more powerful?” but where the loop can be closed most cleanly and reliably.
Temperature loops should not be treated like pressure loops
A furnace, tank heater or HVAC loop often responds much more slowly than pressure or flow.
For temperature control, the PLC may read a temperature sensor or transmitter and control an SSR, power controller, valve or other heating/cooling device.
A very fast PID task usually offers no benefit when the physical temperature takes many seconds or minutes to change.
The dedicated-controller approach is covered separately in PID control with a temperature controller.
Flow and level may use identical PLC blocks but behave completely differently
Two PID instances can look identical in the PLC project while controlling processes with very different dynamics.
Flow control can respond quickly to a valve or pump-speed change.
Level control in a large tank may respond slowly and often behaves as an integrating process.
Copying tuning constants between those loops simply because the PLC instruction looks the same is not a tuning method.
Auto-tuning should be treated as a controlled test
Many PLC platforms and process controllers offer automatic tuning.
That can be useful for obtaining initial parameters, but the procedure may deliberately disturb the process so that its response can be identified.
Before starting auto-tuning, consider:
process limits,
product quality,
equipment capacity,
machine safety,
what happens if the process does not respond as expected.
Auto-tuning results should also be validated at the actual operating load. A loop identified under one operating condition may not behave identically over the full production range.
Ziegler–Nichols is not a universal commissioning recipe
Classical tuning methods remain useful for understanding control behaviour, but deliberately pushing a real machine toward sustained oscillation is not appropriate for every process.
A high-temperature oven, pressure vessel, chemical process or expensive production line may impose limits that make aggressive tuning tests unacceptable.
Use the method supported by the actual process, controller and manufacturer documentation rather than applying one historical tuning rule to every PLC loop.
SCADA should make the loop visible
A SCADA system can show setpoint, PV, controller output, operating mode, alarms and historical trends.
The fast closed-loop calculation can still remain inside the PLC.
That separation provides a useful architecture:
PLC controls the process locally → SCADA supervises, records and presents the process.
The operator may be permitted to change a setpoint or switch operating mode while the PLC retains responsibility for limits, interlocks and the actual PID execution.
This division of responsibility is explored further in PID control with SCADA.
Trend SP, PV and CV together
A trend is one of the most useful tools when a PID loop “does not look right”.
Where possible, record:
setpoint,
process value,
controller output,
Auto / Manual status,
actual valve position or VFD speed,
important alarms or output limits.
Different patterns tell different stories.
PV oscillates around SP: investigate tuning, process delay and measurement behaviour.
CV stays at 100% but PV never reaches SP: check whether the actuator or process has enough capacity.
CV moves but the process does not: look downstream at the analog output, network command, VFD, valve or mechanical equipment.
PV is noisy while the physical process is stable: inspect the sensor, wiring, shielding and input configuration before changing the controller.
More general symptoms are covered in PID troubleshooting.
A failed sensor is not simply a very low process value
Consider a 4–20 mA transmitter with a broken wire.
If the PLC treats the resulting input as valid “low pressure”, the PID controller may command maximum pump speed.
That is a control-system design error.
The program should distinguish a valid process measurement from:
input-module fault,
underrange or overrange,
broken transmitter wiring,
invalid network data,
stale process information.
The required response depends on the process. The loop may be placed in Manual, the output may be held, a defined fallback may be used, or the process may have to stop.
Fault behaviour should be designed before the first sensor fails.
PID is normal process control, not machine safety
A PLC PID loop may regulate a normal operating pressure of 6 bar. That does not make it the independent protection against dangerous overpressure.
Similarly, a temperature PID may regulate an oven during normal production but should not automatically be considered the only protection against a hazardous overtemperature condition.
Required protective and safety functions must be designed according to the actual machine or process risk.
A standard PID instruction is not, by itself, a safety system.
Several PID loops can share one PLC — but not without engineering
A modern PLC can execute many control loops, but the practical limit is not simply the number of PID blocks the programming software allows.
Also consider:
CPU execution load,
analog I/O update rates,
network traffic,
required task periods,
interaction between process loops.
Twenty slow temperature zones and twenty high-speed loops do not place the same requirements on the controller.
Cascade control is more than putting two PID blocks in series
Some processes benefit from two nested control loops.
For example, an outer temperature controller may generate the setpoint for a faster inner temperature or flow controller.
The inner loop should normally respond substantially faster than the outer loop so that the outer controller sees a predictable secondary process.
Simply connecting the output of one PID block to the setpoint of another does not guarantee useful cascade control. Both loop dynamics and mode transfer have to be considered.
A practical PLC PID commissioning sequence
First: verify the physical instrument and its range.
Second: verify the raw PLC input and engineering scaling.
Third: test the actuator manually at safe outputs.
Fourth: confirm the process moves in the expected direction.
Fifth: define output limits and fault behaviour.
Sixth: choose an appropriate periodic PID execution interval.
Seventh: verify Manual/Auto transfer and startup behaviour.
Eighth: enter suitable initial tuning parameters.
Ninth: trend SP, PV and CV.
Tenth: test the loop under realistic load and disturbances.
Following that order prevents a large number of wiring, scaling and actuator problems from being misdiagnosed as PID tuning problems.
Related PLC and PID Topics
PLC and supervisory control: PLCs and Modules · SCADA Systems · PID with SCADA
Measurement and feedback: Analog Signals · 0–10 V and 4–20 mA · Pressure Sensors · Temperature Sensors
Process PID applications: Pressure Control · Flow Control · Level Control · Temperature Control
Drives and PID: Variable Frequency Drives · PID with VFDs
PID behaviour and tuning: PID Control FAQ · P, I and D Components · PID Tuning · Process Dynamics and Delay · PID Troubleshooting
PLC manufacturers implement PID differently. Equation form, parameter units, derivative action, output limits, task timing, Manual/Auto behaviour, startup handling and tuning functions should always be checked against the documentation for the specific PLC and PID instruction being used.