PID

The library util.lib provides the following PID controller function block:

../_images/01325e740a39fceb0a317f345567f415

Unlike the PD controller, this function block contains a further REAL input TN for the readjusting time in sec (e.g. “0.5” for 500 msec).

Inputs of the function block
Variable Data type Description
ACTUAL REAL Current value of the controlled variable
SET_POINT REAL Desired value, command variable
KP REAL Proportionality coefficient, unity gain of the P-part
TN REAL Reset time, reciprocal unity gain of the I-part; given in seconds, e.g. “0.5” for 500 msec
TV REAL Derivative action time, unity gain of the D-part  in seconds, e.g. “0.5” for 500 msec
Y_MANUAL REAL Defines output value Y in case of MANUAL = TRUE
Y_OFFSET REAL Offset for the manipulated variable Y
Y_MIN, Y_MAX REAL Lower resp. upper limit for the manipulated variable Y. If Y exceeds these limits, output LIMITS_ACTIVE will be set to TRUE and Y will be kept within the prescribed range. This control will only work if Y_MIN<Y_MAX.
MANUAL BOOL If TRUE, manual operation will be active, i.e. the manipulated value will be defined by Y_MANUAL.
RESET BOOL TRUE resets the controller; during reinitialization Y = Y_OFFSET.
Outputs of the function block
Variable Data type Description
Y REAL Manipulated value, calculated by the function block (see below)
LIMITS_ACTIVE BOOL TRUE indicates that Y has exceeded the given limits (Y_MIN, Y_MAX).
OVERFLOW BOOL TRUE indicates an overflow (see below)

Y_OFFSET, Y_MIN und Y_MAX serve for transformation of the manipulated variable within a prescribed range.

MANUAL can be used to switch to manual operation; RESET can be used to re-initialize the controller..

In normal operation (MANUAL = RESET = LIMITS_ACTIVE = FALSE) the controller calculates the controller error e as difference from SET_POINT ““ ACTUAL, generates the derivation with respect to time de/dt and stores these values internally.

The output, i.e. the manipulated variable Y unlike the PD controller contains an additional integral part and is calculated as follows:

Y = KP (D + 1/TN òedt + TV dD /dt) + Y_OFFSET

So besides the P-part also the current change of the controller error (D-part) and the history of the controller error (I-part) influence the manipulated variable.

The PID controller can be easily converted to a PI-controller by setting TV=0.

Because of the additional integral part, an overflow can come about by incorrect parameterization of the controller, if the integral of the error D becomes to great. Therefore for the sake of safety a BOOLean output called OVERFLOW is present, which in this case would have the value TRUE. This only will happen if the control system is instable due to incorrect parameterization. At the same time, the controller will be suspended and will only be activated again by re-initialization.