FB_BARFacadeElementEntry

FB_BARFacadeElementEntry 1:

This function block serves the administration of all facade elements (windows) in a facade, which are saved globally in a list of facade elements. It is intended to facilitate the input of the element information - also with regard to the use of the target visualization. A schematic illustration of the objects with description of the coordinates is given in Shading correction: principles and definitions.
The facade elements are declared in the global variables as a two-dimensional field above the window columns and rows:

VAR_GLOBAL
    arrFacadeElement : ARRAY[1..iColumnsPerFacade, 1..iRowsPerFacade] OF ST_BARFacadeElement;
END_VAR

Each individual element arrFacadeElement carries the information for one facade element (ST_BARFacadeElement). The information includes the group affiliation, the dimensions (width, height) and the coordinates of the corners. The function block thereby accesses this field directly via the IN-OUT variable arrFacadeElement.

Note: The fact that the coordinates of corners 2 to 4 are output values arises from the fact that they are formed from the input parameters and are to be available for use in a visualization:

FB_BARFacadeElementEntry 2:

All data in meters!

lrCorner2X = lrCorner1X
lrCorner2Y = lrCorner1Y + lrWindowHeight (window height)
lrCorner3X = lrCorner1X + lrWindowWidth (window width)
lrCorner3Y = lrCorner2Y
lrCorner4X = lrCorner1X + lrWindowWidth (window width)
lrCorner4Y = lrCorner1Y

The function block is used in three steps:

Read

With the entries in iColumn and iRow the corresponding element is selected from the list arrFacadeElement[iColumn,iRow]. A rising edge on bRead reads the following data from the list element:

  • usiGroup Group membership,
  • lrCorner1X X-coordinate of corner 1 in metres
  • lrCorner1Y Y-coordinate of corner 1 in metres
  • lrWindowWidth Window width in metres
  • lrWindowHeight Window height in metres

These are then assigned to the corresponding input variables of the block, which uses them to calculate the coordinates of corners 2-4 as output variables in accordance with the correlation described above. It is important here that the input values are not overwritten in the reading step. Hence, all values can initially be displayed in a visualisation.

Change

In a next program step the listed input values can then be changed. The values entered are constantly checked for plausibility. The output bValid indicates whether the values are valid (bValid=TRUE). If this is not the case, a corresponding error code is output at the output udiErrorId. See also below "Errors (bValid=FALSE)".

Write

The parameterised data are written to the list element with the index nId upon a rising edge on bWrite, regardless of whether they represent valid values or not. Therefore the element structure ST_BARFacadeElement also contains a plausibility bit, bValue, that relays precisely this information to the function block FB_BARShadingCorrection / FB_BARShadingCorrectionSouth and prevents incorrect calculations there.

Error (bValid=FALSE)

The function block FB_BARShadingCorrection / FB_BARShadingCorrectionSouth, which judges whether all windows in a group are shaded, will only perform its task if all windows in the examined group have valid entries.
This means:

  • usiGroup must be greater than 0
  • lrCorner1X must be greater than or equal to 0.0
  • lrCorner1Y must be greater than or equal to 0.0
  • lrWindowWidth must be greater than 0
  • lrWindowHeight must be greater than 0

If one of these criteria is not fulfilled, then this is interpreted as an incorrect input and bValid is set to FALSE at the block output of FB_BARFacadeElementEntry as well as in the window element ST_BARFacadeElement.
If on the other hand all entries of a facade element are zero, it is regarded as a valid, deliberately omitted facade element:

FB_BARFacadeElementEntry 3:

In the case of a facade of 6x4 windows, the elements window (2,1), window (3,5) and window (4,4) would be empty elements here.

VAR_INPUT

eDataSecurityType  : E_HVACDataSecurityType;
iColumn            : INT;
iRow               : INT;
bWrite             : BOOL;
bRead              : BOOL;
usiGroup           : USINT;
lrCorner1X         : LREAL;
lrCorner1Y         : LREAL;
lrWindowWidth      : LREAL;
lrWindowHeight     : LREAL;

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.

iColumn: Column index of the selected component on the facade. This refers to the selection of a field element of the array stored in the IN-OUT variable arrFacadeElement.

iRow: dto. Row index. iRow and iColumn may not be zero! This arises from the field definition, see above.

bRead: With a positive edge on this input, the information from the selected element arrFacadeElement [iColumn,iRow] is read into the function block and assigned to the input variables usiGroup to rWindowHeight. This gives rise to the output variables rCorner2X to rCorner4Y. If data are already present on the inputs usiGroup to rWindowHeight at time of reading, then the data previously read are immediately overwritten with these data.

bWrite: A rising edge writes both the entered values and the calculated values into the selected field element arrFacadeElement [iColumn,iRow].

usiGroup: Group membership,

lrCorner1X: X-coordinate of corner point 1 in meters.

lrCorner1Y: Y-coordinate of corner point 1 in meters.

lrWindowWidth: Window width in meters.

lrWindowHeight: Window height in meters.

VAR_OUTPUT

lrCorner2X : LREAL;
lrCorner2Y : LREAL;
lrCorner3X : LREAL;
lrCorner3Y : LREAL;
lrCorner4X : LREAL;
lrCorner4Y : LREAL;
bValid     : BOOL;
udiErrorId : UDINT;

lrCorner2X: determined X-coordinate of corner 2 of the window in metres. See "Note" above.

lrCorner2Y: determined Y-coordinate of corner 2 of the window in metres. See "Note" above.

lrCorner3X: determined X-coordinate of corner 3 of the window in metres. See "Note" above.

lrCorner3Y: determined Y-coordinate of corner 3 of the window in metres. See "Note" above.

lrCorner4X: determined X-coordinate of corner 4 of the window in metres. See "Note" above.

lrCorner4Y: determined Y-coordinate of corner 4 of the window in metres. See "Note" above.

bValid: result check for the entered values.

udiErrorId: contains the error code if the values entered are not OK. See Error codes.

VAR_IN_OUT

arrFacadeElement : ARRAY[1..iColumnsPerFacade, 1..iRowsPerFacade] OF ST_BARFacadeElement;

arrFacadeElement: List of facade elements.

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