FB_HVACMUX_INT_8

This function block contains two different types of multiplexers, one each for the operation modes eHVACCtrlMode_Auto or eHVACCtrlMode_Manual. This selection is made with the help of the Enum eCtrlMode.
The following conditions must first be fulfilled for this:
bEnable = TRUE AND bError = FALSE
If eCtrlMode = eHVACCtrlMode_Auto, the variable bDirection determines whether the output variable iValueNumber is incremented or decremented when using the input bEdgeNewValue. If bDirection = FALSE it is incremented, if bDirection = TRUE it is decremented.
If eCtrlMode = eHVACCtrlMode_Manual, the output iValueNumber is determined by the variable iManualValue. The variables iNumberOfValues, bEdgeNewValue and bDirection are not taken into account in this operation mode.
The output iValueNumber always indicates the number of the variable iValueX, whose content is output in the output variable iValueOut.
Examples of eCtrlMode = eHVACCtrlMode_Auto
- If bDirection = FALSE AND iNumberOfValues = 7 and there is a rising edge on bEdgeNewValue, then iValueNumber is incremented. If iValueNumber = 4, then iValueOut = iValue4. If iValueNumber = iNumberOfValues(7) and there is a rising edge on bEdgeNewValue, then iValueNumber = 1 and hence iValueOut = iValue1.
- If bDirection = TRUE AND iNumberOfValues = 8 and there is a rising edge on bEdgeNewValue, then iValueNumber is decremented. If iValueNumber = 3, then iValueOut = iValue3. If iValueNumber = 1 and there is a rising edge on bEdgeNewValue, then iValueNumber = iNumberOfValues(8) and hence iValueOut = iValue8.
The start behavior of the outputs iValueNumber and iValueOut is as follows:
- If bDirection = FALSE AND iNumberOfValues > 0, then iValueNumber = 1 and iValueOut = iValue1.
- If bDirection = TRUE AND iNumberOfValues = 6, then iNumberOfValues = 6 and iValueOut = iValue6.
Examples of eCtrlMode = eHVACCtrlMode_Manual
- The value of iValueNumber is determined by iManualValue. If iManualValue = 7 then iValueNumber = 7, which then means that iValueOut = iValue7.
The start behavior of the outputs iValueNumber and iValueOut is as follows:
- If iManualValue = 13, then iValueNumber = 13 and iValueOut = iValue13.
- If iManualValue = 0, then iValueNumber = 0 and iValueOut = 0.
Notice | |
A frequently changing variable may not be applied to the VAR_IN_OUT variables iValue1-8 if eDataSecurityType = eHVACDataSecurityType_Persistent. This would lead to premature wear of the storage medium of the controller. If the VAR_IN_OUT variables iValue1-8 change frequently and are not to be stored persistently, then eDataSecurityType must be eDataSecurityType_Idle. |
VAR_INPUT
eDataSecurityType : E_HVACDataSecurityType;
bEnable : BOOL;
iNumberOfValues : INT;
bEdgeNewValue : BOOL;
bDirection : BOOL;
eCtrlMode : E_HVACCtrlMode;
iManualValue : INT;
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: 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. |
bEnable: The function block is enabled via TRUE. If bEnable = FALSE, then iValueOut and iValueNumber are set constantly to 0.
iNumberOfValues: Indicates the number of variables iValue1-8 that can be output via iValueOut. If iNumberOfValues = 8 is, then the output iValueNumber varies between 1 and 8. The variables iValue1 to iValue8 are then taken into account for the output iValueOut (see Application).
iNumberOfValues determines the start behavior of the outputs iValueOut and iValueNumber, (see Application).
iNumberOfValues is not taken into account in the operation mode eCtrlMode = eHVACCtrlMode_Manual.
iNumberOfValues must not fall below 1 and must not exceed 8. Otherwise an error is indicated by bError = TRUE and the execution of the function block is stopped.
bEdgeNewValue: iValueNumber is incremented or decremented if there is a rising edge on bEdgeNewValue.
If bEnable = TRUE AND bError = FALSE AND eCtrlMode = eHVACCtrlMode_Auto AND bDirection = FALSE AND iNumberOfValues > 0 and there is a rising edge on bEdgeNewValue, then iValueNumber is incremented. If iValueNumber = 6, then iValueOut = iValue6. If iValueNumber = iNumberOfValues and there is a rising edge on bEdgeNewValue, then iValueNumber = 1 and hence iValueOut = iValue1.
If bEnable = TRUE AND bError = FALSE AND eCtrlMode = eHVACCtrlMode_Auto AND bDirection = TRUE AND iNumberOfValues = 6 and there is a rising edge on bEdgeNewValue, then iValueNumber is decremented. If iValueNumber = 5, then iValueOut = iValue5. If iValueNumber = 1 and there is a rising edge on bEdgeNewValue, then iValueNumber = iNumberOfValues(6) and hence iValueOut = iValue6.
bEdgeNewValue is not taken into account in the operation mode eCtrlMode = eHVACCtrlMode_Manual.
bDirection: bDirection determines the control direction of the function block.
bDirection = FALSE means that iValueNumber increments from 1 to iNumberOfValues in ascending form and thus determines the output value iValueOut (see Application).
bDirection = TRUE means that iValueNumber decrements from iNumberOfValues to 1 in descending form and thus determines the output value iValueOut (see Application).
bDirection is not taken into account in the operation mode eCtrlMode = eHVACCtrlMode_Manual.
eCtrlMode: This enum specifies the operation mode of the function block (see E_HVACCtrlMode).
If the operation mode eCtrlMode = eHVACCtrlMode_Auto, then the variable iManualValue is not taken into account.
If the operation mode eCtrlMode = eHVACCtrlMode_Manual, then the variables iNumberOfValues, bEdgeNewValue and bDirection are not taken into account.
iManualValue: If the operation mode eCtrlMode = eHVACCtrlMode_Manual AND bEnable = TRUE AND bError = FALSE AND iManualValue = 15, then iValueNumber = 15. The contents of the variable iValue15 are then output via iValueOut (see Application).
iManualValue is not taken into account in the operation mode eCtrlMode = eHVACCtrlMode_Manual. The value of iValueNumber is determined by iManualValue. iManualValue should lie within the range of 0 to 16. If iManualValue falls below the value 0, then 0 is output via iValueNumber. If iManualValue exceeds the value 16, then 16 is output via iValueNumber. If iManualValue = 0, then iValueNumber = 0 and iValueOut = 0.
VAR_OUTPUT
iValueOut : INT;
bActive : BOOL;
bEdgeNewValueOut : BOOL;
iValueNumber : INT;
bError : BOOL;
eErrorCode : E_HVACErrorCodes;
iValueOut: The value of the variable iValue1-8 is output via iValueOut.
If bEnable = TRUE AND bError = FALSE AND eCtrlMode = eHVACCtrlMode_Auto AND bDirection = FALSE AND iNumberOfValues > 0 and there is a rising edge on bEdgeNewValue, then iValueNumber is incremented. If iValueNumber = 6, then iValueOut = iValue6. If iValueNumber = iNumberOfValues and there is a rising edge on bEdgeNewValue, then iValueNumber = 1 and hence iValueOut = iValue1.
If bEnable = TRUE AND bError = FALSE AND eCtrlMode = eHVACCtrlMode_Auto AND bDirection = TRUE AND iNumberOfValues = 7 and there is a rising edge on bEdgeNewValue, then iValueNumber is decremented. If iValueNumber = 5, then iValueOut = iValue5. If iValueNumber = 1 and there is a rising edge on bEdgeNewValue, then iValueNumber = iNumberOfValues(7) and hence iValueOut = iValue7.
If bEnable = TRUE AND bError = FALSE AND eCtrlMode = eHVACCtrlMode_Manual, then the value of iValueNumber is determined by iManualValue. If iManualValue = 7 then iValueNumber = 7, which then means that iValueOut = iValue7.
The start behavior of the output iValueOut is as follows: if bEnable = TRUE AND bError = FALSE AND eCtrlMode = eHVACCtrlMode_Auto AND bDirection = FALSE AND iNumberOfValues > 0, then iValueNumber = 1 and iValueOut = iValue1.
- eCtrlMode = eHVACCtrlMode_Auto AND bDirection = TRUE AND iNumberOfValues = 7, then iNumberOfValues = 7 and iValueOut = iValue7.
- eCtrlMode = eHVACCtrlMode_Manual AND iManualValue = 13, then iValueNumber = 13 and iValueOut = iValue13.
- eCtrlMode = eHVACCtrlMode_Manual AND iManualValue = 0, then iValueNumber = 0 and iValueOut = 0.
bActive: bActive goes TRUE if
1. bEnable = TRUE AND bError = FALSE AND eCtrlMode = eHVACCtrlMode_Auto.
2. bEnable = TRUE AND bError = FALSE AND eCtrlMode = eHVACCtrlMode_Manual AND iManualValue > 0.
bEdgeNewValueOut: Is TRUE for one PLC cycle if bEnable = TRUE AND bError = FALSE AND iValueNumber changes its value.
iValueNumber: The output iValueNumber always indicates the number of the variable iValueX, whose content is output in the output variable iValueOut.
If eCtrlMode = eHVACCtrlMode_Auto, the variable bDirection determines whether the output variable iValueNumber is incremented or decremented when using the input bEdgeNewValue. If bDirection = FALSE it is incremented, if bDirection = TRUE it is decremented.
If eCtrlMode = eHVACCtrlMode_Manual the value of iValueNumber is determined by iManualValue.
bError: The output signals with a TRUE that there is an error and that there is a wrong parameter on the variable iNumberOfValues. iValueOut and iValueNumber are set constantly to 0 and the Enum eErrorCode indicate the error code. The message bError does not have to be acknowledged after rectification of the error.
eErrorCode: Supplies the error number when the output bError is set. The following error can occur in this function block:
eHVACErrorCodes_InvalidParam_iNumberOfValues: There is an incorrect value on iNumberOfValues. iNumberOfValues must not fall below 1 and must not exceed 8.
![]() | To access the enum error numbers in the PLC, eErrorCode can be assigned to a variable of the data type WORD. eHVACErrorCodes_InvalidParam_iNumberOfValues = 42 |
VAR_IN_OUT
iValue1-8 : INT;
iValue1-8: The value of the output variable iValueOut is determined by the variables iValue1 to iValue8. If iValueNumber = 6, then iValueOut = iValue6.
If iNumberOfValues = 8 is, then the output iValueNumber varies between 1 and 8. The variables iValue1 to iValue8 are then taken into account for the output iValueOut if the operation mode eCtrlMode = eHVACCtrlMode_Auto (see Application).
Requirements
Development environment | required library | required function |
---|---|---|
TwinCAT 3.1 build 4022.16 or higher | Tc2_HVAC V3.3.1.0 | TF8000 | TC3 HVAC V1.0.0.0 |