FB_HVACI_CtrlStepEx

FB_HVACI_CtrlStepEx 1:

Application

Application

The function block serves the sequential control of power generators. It differs from FB_HVACI_CtrlStep in that the value of iStep is specified by the variable iStartStep when starting the function block.

In conjunction with the power range table FB_HVACPowerRangeTable, the power step controller can be used for the stepped control of several heating boilers, refrigerating machines or recooling plants.

Switching up or down to the next higher or next lower power step respectively takes place via an integral (rW - rX) and a time delay. First of all, the actual temperature value rX must have exceeded or fallen below a threshold value rW_High / rW_Low. Subsequently, the integral starts. If the upper or lower limit value (rIntegralHigh / rIntegralLow) is reached at the output rI_Ctrl, then a timing element is started upon whose expiry (udiSecRT_DelayHigh / udiSecRT_DelayLow) the output iStep is incremented or decremented; see Program flowchart

FB_HVACI_CtrlStepEx 2:

An integration time setting of udiSecTiHigh/udiSecTiLow = 60 seconds means that the I transfer element changes by one Kelvin per minute. With a control deviation rE = 5, the output of the I transfer element rI_Ctrl has the value 5 after one minute. Example:bDirection = FALSE; udiSecTiLow = 60; rE = 2; rIntegralLow = 10 With the remaining control deviation of 2 and the lower integral limit of 10, after 5 minutes rI_Ctrl = rIntegralLow. The consequence of this is that a timing element with the delay time udiSecDelayLow is started. After its expiry (udiSecRT_DelayHigh / udiSecRT_DelayLow),the output iStep is incremented by 1 and the I transfer element and the time delays are reset.

FB_HVACI_CtrlStepEx 3:

iStep is set to iStartStep for one PLC cycle if bEnable = TRUEANDbError = FALSE.

Conditions

The I transfer element is released, if

bEnable = TRUEAND NOTbErrorANDeCtrlMode = eHVACCtrlMode_AutoAND NOTbBlock
(
(rX >= rW_HighAND ((iStep > 0 ANDNOTbDirection) OR (iStep < iNumberOfStepInProfileANDbDirection))
OR
(rX < rW_LowAND ((iStep < iNumberOfStepInProfileANDNOTbDirection) OR (iStep > 0 ANDbDirection))
)

. If rI_Ctrl =rIntegralHigh / rIntegralLow, then the timing elements of the delay times udiSecDelayHigh / udiSecDelayLow are activated. After the expiry of the delay times udiSecRT_DelayHigh / udiSecRT_DelayLow, the steps of the power step sequence are controlled as follows:

iStep = iStep + 1 if

(rX < rW_LowANDiStep < iNumberOfStepInProfileANDNOTbDirection)
OR
(rX >= rW_HighANDiStep < iNumberOfStepInProfileANDbDirection)

iStep = iStep - 1 if

(rX < rW_LowANDiStep > 0 ANDbDirection)
OR
(rX >= rW_HighANDiStep > 0 ANDNOTbDirection)

FB_HVACI_CtrlStepEx 4:

The I transfer element and the internal time delays (udiSecDelayLow, udiSecDelayHigh) are reset after each change of iStep.

Transfer function of the I transfer element (I_Ctrl)

FB_HVACI_CtrlStepEx 5:

Program flowchart

Program flowchart

FB_HVACI_CtrlStepEx 6: FB_HVACI_CtrlStepEx 7:

FB_HVACI_CtrlStepEx 8:

Program flowchart

Program flowchart

FB_HVACI_CtrlStepEx 9:
FB_HVACI_CtrlStepDiagramm

Behavior of the different variables

Behavior of the different variables

The figure shows when each variable is used and how.


Application example

FB_HVACI_CtrlStepEx 10:
FB_HVACI_CtrlStepParameter

The application example shows the function block FB_HVACI_CtrlStep in conjunction with the power range table FB_HVACPowerRangeTable. The example is available in the programming languages ST and CFC. The program example P_CFC_I_CtrlStep.PRG in CFC can be found in the folder Language CFC > Controller, the program example P_ST_I_CtrlStep.PRG in ST in the folder Language Structure Text > Controller.

Download

Required library

TcHVAC.pro

TcHVAC.lib

VAR_INPUT

eDataSecurityType     : E_HVACDataSecurityType;
bSetDefault           : BOOL;
bEnable           : BOOL;
rW            : REAL;
rX            : REAL;
iStartStep        : INT;             0..iNumberOfStepInProfile
eCtrlMode         : E_HVACCtrlMode;
iManualStep           : INT;             0..iNumberOfStepInProfile
bStepUp           : BOOL;
bStepDown         : BOOL;
bDirection        : BOOL;
iNumberOfStepInProfile    : INT;             0..g_iMaxNumberOfSteps
bBlock            : BOOL;
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_HVACI_CtrlStepEx 11: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, then iStep is set constantly to 0. The check of the variable iNumberOfStepInProfile remains active. If an error occurs, it is displayed with bError = TRUE and can be acknowledged with bReset once the fault has been corrected.

rW: The setpoint is transferred with the variable rW.

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

iStartStep: if the function block is enabled (bEnable = TRUE) and there is no error (bError = FALSE), then iStep = iStartStep for one PLC cycle.

eCtrlMode: Enum that specifies the operation mode of the function block. If bEnable = TRUEANDbError = FALSEANDeCtrlMode = eHVACCtrlMode_ManualANDiNumberOfStepInProfile > 0, then the value of the output iStep can be specified via iManualStep. On starting the PLC, eCtrlMode = eHVACCtrlMode_Auto.

iManualStep: if the operation mode eCtrlModeeHVACCtrlMode_ManualANDbEnable = TRUEANDbError = FALSEANDiNumberOfStepInProfile > 0, then the value of the output iStep can be specified via iManualStep. The input range of iManualStep can be 0 at the least and the value of iNumberOfStepInProfile at the most.

bStepUp: if bEnable = TRUEANDbError = FALSEANDeCtrlMode = eHVACCtrlMode_AutoANDbBlock=FALSE, then the value of the output iStep can be incremented by 1 by a rising edge at the input bStepUp. This can be repeated until iStep = iNumberOfStepInProfile.

bStepDown: if bEnable = TRUEANDbError = FALSEANDeCtrlMode = eHVACCtrlMode_AutoANDbBlock=FALSE, then the value of the output iStep can be decremented by 1 by a rising edge at the input bStepDown. This can be repeated until iStep = 0.

bDirection: the control direction of the function block is determined by bDirection. FALSE = heating mode; TRUE = cooling mode

iNumberOfStepInProfile: number of steps in the power step sequence. iNumberOfStepInProfile can be minimum 0 and maximum g_iMaxNumberOfSteps. If the limit values are not adhered to, an error is output and displayed by bError = TRUE and iStep becomes 0.

bBlock: using the input variable bBlock, the control of the function block can either be released or the output iStep is set to the value of the variable iNumberOfStepInProfile.

If bEnable = TRUEANDbError = FALSEANDeCtrlMode = eHVACCtrlMode_AutoANDbBlock=FALSE, then the I transfer element and the internal timing elements are enabled for the control of the output iStep.

If bEnable = TRUEANDbError = FALSEANDeCtrlMode = eHVACCtrlMode_AutoANDbBlock=TRUE, then the I transfer element and the internal timing elements are blocked and iStep = iNumberOfStepInProfile.

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

VAR_OUTPUT

iStep               : INT;           0..iNumberOfStepInProfile
rI_Ctrl             : REAL;
rE                  : REAL;
rW_High             : REAL;
rW_Low              : REAL;
b_rW_High               : BOOL;
b_rW_Low            : BOOL;
udiSecRT_DelayHigh          : UDINT;                         Second Remaining Time Delay High
udiSecRT_DelayLow           : UDINT;                         Second Remaining Time Delay Low
bError              : BOOL;
eErrorCode              : E_HVACErrorCodes;

iStep: the output variable iStep indicates the step in a power step sequence. When starting the function block, iStep = iStartStep, if bEnable = TRUEANDbError = FALSE. iStep can reach at most the value of iNumberOfStepInProfile and be at least 0.

The value of iStep can be manually specified via iManualStep, if bEnable = TRUE, bError = FALSEANDeCtrlMode = eHVACCtrlMode_Manual.

The value of iStep can be incremented or decremented via the input variables bStepUp / bStepDown, if bEnable = TRUE, bError = FALSE, eCtrlMode = eHVACCtrlMode_AutoANDbBlock = FALSE.

If bEnable = TRUE, bError = FALSE, eCtrlMode = eHVACCtrlMode_Auto ANDbBlock = FALSE and the value of iStep has changed, then the delay timing elements and the I transfer element are reset.

If bEnable = TRUE, bError = FALSE, eCtrlMode = eHVACCtrlMode_Auto, bBlock = FALSEANDiNumberOfStepInProfile > 0, the output of the I transfer element rI_Ctrl =rIntegralHigh or rIntegralLow and one of the delay times tRemainingTimeDelayHigh / tRemainingTimeDelayLow =T#0s, then the output iStep is controlled as follows:

iStep = iStep + 1 if

(rX < rW_LowANDiStep < iNumberOfStepInProfileANDNOTbDirection)
OR
(rX >= rW_HighANDiStep < iNumberOfStepInProfileANDbDirection).

iStep = iStep - 1 if

(rX < rW_LowANDiStep > 0 ANDbDirection)
OR
(rX >= rW_HighANDiStep > 0 ANDNOTbDirection), see Program flowchart

If bEnable = TRUEANDbError = FALSEANDeCtrlMode = eHVACCtrlMode_AutoANDbBlock=TRUE, then the I transfer element and the internal timing elements are blocked and iStep = iNumberOfStepInProfile.

rI_Ctrl: output of the I transfer element.
If rI_Ctrl >= rIntegralHigh orrIntegralLow and tRemainingTimeDelayHigh or tRemainingTimeDelayLow = T#0s, then the number of steps is incremented or decremented by 1 via iStep. Subsequently, the I transfer element and the timing elements for stepping up or down are reset, so that stepping up or down is restarted, see Program flowchart.

rE: control deviation with which the internal I transfer element works: rE = rW - rX

rW_High: rW_High := rW + rHysteresisHigh - upper setpoint limit which, when exceeded by rX, causes the I transfer element to be activated first, followed by the timing element of the delay time udiSecDelayHigh; see Application or Behavior of different variables.

rW_Low: rW_Low := rW - rHysteresisLow - lower setpoint limit which, when undershot by rX, causes the I transfer element to be activated first, followed by the timing element of the delay time udiSecDelayLow; see Application or Behavior of different variables.

b_rW_High: b_rW_High becomes TRUE, if rX > rW_High.

b_rW_Low: b_rW_Low becomes TRUE, if rX < rW_Low.

udiSecRT_DelayHigh: remaining time of delay time udiSecDelayHigh.

udiSecRT_DelayLow: remaining time of delay time udiSecDelayLow.

bError: the output signals with a TRUE that an error is present and an incorrect parameter is present at the variable iNumberOfStepInProfile. iStep is constantly set to 0 and the Enum eErrorCode indicates the error number. Once the fault has been corrected the bError message must be acknowledged with bReset.

eErrorCode: returns the error number when the bError output is set. The following error can occur in this function block: eHVACErrorCodes_InvalidParam_NumberOfStepInProfile

FB_HVACI_CtrlStepEx 12:

To access the enum error numbers in the PLC, eErrorCode can be assigned to a variable of the data type WORD.eHVACErrorCodes_Error_iNumberOfStepInProfil= 32

VAR_IN_OUT

rHysteresisHigh       : REAL;  
rHysteresisLow        : REAL; 
udiSecDelayHigh       : UDINT; 
udiSecDelayLow        : UDINT; 
udiSecTiHigh          : UDINT; 
udiSecTiLow           : UDINT; 
rIntegralHigh         : REAL; 
rIntegralLow          : REAL;  

rHysteresisHigh: positive value of the upper limit of the control deviation, see Application or Behavior of different variables. rW_High := rW + rHysteresisHigh The variable is saved persistently. Preset to 5.

rHysteresisLow: positive value of the lower limit of the control deviation, see Application or Behavior of different variables. rW_Low := rW - rHysteresisLow The variable is saved persistently. Preset to 5.

udiSecDelayHigh: delay time after whose expiry iStep is incremented or decremented; see Application or Behavior of different variables. The variable is saved persistently. Preset to 300 s.

udiSecDelayLow: delay time after whose expiry iStep is incremented or decremented; see Application or Behavior of different variables. The variable is saved persistently. Preset to 300 s.

udiSecTiHigh: integration time for the upper limit of the I transfer element in seconds, see Application or Behavior of different variables. udiSecTiHigh must be > 0. Otherwise the default value or the last valid variable value is used internally. The variable is saved persistently. Preset to 60 s.

udiSecTiLow: integration time for the lower limit of the I transfer element, see Application or Behavior of different variables. udiSecTiLow must be > 0. Otherwise the default value or the last valid variable value is used internally. The variable is saved persistently. Preset to 60 s.

rIntegralHigh: positive value for the upper limit at which the integration of the I transfer element is stopped (ARW measure, anti-reset-windup) and one of the delay times starts; see Application or Behavior of different variables. The variable is saved persistently. Preset to 15.

rIntegralLow: positive value for the lower limit at which the integration of the I transfer element is stopped (ARW measure, anti-reset-windup) and one of the delay times starts; see Application or Behavior of different variables. The variable is saved persistently. Preset to 15.