FB_BA_PIDCtrl

Universal PID controller

FB_BA_PIDCtrl 1:

Functional description

This FB is a standard controller with a parallel PID-struchture. If a controller with a selectable structure is needed (either PID in parallel or with a prepositioned P-Part) please use the  FB_BA_PIDCtrlEx.

Diagram

FB_BA_PIDCtrl 2:

Passive behaviour (bEn = FALSE or bErr = TRUE)

The outputs are set as follows:

lrY

0.0

lrE

0.0

bAct

FALSE

bARW

FALSE

bMinLim

FALSE

bMaxLim

FALSE

bIncLim

FALSE

bDecLim

FALSE

In the event of an error, bErr is TRUE; udiErrId and udiErrArg describe the error. The internal values for the P-, I-, and D-components are set to 0, also the values for the I- and D-components of the preceding cycle. This ensures that the control value is "clean" in the first cycle after a restart, i.e. it is calculated without historical values.

Active behaviour (bEn = TRUE and bErr = FALSE)

In the first cycle, the I and D components are calculated "clean", i.e. without historical values, as already mentioned. A positive signal on bSync sets the I component so that the control value assumes the value lrSync. If bEn and bSync are set at the same time, this method can be used to set an initial value from which the controller "sets off". If the I component is not active, the D component is set accordingly. Note that only the rising edge of bSync is evaluated internally as this is a setting action. A TRUE signal must be applied again to the input bSync for renewed synchronization, for instance with a transfer value. If the I component is active, the controller ensures that it is retained, if the controller output lrY is at the limits lrYMin or lrYMax and about to fall or increase further. This procedure is referred to as Anti-Reset-Wind-Up. It ensures that the I component is always only just sufficiently large to enable the control value to assume values within the limit immediately after a control deviation, without having to deal with an integral component that has become too large.

Direction of action

Direction of action

bActn = FALSE can be used to reverse the direction of action such that a control deviation of less than 0 results in a change in control value to positive. This is achieved by a negative calculation of the control deviation:

bActn

rXW (control deviation)

Direction of action

TRUE

lrX-lrW (actual value-set value)

direct (cooling)

FALSE

lrW-lrX (set value-actual value)

indirect (heating)

Anti-Reset-Windup when the maximum or minimum value is reached

If the controller reaches its upper limit at the output and the control deviation is still positive, the integral component will continue to increase, until the control deviation is less than or equal to zero again. This may lead to an unnecessarily large integral component, which would have to be reduced again, if the sign of the control deviation changes and would make the control behavior sluggish. The same applies if the minimum values is reached at the output, while the control deviation is still negative. To prevent this, the I component is not recalculated when one of these two cases occurs, but it is held at the value of the preceding PLC cycle. If a sign inversion occurs, i.e. if the maximum value is reached and the control deviation is less than 0.0 or the minimum value is reached and the control deviation is greater than 0.0, the I-component is calculated again.

Slope limitation

If the controller is set faster than the actuator, it is unable to follow the controller, which can lead to jitter. It is therefore possible to limit the slope of the control value.

It is based on the following parameters:

udiMinToMax: Slope limitation of controller output for increase: udiMinToMax [s] in relation to a change from lrYMin to lrYMax.

udiMaxToMin: Slope limitation of controller output for decrease: udiMaxToMin [s] in relation to a change from lrYMax to lrYMin.

This can be used to calculate the maximum change per PLC cycle (maximum increment or decrement). If the calculated change in the control signal over a PLC cycle is now higher than the change set by udiMinToMax or udiMaxToMin, the control signal is only increased or decreased by the maximum increment or decrement. Internally, the I-component is automatically adjusted in the same way (I-component of last PLC cycle + maximum increment or I-component of the last PLC cycle - maximum decrement).

Neutral zone (deadband)

A value of lrNZ > 0.0 enables the neutral zone function. If lrNZ is 0 the deadband-part is deactivated and the values at its input are put through.
If the deadband is activated, the value at the input will only be put through as a new ouput-value if the difference between input-value and current output-value is greater or equal to lrNZ/2.

Example: lrNZ = 1, lrYin = 55.0, lrYout= 55.0 (the input-value was just put through)

PLC-Cycle+1

lrYin=55.2

lrYout=55.0

PLC-Cycle+2

lrYin=55.3

lrYout=55.0

PLC-Cycle+3

lrYin=55.1

lrYout=55.0

PLC-Cycle+4

lrYin=55.6

lrYout=55.6

PLC-Cycle+5

lrYin=55.4

lrYout=55.6

PLC-Cycle+6

lrYin=55.3

lrYout=55.6

PLC-Cycle+7

lrYin=55.1

lrYout=55.1

This function is intended to avoid an unnecessarily large number of actuating pulses.

On-off control behaviour

- removed -

Autocorrection of parameters

For parameters it makes sense to correct or limit them automatically, without issuing an error message, since the user expectation is clear:

Inputs/outputs

VAR_INPUT

bEn         : BOOL;
bActn       : BOOL;
bSync       : BOOL;
lrSync      : LREAL;
lrW         : LREAL;
lrX         : LREAL;
lrNZ        : LREAL;
lrYMin      : LREAL;
lrYMax      : LREAL;
lrKp        : LREAL;
udiTn       : UDINT;
udiTv       : UDINT;
udiTd       : UDINT;
udiMinToMax : UDINT;
udiMaxToMin : UDINT;
uiCycCl     : UINT;

bEn: controller activation

bActn: control direction of the controller

bSync / lrSync: synchronization command: set output value lrY to lrSync

lrW: setpoint

lrX: actual value

lrNZ: neutral zone

lrYMin: lower controller output limit

lrYMax: upper limit of the working range of the controller

lrKp: controller amplification. Only affects the P component

udiTn: integral action time of the I component [ms]. A zero value at this parameter disables the I component.

udiTv: integral action time of the D component [ms]. A zero value at this parameter disables the D component.

udiTd: damping time of the D component [ms]

udiMinToMax: slope limit of controller output for increase: udiMinToMax [s] related to a change from lrYMin to lrYMax.

udiMaxToMin: slope limit of controller output for decrease: udiMaxToMin [s] related to a change from lrYMax to lrYMin.

uiCycCl: call cycle of the function block as a multiple of the cycle time. A zero entry is automatically interpreted as uiCycleCall =1.
Example: tTaskCycleTime = 20 ms, uiCtrlCycleCall =10 -> The control algorithm is called every 200 ms. Thus the outputs are also updated only every 200 ms.

VAR_OUTPUT

lrY        : LREAL;
lrE        : LREAL;
bAct       : BOOL;
b2PtAct    : BOOL;
bARW       : BOOL;
bMinLim    : BOOL;
bMaxLim    : BOOL;
bDecLim    : BOOL;
bIncLim    : BOOL;
bErr       : BOOL;
udiErrId   : UDINT;
udiErrArg  : UDINT;

lrY: control value. Range limited by lrYMin and lrYMax.

lrE: control deviation (calculation dependent on control direction)

bAct: the controller is active, i.e. enabled (bEn = TRUE) and not in the error state (bErr = FALSE).

bARW: Anti-Reset-Windup function is active

b2PtAct: is no longer required.

bMaxLim: the control value has reached its upper limit value.

bMinLim: the control value has reached its lower limit value.

bDecLim: the control value slope has reached its limit value for the maximum decrease, see udiMaxToMin (VAR_INPUT).

bIncLim : the control value slope has reached its limit value for the maximum increase, see udiMinToMax (VAR_INPUT).

bErr: this output is switched to TRUE if the parameters entered are erroneous.

udiErrId / udiErrArg: contains the error number and the error argument. See error codes.

Requirements

Development environment

Target system

required library

required supplement

TwinCAT 2.11 R3/x64

PC/CX

TcBA library from V1.0.0

TS8040 | TwinCAT Building Automation from V1.0.0