FB_BA_PIDControl

FB_BA_PIDControl 1:

The function block FB_BA_PIDCtrl is a universal PID controller.

The controller is divided internally into two consecutive parts:

Operation mode "Upstream P part":

(eOpMode = E_BA_PIDMode.eP1ID)

FB_BA_PIDControl 2:

"Parallel structure" operation mode:

(eOpMode = E_BA_PIDMode.ePID )

FB_BA_PIDControl 3:

Control direction

With eAction = E_BA_Action.eReverse, the control direction of the controller is reversed so that a control deviation of less than 0 causes a positive change in the control value. This is achieved by a negative calculation of the control deviation:

eAction

fE (control deviation)

Control direction

E_BA_Action.eDirect

fCtrlVal-fSetpoint (actual value-setpoint)

direct (cooling)

E_BA_Action.eReverse

fSetpoint-fCtrlVal (setpoint - actual value)

indirect (heating)

Passive behavior (bEn = FALSE)

The outputs are set as follows:

fPresentValue

0.0

The internal values for the P, I, and D parts are set to 0, also the values for the I and D parts of the preceding cycle. In case of a restart the control value is thus calculated in the first cycle without past values.

Active behavior (bEn = TRUE)

In the first cycle, the I and D parts are calculated without historical values, as already mentioned.

Anti-Reset-Windup

If the I part is active, the controller ensures that it is retained, if the controller output rY is about to move beyond the limits fMinOutput oder fMaxOutput. A preliminary calculation of the controller output takes place inside the controller in every cycle.

Anti-reset windup at min limit

If the precalculation is smaller than the lower output limit fMinOutput, the I part is prevented from falling further and is limited to the value of the last PLC cycle. However, an increase in the I part remains possible.

Anti-reset windup at max limit

On the other hand, if the precalculation is greater than the upper limit fMaxOutput, the I part is prevented from increasing further and is also limited to the value of the last PLC cycle. In this case, a drop in the I part remains possible.

Synchronizations

There are several cases where controller output must not only be limited, but also synchronized to a new value by manipulating the I part (if not active, then the D part or the P part). These cases are prioritized because of the potential for simultaneity:

Prio

Description

Conditions

Comments

1

Synchronization via bEnSync/fValSync

Controller enabled - bEn = TRUE

A positive signal on bEnSync sets the I part so that the control value assumes the value fValSync. If bEn and bEnSync 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 part is not active, the D part is set accordingly. Note that only the rising edge of bEnSync is evaluated internally as this is a Set action. A TRUE signal must be applied again to the input bEnSync for renewed synchronization, for instance with a transfer value.

2

Range synchronization fMinOutput

Controller enabled – bEn = TRUE

fMinOutput <> fMinOutput_1 (lastCycle)

fY_Test < fMinOutput

If the lower range limit has changed and the precalculated controller output is now smaller than fMinOutput then synchronization is performed to fMinOutput.

3

Range synchronization fMaxOutput

Controller enabled – bEn = TRUE

fMaxOutput <> fMaxOutput_1 (lastCycle)

fY_Test > fMaxOutput

If the upper range limit has changed and the precalculated controller output is now greater than fMaxOutput, then synchronization is performed to fMaxOutput

4

Synchronization with reversal of the control direction

Controller enabled – bEn = TRUE

eAction <> eAction_1 (last cycle)

It is synchronized so that the output holds the value BEFORE the reversal:
fPresentValue = fPresentValue_1 (last cycle)

5

Anti-Reset-Windup

Controller enabled – bEn = TRUE

see Anti-Reset-Windup

Neutral zone

A value of fNeutralZone > 0.0 enables the function of the neutral zone (deadband). A value equal to zero deactivates the deadband element and the values at the input are passed directly through.

If, for the active controller, the change at the input of the element in a PLC cycle is smaller than fNeutralZone / 2 in comparison with the previous PLC cycle, then the output is held at the value of the previous cycle until the change is larger than or equal to fNeutralZone / 2.

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

Syntax

VAR_INPUT
  bEn                          : BOOL;
  fSetpoint                    : REAL;
  fCtrlVal                     : REAL;
  bEnSync                      : BOOL;
  fValSync                     : REAL;
END_VAR
VAR_INPUT CONSTANT PERSISTENT
  {attribute 'parameterCategory':='Config'}
  eOpMode                      : E_BA_PIDMode := E_BA_PIDMode.ePID;
  {attribute 'parameterCategory':='Deadband'}
  fNeutralZone                 : REAL := 0.0;
  {attribute 'parameterCategory':='Config'}
  eAction                      : E_BA_Action := E_BA_Action.eReverse;
  {attribute 'parameterCategory':='Config'}
  fMinOutput                   : REAL := 0;
  {attribute 'parameterCategory':='Config'}
  fMaxOutput                   : REAL := 100;
  {attribute 'parameterCategory':='Config'}
  fProportionalConstant        : REAL := 3;
  {attribute 'parameterCategory':='Config'}
  {attribute 'parameterUnit':= 's,ms'}
  fIntegralConstant            : REAL;
  {attribute 'parameterCategory':='Config'}
  {attribute 'parameterUnit':= 's,ms'}
  fDerivativeConstant          : REAL;
  {attribute 'parameterCategory':='Config'}
  {attribute 'parameterUnit':= 's'}
  nDampConstant                : UDINT;
END_VAR
VAR_OUTPUT
  fPresentValue                : REAL;
END_VAR

FB_BA_PIDControl 4: Inputs

Name

Type

Description

bEn

BOOL

Enabling the controller

fSetpoint

REAL

Setpoint of the controlled system

fCtrlVal

REAL

Actual value of the controlled system

bEnSync

BOOL

Synchronizes the controller to the value of fValSync.

fValSync

REAL

Synchronization value. The value fValSync is internally limited to values from fMinOutput to fMaxOutput.

FB_BA_PIDControl 5: Inputs CONSTANT PERSISTENT

Name

Type

Description

eOpMode

E_BA_PIDMode

Mode of operation of the controller: PID mode or P-ID mode.

fNeutralZone

REAL

Dead zone

eAction

E_BA_Action

Control direction of the controller

fMinOutput

TIME

Lower controller output limit [%]. The value fMinOutput is limited at the top by fMaxOutput.

fMaxOutput

TIME

Upper controller output limit [%].

fProportionalConstant

REAL

Controller gain. Only affects the P part. Internally limited to a minimum value of 0.

fIntegralConstant

REAL

Integral action time of the I part [s,ms]. A null value at this parameter disables the I part.

fDerivativeConstant

REAL

Rate time of the D part [s,ms]. A null value at this parameter disables the D part.

nDampConstant

UDINT

Damping time of the D part [s].

FB_BA_PIDControl 6: Outputs

Name

Type

Description

fPresentValue

REAL

Control value. Range limited by fYMin and fYMax.

FB_BA_PIDControl 7: Properties

Name

Type

Access

Description

AntiResetWindup

BOOL

Get

The controller is in anti-reset windup status.

ControlDeviation

REAL

Get

Control deviation

IsMaxLimit

BOOL

Get

The controller output fPresentValue is at the upper output limit fMaxOutput.

IsMinLimit

BOOL

Get

The controller output fPresentValue is at the lower output limit fMinOutput.

Requirements

Development environment

Required PLC library

TwinCAT from v3.1.4024.56

Tc3_BA2 from v5.4.2.0