FB_HVAC2PointCtrlSequence

FB_HVAC2PointCtrlSequence 1:

Application

This function block represents a 2-point sequence controller. It is used for sequential staged control of discontinuous aggregates. If can be used for cascades of vessels and in sequences of refrigerating machines or recooling plants for controlling the power stages. For each power stage an instance of the function block is used.

FB_HVAC2PointCtrlSequence 2:

FB_HVAC2PointCtrlSequence can be used in a control sequence with other sequence controllers from TcHVAC.lib.

Depending on the application several actuators (stages) are used for reaching a controlled variable, which operate in a so-called control sequence. In the control sequence shown below four stages are enabled via the respective output bOut = TRUE of FB_HVAC2PointCtrlSequence. With active control only one of the 2-point sequence controllers is active at a time. The outputs of the non-active 2-point sequence controller are fixed. This means that depending on the control direction bDirection of the individual controller; bOut is either TRUE or FALSE.

If the action of the active step is insufficient in the switched-on state, the active 2-point controller switches over to the neighboring 2-point controller on the left or right in the controller sequence via iCurrentSequence. This then takes over control of the steps. The previously active controller remains in the end position bOut = TRUE or FALSE, depending on the control direction.

Transfer function of the internal I transfer element

Transfer function of the internal I transfer element

FB_HVAC2PointCtrlSequence 3:

Through an internal AND link of the I transfer element consisting of (tCtrl_I_Ti_HighLimit, tCtrl_I_Ti_LowLimit, rCtrl_I_HighLimit, rCtrl_I_LowLimit, st2PointCtrlSequence.rCtrl_I_Out) and the delay times tDelayIncreaseSequence/tDelayDecreaseSequence switching in the control sequence to the right or left is controlled via iCurrentSequence. The active sequence controller is indicated via bActiveCtrl = TRUE (iCurrentSequence = iMyNumberInSequence).

The I transfer element and the timing elements for the delay times tDelayIncreaseSequence/tDelayDecreaseSequence are activated if

bActiveCtrl = TRUEAND
( (*Decrease*)
(
rX
> st2PointCtrlSequence.rW_MaxAND ((iMyNumberInSequence <= 1) = FALSE) AND
(
(bDirection = TRUEANDbOut = TRUE) OR
(bDirection = FALSEANDbOut = FALSE)
)
)
OR
( (*Increase*)
rX < st2PointCtrlSequence.rW_MinAND((iMyNumberInSequence >= iNumberOfSequences) = FALSE) AND
(
(bDirection = FALSEANDbOut = TRUE) OR
(bDirection = TRUEANDbOut = FALSE)
)
)
)

Once the I transfer element (st2PointCtrlSequence.rCtrl_I_Out output of the internal I transfer element) AND the timing elements for the delay times tDelayIncreaseSequence/tDelayDecreaseSequence have been activated, switching in the control sequence to the right or left via iCurrentSequence is controlled as follows:

iCurrentSequence = iCurrentSequence - 1 if st2PointCtrlSequence.rCtrl_I_Out <= st2PointCtrlSequence.rCtrl_I_LowLimitANDst2PointCtrlSequence.tRemainingTimeDecreaseSequence = T#0s.

iCurrentSequence = iCurrentSequence + 1 if st2PointCtrlSequence.rCtrl_I_Out >= st2PointCtrlSequence.rCtrl_I_HighLimitANDst2PointCtrlSequence.tRemainingTimeIncreaseSequence = T#0s.

Behavior of the outputs of four FB_HVAC2PointCtrlSequence in a control sequence

FB_HVAC2PointCtrlSequence 4:
FB_HVAC2PointCtrlSequence_1
FB_HVAC2PointCtrlSequence 5:

In the control sequence of four FB_HVAC2PointCtrlSequence controllers shown above there may be no gap in the allocation of iMyNumberInSequence (1,2,3,4) and iNumberOfSequence (4), since otherwise automatic switching of the controllers from the active controller to the adjacent controller to the right or left in the control sequence would not work.

FB_HVAC2PointCtrlSequence 6:

If bEnable =FALSEODERbError = TRUEODER (e2PointCtrlMode =eHVAC2PointCtrlMode_On_BMSODEReHVAC2PointCtrlMode_On_OPODEReHVAC2PointCtrlMode_Off_BMSODEReHVAC2PointCtrlMode_Off_OP), automatic switching of the controllers from the active controller to the adjacent controller to the right or left in the control sequence is still operational. The switching mode is therefore always active. The active function block is displayed with bActiveCtrl = TRUE. Depending on the control deviation rE up- or down-switching of the sequence via iCurrentSequence is directly executed. If rX >= rW, then iCurrentSequence = iCurrentSequence - 1. If rX < rW, then iCurrentSequence = iCurrentSequence + 1.

Application example

Download

Required library

TcHVAC.pro

TcHVAC.lib

VAR_INPUT

eDataSecurityType  : E_HVACDataSecurityType;
bSetDefault        : BOOL;                               
bEnable            : BOOL;
e2PointCtrlMode    : E_HVAC2PointCtrlMode;
bDirection         : BOOL;
rW                 : REAL;
rX                 : REAL;
iNumberOfSequences : INT;              1..32 
iMyNumberInSequence: INT;              1..32
bReset             : BOOL;

eDataSecurityType:if eDataSecurityType:= eHVACDataSecurityType_Persistent, the persistent VAR_IN_OUT variables of the function block are stored in the flash of the computer if a value changes. For this to work, the function block FB_HVACPersistentDataHandling must be instanced once in the main program, which is called cyclically. Otherwise the instanced FB is not released internally.

A change of value can be initiated by the building management system, a local operating device or via a write access from TwinCAT. When the computer is restarted the saved data are automatically read back from the flash into the RAM.

Application example: FB_HVAC2PointCtrlSequence 7:Example_PERSISTENT.zip

If eDataSecurityType:= eHVACDataSecurityType_Idle the persistently declared variables are not saved in a fail-safe manner.

Notice

A cyclically changing variable must never be linked with the IN_OUT variable of a function block, if eDataSecurityType:= eHVACDataSecurityType_Persistent. It would lead to early wear of the flash memory.

bSetDefault: If the variable is TRUE, the default values of the VAR_IN_OUT variables are adopted.

bEnable: the function block is enabled via TRUE. If bEnable = FALSE, the 2-point sequence controller is disabled. Validation of the variables iNumberOfSequences, iMyNumberInSequence, iCurrentSequence and tTi_Ctrl_I is still active. If an error occurs, it is displayed with bError = TRUE and can be acknowledged with bReset once the fault has been corrected.

FB_HVAC2PointCtrlSequence 8:

If bEnable =FALSEODERbError = TRUEODER (e2PointCtrlMode =eHVAC2PointCtrlMode_On_BMSODEReHVAC2PointCtrlMode_On_OPODEReHVAC2PointCtrlMode_Off_BMSODEReHVAC2PointCtrlMode_Off_OP), automatic switching of the controllers from the active controller to the adjacent controller to the right or left in the control sequence is still operational. The switching mode is therefore always active. The active function block is displayed with bActiveCtrl = TRUE. Depending on the control deviation rE up- or down-switching of the sequence via iCurrentSequence is directly executed. If rX >= rW, then iCurrentSequence = iCurrentSequence - 1. If rX < rW, then iCurrentSequence = iCurrentSequence + 1.

e2PointCtrlMode: Enum that specifies the operation mode of the 2-point sequence controller. If bEnable = TRUEANDbError = FALSE, the output bOut can be switched on or off directly via the Enum. When starting the PLC, e2PointCtrlMode = eHVAC2PointCtrlMode_Auto_BMS.
Switching the sequence up or down via iCurrentSequence is not dependent on the operating mode e2PointCtrlMode of the 2-point sequence controller.

FB_HVAC2PointCtrlSequence 9:

If bEnable =FALSEODERbError = TRUEODER (e2PointCtrlMode =eHVAC2PointCtrlMode_On_BMSODEReHVAC2PointCtrlMode_On_OPODEReHVAC2PointCtrlMode_Off_BMSODEReHVAC2PointCtrlMode_Off_OP), automatic switching of the controllers from the active controller to the adjacent controller to the right or left in the control sequence is still operational. The switching mode is therefore always active. The active function block is displayed with bActiveCtrl = TRUE. Depending on the control deviation rE up- or down-switching of the sequence via iCurrentSequence is directly executed. If rX >= rW, then iCurrentSequence = iCurrentSequence - 1. If rX < rW, then iCurrentSequence = iCurrentSequence + 1.

bDirection: bDirection determines the control direction of the internal 2-point controller. FALSE = heating mode;  TRUE = cooling mode.

rW: The setpoint is transferred with the variable rW.

rX: the actual value is transferred with the variable rX.

iNumberOfSequences: number of controllers in the sequence. If iNumberOfSequences <= 0 an error is issued and indicated with bError = TRUE. The number of devices in a sequence is not exceeded by the active sequence controller via iCurrentSequence.

iMyNumberInSequence: the 2-point controller's own number in the sequence. If iMyNumberInSequence > iNumberOfSequencesORiMyNumberInSequence <= 0, an error is issued and indicated with bError = TRUE.

bReset: input for acknowledgement of the faults once they have been corrected. Internally the system responds to a rising edge.

VAR_OUTPUT

bOut                : BOOL;
bActiveCtrl         : BOOL;
b_rW_Max            : BOOL;
b_rW_Min            : BOOL;
rE                  : REAL;
e2PointCtrlState    : E_HVAC2PointCtrlMode;
st2PointCtrlSequence: ST_HVAC2PointCtrlSequence;
bError              : BOOL;
eErrorCode          : E_HVACErrorCodes;

bOut: output of the 2-point sequence controller.

bOut becomes TRUE, if

1.
bEnable = TRUEANDbError = FALSEAND
( e2PointCtrlMode = eHVAC2PointCtrlMode_Auto_BMSORe2PointCtrlMode = eHVAC2PointCtrlMode_Auto_OP ) AND
bActiveCtrl
= TRUEAND
(
(bDirection = TRUEAND ( rX > st2PointCtrlSequence.rW_Max )) OR ( bDirection = FALSEAND ( rX < st2PointCtrlSequence.rW_Min ))
)

2.
bEnable = TRUEANDbError = FALSEAND
( e2PointCtrlMode = eHVAC2PointCtrlMode_Auto_BMSORe2PointCtrlMode = eHVAC2PointCtrlMode_Auto_OP ) AND
(
( bDirection = TRUEAND ( iCurrentSequence < iMyNumberInSequence )) OR ( bDirection = FALSEAND ( iCurrentSequence > iMyNumberInSequence ))
)

3.
bEnable = TRUEANDbError = FALSEAND
( e2PointCtrlMode = eHVAC2PointCtrlMode_On_BMSORe2PointCtrlMode = eHVAC2PointCtrlMode_On_OP )

bOut becomes FALSE, if

1.
bEnable = FALSEORbError = TRUE

2.
bEnable = TRUEANDbError = FALSEAND
( e2PointCtrlMode = eHVAC2PointCtrlMode_Auto_BMSORe2PointCtrlMode = eHVAC2PointCtrlMode_Auto_OP ) AND
bActiveCtrl
= TRUEAND
(
( bDirection = TRUEAND ( rX < st2PointCtrlSequence.rW_Min )) OR ( bDirection = FALSEAND ( rX > st2PointCtrlSequence.rW_Max ))
)

3.
bEnable = TRUEANDbError = FALSEAND
( e2PointCtrlMode = eHVAC2PointCtrlMode_Auto_BMSORe2PointCtrlMode = eHVAC2PointCtrlMode_Auto_OP ) AND
(
( bDirection = TRUEAND ( iCurrentSequence > iMyNumberInSequence )) OR ( bDirection = FALSEAND ( iCurrentSequence < iMyNumberInSequence ))
)

4.
bEnable = TRUEANDbError = FALSEAND
( e2PointCtrlMode = eHVAC2PointCtrlMode_Off_BMSORe2PointCtrlMode = eHVAC2PointCtrlMode_Off_OP )

bActiveCtrl: bActiveCtrl indicates with TRUE that the function block is the active one in the sequence. bActiveCtrl becomes TRUE, if bEnable = TRUE, bError = FALSEANDiCurrentSequence = iMyNumberInSequence.

b_rW_Max: b_rW_Max becomes TRUE, if rX > st2PointCtrlSequence.rW_Max.

b_rW_Min: b_rW_Min becomes TRUE, if rX < st2PointCtrlSequence.rW_Min.

rE: control deviation: rE = rW - rX

e2PointCtrlState: Enum indicating the state of the operation mode e2PointCtrlModeof the 2-point sequence controller

st2PointCtrlSequence: the structure indicates various states, inputs and outputs of the function block. Furthermore the remaining times of the VAR_IN_OUT variables tDelayIncreaseSequence and tDelayDecreaseSequence are output if their function is active. Via st2PointCtrlSequence.rCtrl_I_Out the output signal of the internal I transfer element is displayed.

st2PointCtrlSequence.tRemainingTimeIncreaseSequence: remaining delay time tDelayIncreaseSequence.

st2PointCtrlSequence.tRemainingTimeDecreaseSequence: remaining delay time tDelayDecreaseSequence.

st2PointCtrlSequence.rX: state of rX

st2PointCtrlSequence.rW_Max: st2PointCtrlSequence.rW_Max := rW + rW_HighLimit – upper setpoint limit; if rX exceeds it, the internal I transfer element and the timing elements of the delay times tDelayIncreaseSequence/tDelayDecreaseSequence can be activated or deactivated respectively, see Transfer function of the internal I transfer element in this document

st2PointCtrlSequence.rW_Min: st2PointCtrlSequence.rW_Min := rW - rW_LowLimit - lower setpoint limit; if rX falls below it, the internal I transfer element and the timing elements of the delay times tDelayIncreaseSequence/tDelayDecreaseSequence can be activated or deactivated respectively, see Transfer function of the internal I transfer element in this document

st2PointCtrlSequence.rE: control deviation: rE = rW - rX

st2PointCtrlSequence.rCtrl_I_HighLimit: upper limit at which the integration of the internal I transfer element is stopped. st2PointCtrlSequence.rCtrl_I_HighLimit = rCtrl_I_HighLimit

st2PointCtrlSequence.rCtrl_I_LowLimit: lower limit at which the integration of the internal I transfer element is stopped. st2PointCtrlSequence.rCtrl_I_Low = rCtrl_I_LowLimit * (-1)

st2PointCtrlSequence.rCtrl_I_Out: output of the internal I transfer element.
If st2PointCtrlSequence.rCtrl_I_Out = st2PointCtrlSequence.rCtrl_I_HighLimitOR
st2PointCtrlSequence.rCtrl_I_LowLimit
AND
either st2PointCtrlSequence.tRemainingTimeIncreaseSequenceOR
st2PointCtrlSequence.tRemainingTimeDecreaseSequence
= T#0sAND
bActive = TRUE, then the number of the active controller iCurrentSequence is incremented or decremented by 1, depending on bDirection.

st2PointCtrlSequence.e2PointCtrlState: see e2PointCtrlState

st2PointCtrlSequence.iNumberOfSequences: see iNumberOfSequences

st2PointCtrlSequence.iMyNumberInSequence: see iMyNumberInSequence

st2PointCtrlSequence.iCurrentSequence: see iCurrentSequence

st2PointCtrlSequence.bEnable: see bEnable

st2PointCtrlSequence.bError: see bError

st2PointCtrlSequence.bOut: see bOut

st2PointCtrlSequence.bActiveCtrl: see bActiveCtrl

st2PointCtrlSequence.b_rW_Max: see b_rW_Max

st2PointCtrlSequence.b_rW_Min: see b_rW_Min

bError: the output is TRUE if an error is active and one of the variables iNumberOfSequences, iMyNumberInSequence or iCurrentSequence has an incorrect parameter. Once the fault has been corrected the bError message must be acknowledged with bReset. The eErrorCode enum indicates the error number. If bError = TRUE, then the output bOut = FALSE.

FB_HVAC2PointCtrlSequence 10:

If bEnable =FALSEODERbError = TRUEODER (e2PointCtrlMode =eHVAC2PointCtrlMode_On_BMSODEReHVAC2PointCtrlMode_On_OPODEReHVAC2PointCtrlMode_Off_BMSODEReHVAC2PointCtrlMode_Off_OP), automatic switching of the controllers from the active controller to the adjacent controller to the right or left in the control sequence is still operational. The switching mode is therefore always active. The active function block is displayed with bActiveCtrl = TRUE. Depending on the control deviation rE up- or down-switching of the sequence via iCurrentSequence is directly executed. If rX >= rW, then iCurrentSequence = iCurrentSequence - 1. If rX < rW, then iCurrentSequence = iCurrentSequence + 1.

eErrorCode:returns the error number when the bError output is set. The following errors may occur in this function block: eHVACErrorCodes_Error_iMyNumberInSequence, eHVACErrorCodes_Error_iNumberOfSequences, eHVACErrorCodes_Error_iCurrentSequences

FB_HVAC2PointCtrlSequence 11:

To get the error numbers of the enum in the PLC, eErrorCode can be assigned to a variable of data type WORD.eHVACErrorCodes_Error_iNumberOfSequences = 27 eHVACErrorCodes_Error_iMyNumberInSequence = 28 eHVACErrorCodes_Error_iCurrentSequences = 29

VAR_IN_OUT

rW_HighLimit            : REAL;
rW_LowLimit             : REAL;
tDelayIncreaseSequence  : TIME;
tDelayDecreaseSequence  : TIME;
tCtrl_I_Ti_HighLimit    : TIME;
tCtrl_I_Ti_LowLimit     : TIME;
rCtrl_I_HighLimit       : REAL;
rCtrl_I_LowLimit        : REAL;
iCurrentSequence        : INT;

rW_HighLimit: positive value of the upper limit of the control deviation. st2PointCtrlSequence.rW_Max =rW_Max := rW + rW_HighLimit.
The variable is saved persistently. Preset to 5.

rW_LowLimit: positive value of the lower limit of the control deviation. st2PointCtrlSequence.rW_Min =rW_Min := rW - rW_LowLimit.
The variable is saved persistently. Preset to 5.

tDelayIncreaseSequence: delay time after which iCurrentSequence is increased by 1, see Transfer function of the internal I transfer element in this document. The variable is saved persistently. Preset to 5 min.

tDelayDecreaseSequence: delay time after which iCurrentSequence is decreased by 1, see Transfer function of the internal I transfer element in this document. The variable is saved persistently. Preset to 5 min.

tCtrl_I_Ti_HighLimit: integration time for the upper limit of the internal I transfer element, see Transfer function of the internal I transfer element in this document. tCtrl_I_Ti_HighLimit must be > T#0s. The variable is saved persistently. Preset to 10 min.

tCtrl_I_Ti_LowLimit: integration time for the lower limit of the internal I transfer element, see Transfer function of the internal I transfer element in this document. tCtrl_I_Ti_LowLimit must be > T#0s. The variable is saved persistently. Preset to 10 min.

rCtrl_I_HighLimit: positive value for the upper limit at which the integration of the internal I transfer element is stopped (ARW measure, anti-reset windup), see Transfer function of the internal I transfer element in this document. The variable is saved persistently. Preset to 10.

rCtrl_I_LowLimit: negative value for the lower limit at which the integration of the internal I transfer element is stopped (ARW measure, anti-reset windup), see Transfer function of the internal I transfer element in this document. The variable is saved persistently. Preset to -10.

iCurrentSequence: number of the active controller in the sequence (0..32). The number of devices in a sequence iNumberOfSequences is not exceeded by the active sequence controller via iCurrentSequence.
If iCurrentSequence > iNumberOfSequences or iCurrentSequence < 0, an error is indicated with bError = TRUE.
The sequence is switched up or down via iCurrentSequence depending on the control deviation rE if the function block is active in the sequence bActiveCtrl = TRUE.

1. iCurrentSequence = iCurrentSequence - 1 if st2PointCtrlSequence.rCtrl_I_Out >= st2PointCtrlSequence.rLimit_Ctrl_I_MinUNDst2PointCtrlSequence.tRemainingTimeDecreaseSequence = T#0sUNDbActiveCtrl = TRUE

2. iCurrentSequence = iCurrentSequence + 1 if st2PointCtrlSequence.rCtrl_I_Out >= st2PointCtrlSequence.rLimit_Ctrl_I_MaxUNDst2PointCtrlSequence.tRemainingTimeIncreaseSequence = T#0sUNDbActiveCtrl = TRUE

FB_HVAC2PointCtrlSequence 12:

To ensure correct functioning of the automatic switchover of the controller from the active controller to the neighboring controller on the left or right in the control sequence, iCurrentSequence may not be written to continuously from the outside in a control sequence. When starting a control sequence it must be defined which sequence controller is active. iCurrentSequence must be written for a PLC cycle and be > 0 and <= iNumberOfSequences.

FB_HVAC2PointCtrlSequence 13:

If bEnable =FALSEODERbError = TRUEODER (e2PointCtrlMode =eHVAC2PointCtrlMode_On_BMSODEReHVAC2PointCtrlMode_On_OPODEReHVAC2PointCtrlMode_Off_BMSODEReHVAC2PointCtrlMode_Off_OP), automatic switching of the controllers from the active controller to the adjacent controller to the right or left in the control sequence is still operational. The switching mode is therefore always active. The active function block is displayed with bActiveCtrl = TRUE. Depending on the control deviation rE up- or down-switching of the sequence via iCurrentSequence is directly executed. If rX >= rW, then iCurrentSequence = iCurrentSequence - 1. If rX < rW, then iCurrentSequence = iCurrentSequence + 1.