FB_HVACMUX_REAL_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 rValueOut = iValue4. If iValueNumber= iNumberOfValues(7) and there is a rising edge on bEdgeNewValue, then iValueNumber = 1 and hence rValueOut = rValue1.
- If bDirection = TRUE AND iNumberOfValues = 8 and there is a rising edge on bEdgeNewValue, then iValueNumber is decremented. If iValueNumber = 3, then rValueOut = rValue3. If iValueNumber= 1 and there is a rising edge on bEdgeNewValue, then iValueNumber = iNumberOfValues(8) and hence rValueOut = rValue8.
The start behavior of the outputs iValueNumber and rValueOut is as follows:
- If bDirection = FALSE AND iNumberOfValues > 0, then iValueNumber = 1 and rValueOut = rValue1.
- If bDirection = TRUE AND iNumberOfValues = 6, then iNumberOfValues = 6 and rValueOut = rValue6.
Examples of eCtrlMode = eHVACCtrlMode_Manual
- The value of iValueNumber is determined by iManualValue. If iManualValue = 7 then iValueNumber = 7, which then means that rValueOut = rValue7.
The start behavior of the outputs iValueNumber and rValueOut is as follows:
- If iManualValue = 13, then iValueNumber = 13 and rValueOut = rValue13.
- If iManualValue = 0, then iValueNumber = 0 and rValueOut = 0.
Notice | |
A frequently changing variable may not be applied to the VAR_IN_OUT variables rValue1-n if eDataSecurityType = eHVACDataSecurityType_Persistent. This would lead to premature wear of the storage medium of the controller. If the VAR_IN_OUT variables rValue1-n 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 rValueOut and iValueNumber are set constantly to 0.
iNumberOfValues: Indicates the number of variables rValue1-8 that can be output via rValueOut. If iNumberOfValues = 8 is, then the output iValueNumber varies between 1 and 8. The variables rValue1 to rValue8 are then taken into account for the output rValueOut (see Application).
iNumberOfValues determines the start behavior of the outputs rValueOut 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 rValueOut = rValue6. If iValueNumber= iNumberOfValues and there is a rising edge on bEdgeNewValue, then iValueNumber = 1 and hence rValueOut = rValue1.
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 rValueOut = rValue5. If iValueNumber= 1 and there is a rising edge on bEdgeNewValue, then iValueNumber = iNumberOfValues(6) and hence rValueOut = rValue6.
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 rValueOut (see Application).
bDirection = TRUE means that iValueNumber decrements from iNumberOfValues to 1 in descending form and thus determines the output value rValueOut (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 rValue15 are then output via rValueOut (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 rValueOut = 0.
VAR_OUTPUT
rValueOut : INT;
bActive : BOOL;
bEdgeNewValueOut : BOOL;
iValueNumber : INT;
bError : BOOL;
eErrorCode : E_HVACErrorCodes;
rValueOut: The value of the variable rValue1-8 is output via rValueOut.
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 rValueOut = rValue6. If iValueNumber= iNumberOfValues and there is a rising edge on bEdgeNewValue, then iValueNumber = 1 and hence rValueOut = rValue1.
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 rValueOut = rValue5. If iValueNumber= 1 and there is a rising edge on bEdgeNewValue, then iValueNumber = iNumberOfValues(7) and hence rValueOut = rValue7.
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 rValueOut = rValue7.
The start behavior of the output rValueOut is as follows: if bEnable = TRUE AND bError = FALSE AND eCtrlMode = eHVACCtrlMode_Auto AND bDirection = FALSE AND iNumberOfValues > 0, then iValueNumber = 1 and rValueOut = rValue1.
- eCtrlMode = eHVACCtrlMode_Auto AND bDirection = TRUE AND iNumberOfValues = 7, then iNumberOfValues = 7 and rValueOut = rValue7.
- eCtrlMode = eHVACCtrlMode_Manual AND iManualValue = 13, then iValueNumber = 13 and rValueOut = rValue13.
- eCtrlMode = eHVACCtrlMode_Manual AND iManualValue = 0, then iValueNumber = 0 and rValueOut = 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 rValueX, whose content is output in the output variable rValueOut.
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. rValueOut 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
rValue1-8 : INT;
rValue1-8: The value of the output variable rValueOut is determined by the variables rValue1 to rValue8. If iValueNumber = 6, then rValueOut = iValue6.
If iNumberOfValues = 8 is, then the output iValueNumber varies between 1 and 8. The variables rValue1 to rValue8 are then taken into account for the output rValueOut if the operation mode eCtrlMode = eHVACCtrlMode_Auto (see Application). The variable is saved persistently.
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 |