PIDPLCopen motion icon

Function BlockClosed A function block groups an algorithm and a set of private data. It has inputs and outputs. - PIDClosed "Proportional-Integral-Derivative" A PID controller is a generic control-loop feedback mechanism widely used in industrial control systems. An "error" occurs when an event or a disturbance triggers off a change in the process variable. A PID controller attempts to correct the error between a measured process variable and a desired setpoint by calculating and then outputting a corrective action that can adjust the process accordingly loop

For more details on regulation, see "Regulation".

Inputs

Input Type Description
AUTO BOOL TRUE = normal mode , FALSE = manual mode.
PV REAL Process value.
SP REAL Set point.
Xout_Manu REAL Output value in manual mode.
KP REAL Gain.
TI REAL Integration time factor. A value of zero will stop the integrator and freeze Xout I at the previous sample’s calculated value.
TD REAL Derivation factor.
TS TIME Sampling period.
XMIN REAL Minimum allowed output value.
XMAX REAL Maximum output value.
I_SEL BOOL If FALSE, the integrated value is ignored.
INT_HOLD BOOL If TRUE, the integrated value is frozen.
I_ITL_ON BOOL If TRUE, the integrated value is reset to I_ITLVAL.
I_ITLVAL REAL Reset value for integration when I_ITL_ON is TRUE.
DEADB_ERR REAL Hysteresis on PV. PV will be considered as unchanged if greater than (PVprev - DEADBAND_W) and less that (PRprev + DEADBAND_W).
FFD REAL Disturbance value on output.

Outputs

Output Type Description
Xout REAL Output command value.
ER REAL Last calculated error.
Xout_P REAL Last calculated proportional value.
Xout_I REAL Last calculated integrated value.
Xout_D REAL Last calculated derivated value.
Xout_HLM BOOL TRUE if the output value is saturated to XMIN.
Xout_LLM BOOL TRUE if the output value is saturated to XMAX.

Diagram

Remarks

  • It is important for the stability of the control that the TS sampling period is much bigger than the cycle time.
  • Output of the PID block always starts with zero. The value will vary per the inputs provided upon further cycle executions.
  • The output rung has the same value as the AUTO input, corresponding to the input rung, in the FFLD language.

ST Language

(* MyPID is a declared instance of PID function block *)
MyPID (AUTO, PV, SP, XOUT_MANU, KP, TI, TD, TS, XMIN, XMAX, I_SEL, I_ITL_ON, I_ITLVAL, DEADB_ERR, FFD);
XOUT := MyPID.XOUT;
ER := MyPID.ER;
XOUT_P := MyPID.XOUT_P;
XOUT_I := MyPID.XOUT_I;
XOUT_D := MyPID.XOUT_D;
XOUT_HLM := MyPID.XOUT_HLM;
XOUT_LLM := MyPID.XOUT_LLM;

FBD Language

FFLD Language

(* ENO has the same state as the input rung *)

IL Language

(* MyPID is a declared instance of PID function block *)
Op1: CAL MyPID (AUTO, PV, SP, XOUT_MANU, KP, TI, TD, TS, XMIN, XMAX, I_SEL, I_ITL_ON, I_ITLVAL, DEADB_ERR, FFD)
FFLD  MyPID.XOUT
STClosed "Structured text" A high-level language that is block structured and syntactically resembles Pascal  XOUT
FFLD  MyPID.ER
ST  ER
FFLD  MyPID.XOUT_P
ST  XOUT_P
FFLD  MyPID.XOUT_I
ST  XOUT_I
FFLD  MyPID.XOUT_D
ST  XOUT_D
FFLD  MyPID.XOUT_HLM
ST  XOUT_HLM
FFLD  MyPID.XOUT_LLM
ST  XOUT_LLM