FB_HVACPriority_INT_16

FB_HVACPriority_INT_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 iValueOut is controlled by the occurring events of the inputs bEvent1-16, iValue1-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 iValueOut has the value of iValue15.
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 iValueOut has the value of iValue1.

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 iValue1-16, whose value is output via iValueOut. If bEnable = TRUEANDeCtrlMode = eHVACCtrlMode_ManualAND iManualValue = 2, then iValueOut = iValue2, see Table 3.

Notice

A frequently changing variable may not be applied to the VAR_IN_OUT variables iValue1-16 if eDataSecurityType = eHVACDataSecurityType_Persistent. This would lead to premature wear of the storage medium of the controller. If the VAR_IN_OUT variables iValue1-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 iValueOut in ascending order from 1 to 16. If bEnable = TRUEANDeCtrlMode = eHVACCtrlMode_AutoANDbDirection = FALSEANDbEvent15 = TRUE (highest occurring event in column 1), then iValueOut = iValue15.

FB_HVACPriority_INT_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 iValueOut in descending order from 16 to 1. If bEnable = TRUEANDeCtrlMode = eHVACCtrlMode_AutoANDbDirection = TRUEANDbEvent1 = TRUE (lowest occurring event in Table 2 column 1), then iValueOut = iValue1.

FB_HVACPriority_INT_16 3:

Table 3: Multiplexer

Table 3

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

FB_HVACPriority_INT_16 4:

Application example

Download

Required library

tchvac.zip

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_INT_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 iValueOut 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 then the output iValueOut is controlled by the occurring events of the inputs bEvent1-16, iValue1-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 iValueOut is controlled by iManualValue. If iManualProfile = 5, then iValueOut = iValue5, see Table 3

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

bEvent1-16: the output iValueOut is controlled by the occurring events of the inputs bEvent1-16, iValue1-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 iValueOut. If bEnable = TRUEANDeCtrlMode = eHVACCtrlMode_AutoANDbDirection = FALSEANDbEvent15 = TRUE (highest event occurred in Table 1 column 1), then iValueOut = iValue15.
bDirection = TRUE means that the events in descending order from 16 to 1 determine the output value iValueOut. If bEnable = TRUEANDeCtrlMode = eHVACCtrlMode_AutoANDbDirection = TRUEANDbEvent1 = TRUE (lowest occurred event in Table 2 column 1), then iValueOut = iValue1.
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 iValueOut is controlled by the occurring events of the inputs bEvent1-16, iValue1-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 iValueOut. If bEnable = TRUEANDeCtrlMode = eHVACCtrlMode_AutoANDbDirection = FALSEANDbEvent15 = TRUE (highest event occurred in Table 1 column 1), then iValueOut = iValue15.
bDirection = TRUE means that the events in descending order from 16 to 1 determine the output value iValueOut. If bEnable = TRUEANDeCtrlMode = eHVACCtrlMode_AutoANDbDirection = TRUEANDbEvent1 = TRUE (lowest occurred event in Table 2 column 1), then iValueOut = iValue1.
The variables bEvent1-16 and bDirection are only taken into account if eCtrlMode = eHVACCtrlMode_Auto.

VAR_OUTPUT

iValueOut           : INT;
bActive             : BOOL;
bEdgeNewEvent       : BOOL;
iValueNumber        : INT;

iValueOut: 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 iValueOut is controlled by the occurring events of the inputs bEvent1-16, iValue1-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 iValueOut. If bEnable = TRUEANDeCtrlMode = eHVACCtrlMode_AutoANDbDirection = FALSEANDbEvent15 = TRUE (highest event occurred in Table 1 column 1), then iValueOut = iValue15.
bDirection = TRUE means that the events in descending order from 16 to 1 determine the output value iValueOut. If bEnable = TRUEANDeCtrlMode = eHVACCtrlMode_AutoANDbDirection = TRUEANDbEvent1 = TRUE (lowest occurring event in Table 2 column 1), then iValueOut = iValue1.

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 iValue1-16, whose value is output via iValueOut. If bEnable = TRUEANDeCtrlMode = eHVACCtrlMode_ManualAND iManualValue = 2, then iValueOut = iValue2, 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 iValueOut using iValue1-16.

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

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

VAR_IN_OUT

Name              : Type        Persistent
iValue1-16        : INT;        X            

iValue1-16: the value of the output variable iValueOut is determined by the variables iValue1 to iValue16. iValueOut = iValueX

If the function block is used to prioritize events, each of the variables iValue1-16 is assigned to an event. iValue1 is assigned to the event bEvent1, iValue2 to the event bEvent2, iValue3 to the event bEvent3,..., iValue16 to the event bEvent16

If the function block is used as a multiplexer, then each of the variables iValue1-16 is assigned to the value of iManualValue. If iManualValue = 1, then iValueOut = iValue1. If iManualValue = 2, then iValueOut = iValue2.... If iManualValue = 16, then iValueOut = iValue16.

The variable is saved persistently.