FB_HVACPriority_REAL_16

FB_HVACPriority_REAL_16 1:

Application

This function block can be used to prioritize events or as a multiplexer. This selection is made with the help of the Enum eCtrlMode.

The function block can be used to prioritize events if eCtrlMode = eHVACCtrlMode_Auto. The output rValueOut is controlled by the occurring events of the inputs bEvent1-16, rValue1-16 and the control direction of the prioritization bDirection.
bDirection
= FALSE means that the events in ascending order from 1 to 16 have a higher priority. If bEnable = TRUEANDeCtrlMode = eHVACCtrlMode_AutoANDbDirection = FALSEANDbEvent15 = TRUE (highest occurred event in Table 1 column 1), then rValueOut has the value of rValue15.
bDirection = TRUE means that the events in descending order from 16 to 1 have a higher priority. If bEnable = TRUEANDeCtrlMode = eHVACCtrlMode_AutoANDbDirection = TRUEANDbEvent1 = TRUE (lowest occurring event in Table 2 column 1), then rValueOut has the value of rValue1.

The function block can be used as a multiplexer if eCtrlMode = eHVACCtrlMode_Manual. The value of iManualValue refers to one of the VAR_IN_OUT variables rValue1-16, whose value is output via rValueOut. If bEnable = TRUEANDeCtrlMode = eHVACCtrlMode_ManualAND iManualValue = 2, then rValueOut = rValue2, see Table 3.

Notice

A frequently changing variable may not be applied to the VAR_IN_OUT variables rValue1-16 if eDataSecurityType = eHVACDataSecurityType_Persistent. This would lead to premature wear of the storage medium of the controller. If the VAR_IN_OUT variables rValue1-16 change frequently and are not to be stored persistently, then eDataSecurityType must be eDataSecurityType_Idle.

Table 1: Prioritization of events in ascending order from 1 to 16

Table 1

It can be seen in Table 1 that bDirection = FALSE. This means that the events determine the output value rValueOut in ascending order from 1 to 16. If bEnable = TRUEANDeCtrlMode = eHVACCtrlMode_AutoANDbDirection = FALSEANDbEvent15 = TRUE (highest occurring event in column 1), then rValueOut = rValue15.

FB_HVACPriority_REAL_16 2:

Table 2: Prioritization of events in descending order from 16 to 1

Table 2

It can be seen in Table 2 that bDirection = TRUE. This means that the events determine the output value rValueOut in descending order from 16 to 1. If bEnable = TRUEANDeCtrlMode = eHVACCtrlMode_AutoANDbDirection = TRUEANDbEvent1 = TRUE (lowest occurring event in Table 2 column 1), then rValueOut = rValue1.

FB_HVACPriority_REAL_16 3:

Table 3: Multiplexer

Table 3

If bEnable = TRUEANDeCtrlMode = eHVACCtrlMode_ManualANDiManualValue = 2, then rValueOut = 2.

FB_HVACPriority_REAL_16 4:

Application example

Download

Required library

TcHVAC.pro

TcHVAC.lib

VAR_INPUT

eDataSecurityType : E_HVACDataSecurityType;
bEnable           : BOOL;
bEvent1 - bEvent8 : BOOL;
eCtrlMode         : E_HVACCtrlMode;
iManualValue      : INT;             0..16
bDirection        : 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_HVACPriority_REAL_16 5: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 is set constantly to 0.

eCtrlMode: the operation mode of the function block is specified by means of the enum.
If eCtrlMode = eHVACCtrlMode_Auto, the function block represents a prioritization of events. If bEnable = TRUEANDeCtrlMode = eHVACCtrlMode_Auto the output rValueOut is controlled by the events of the inputs bEvent1-16, rValue1-16 and the control direction of the prioritization bDirection, see Table 1 and Table 2
If eCtrlMode = eHVACCtrlMode_Manual, the function block represents a multiplexer. If bEnable = TRUEANDeCtrlMode = eHVACCtrlMode_Manual, then the value of output rValueOut is controlled by iManualValue. If iManualProfile = 5, then rValueOut = rValue5, see Table 3

iManualProfile: if the operation mode eCtrlMode = eHVACCtrlMode_Manual (multiplexer) ANDbEnable = TRUEANDbError = FALSE, then the value of the output rValueOut is controlled by iManualValue. If iManualProfile = 5, then rValueOut = rValue5, see Table 3

bEvent1-16: the output rValueOut is controlled by the occurring events of the inputs bEvent1-16, rValue1-16 and the control direction of the prioritization bDirection.
bDirection
= FALSE means that the events in ascending order from 1 to 16 determine the output value rValueOut. If bEnable = TRUEANDeCtrlMode = eHVACCtrlMode_AutoANDbDirection = FALSEANDbEvent15 = TRUE (highest event occurred in Table 1 column 1), then rValueOut = rValue15.
bDirection = TRUE means that the events in descending order from 16 to 1 determine the output value rValueOut. If bEnable = TRUEANDeCtrlMode = eHVACCtrlMode_AutoANDbDirection = TRUEANDbEvent1 = TRUE (lowest occurred event in Table 2 column 1), then rValueOut = rValue1.
The variables bEvent1-16 and bDirection are only taken into account if eCtrlMode = eHVACCtrlMode_Auto.

bDirection: the function block can be used to prioritize events if eCtrlMode = eHVACCtrlMode_Auto. The output rValueOut is controlled by the occurring events of the inputs bEvent1-16, rValue1-16 and the control direction of the prioritization bDirection.
bDirection
= FALSE means that the events in ascending order from 1 to 16 determine the output value rValueOut. If bEnable = TRUEANDeCtrlMode = eHVACCtrlMode_AutoANDbDirection = FALSEANDbEvent15 = TRUE (highest event occurred in Table 1 column 1), then rValueOut = rValue15.
bDirection = TRUE means that the events in descending order from 16 to 1 determine the output value rValueOut. If bEnable = TRUEANDeCtrlMode = eHVACCtrlMode_AutoANDbDirection = TRUEANDbEvent1 = TRUE (lowest occurred event in Table 2 column 1), then rValueOut = rValue1.
The variables bEvent1-16 and bDirection are only taken into account if eCtrlMode = eHVACCtrlMode_Auto.

VAR_OUTPUT

rValueOut           : REAL;
bActive             : BOOL;
bEdgeNewEvent       : BOOL;
iValueOut           : INT;

rValueOut: this function block can be used to prioritize events or as a multiplexer. This selection is made with the help of the Enum eCtrlMode.

The function block can be used to prioritize events if eCtrlMode = eHVACCtrlMode_Auto. The output rValueOut is controlled by the occurring events of the inputs bEvent1-16, rValue1-16 and the control direction of the prioritization bDirection.
bDirection
= FALSE means that the events in ascending order from 1 to 16 determine the output value rValueOut. If bEnable = TRUEANDeCtrlMode = eHVACCtrlMode_AutoANDbDirection = FALSEANDbEvent15 = TRUE (highest event occurred in Table 1 column 1), then rValueOut = rValue15.
bDirection = TRUE means that the events in descending order from 16 to 1 determine the output value rValueOut. If bEnable = TRUEANDeCtrlMode = eHVACCtrlMode_AutoANDbDirection = TRUEANDbEvent1 = TRUE (lowest occurring event in Table 2 column 1), then rValueOut = rValue1.

The function block can be used as a multiplexer if eCtrlMode = eHVACCtrlMode_Manual. The value of iManualValue refers to one of the VAR_IN_OUT variables rValue1-16, whose value is output via rValueOut. If bEnable = TRUEANDeCtrlMode = eHVACCtrlMode_ManualAND iManualValue = 2, then rValueOut = rValue2, see Table 3.

bActive: bActive becomes TRUE , if

1. bEnable = TRUEANDeCtrlMode = eHVACCtrlMode_Auto and one of the input variables bEvent1-16 = TRUE.

2. bEnable = TRUEANDeCtrlMode = eHVACCtrlMode_ManualANDiManualValue > 0

bEdgeNewEvent: is TRUE for one PLC cycle if

1. bEnable = TRUEANDeCtrlMode = eHVACCtrlMode_Auto and the decisive event (bEvent1-16) has changed to control the output rValueOut using rValue1-16.

2. bEnable = TRUEANDeCtrlMode = eHVACCtrlMode_Manual and with each change of iManualValue

iValueNumber: the variable iValueNumber indicates the variable from which the value on rValueOut is output. If rValueOut = rValue7, then iValueNumber = 7, see Table 1, Table 2 and Table 3

VAR_IN_OUT

rValue1-16        : REAL;            

rValue1-16: the value of the output variable rValueOut is determined by the variables rValue1 to rValue16. rValueOut = rValueX

If the function block is used to prioritize events, each of the variables rValue1-16 is assigned to an event. rValue1 is assigned to the event bEvent1, rValue2 to the event bEvent2, rValue3 to the event bEvent3,..., rValue16 to the event bEvent16

If the function block is used as a multiplexer, then each of the variables rValue1-16 is assigned to the value of iManualValue. If iManualValue = 1, then rValueOut = rValue1. If iManualValue = 2, then rValueOut = rValue2.... If iManualValue = 16, then rValueOut = rValue16.

The variable is saved persistently.