FB_BA_FcdElemEntry
The function block FB_BA_FcdElemEntry is used to manage all facade elements (windows) of a facade, which is globally stored in a List of facade elements. It is intended to facilitate inputting element information - not least with regard to using the TC3 PLC HMI. A schematic representation of the objects with description of the coordinates is shown 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
aFcdElem : ARRAY[1..Param.nSunPrt_MaxColumnFcd, 1..Param.nSunPrt_MaxRowFcd] OF ST_BA_FcdElem;
END_VAR
Each individual element arrFcdElem[x,y] carries the information for one facade element (ST_BA_FcdElem). The information includes the group assignment, the dimensions (width, height) and the coordinates of the corners. The function block thereby accesses this field directly via the IN-OUT variable aFcdElem.
Note: The fact that the coordinates of corners C2 to C4 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:
All data in [m]!
fCnr2X = fCnr1X
fCnr2Y = fCnr1Y + fWdwHght (window height)
fCnr3X = fCnr1X + fWdwWdth (window width)
fCnr3Y = fCnr2Y
fCnr4X = fCnr1X + fWdwWdth (window width)
fCnr4Y = fCnr1Y
The function block is used in three steps:
- Read
- Change
- Write
Read
With the entries at nColumn and nRow the corresponding element is selected from the list, aFcdElem[nColumn, nRow]. A rising edge on bRd reads the following data from the list element:
- nGrp group membership,
- fCnr1X x-coordinate of corner point 1 [m]
- fCnr1Y y-coordinate of corner point 1 [m]
- fWdwWdth window width [m]
- fWdwHght window height [m]
These are then assigned to the corresponding input variables of the function block, which uses them to calculate the coordinates of corners C2-C4 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 visualization.
Change
In a next program step the listed input values can then be changed. The values entered are constantly checked for plausibility. The output bErr indicates whether the values are valid (bErr=FALSE). If the values are invalid, a corresponding error message is issued at output sErrDescr. See also "Error (bErr=TRUE)" below.
Write
With a positive edge at bWrt the parameterized data are written into the field of the array aFcdElem dependent on nRow and nColumn, regardless of whether they represent valid values or not. The element structure ST_BA_FcdElem therefore also contains a plausibility bit bVld, which forwards precisely this information to the function block FB_BA_ShdCorr to prevent miscalculations.
This approach is to be regarded only as a proposal. It is naturally also possible to parameterize the function block quite normally in one step and to write the values entered to the corresponding list element with a rising edge on bWrt.
Error (bErr=TRUE)
The function block FB_BA_ShdCorr, which assesses 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:
- nGrp must be greater than 0
- fCnr1X must be greater than or equal to 0.0
- fCnr1Y must be greater than or equal to 0.0
- fWdwWdth must be greater than 0
- fWdwHght must be greater than 0
If one of these criteria is not met, it is interpreted as incorrect input, and the error output bErr is set at the function block output of FB_BA_FcdElemEntry. Within the window element ST_BA_FcdElem the plausibility bit bVld is set to FALSE.
If, on the other hand, all entries of a facade element are zero, it is regarded as a valid, intentionally omitted facade element:
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.
Inputs
VAR_INPUT
nColumn : UDINT;
nRow : UDINT;
bWrt : BOOL;
bRd : BOOL;
nGrp : UDINT;
fCnr1X : REAL;
fCnr1Y : REAL;
fWdwWdth : REAL;
fWdwHght : REAL;
END_VAR
Name | Type | Description |
---|---|---|
nColumn
| UDINT | 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 aFcdElem. |
nRow | UDINT | ditto row index. nRow and nColumn must not be zero! This is due to the field definition, which always starts with 1; see above. |
bRd | BOOL | With a positive edge at this input, the information of the selected element, aFcdElem[nColumn, nRow] is read into the function block and assigned to the input variables nGrp to fWdwHght. The resulting output variables are fCnr2X to fCnr4Y. If data are already present on the inputs nGrp to fWdwHght at time of reading, then the data previously read are immediately overwritten with these data. |
bWrt | BOOL | A positive edge writes the entered as well as calculated values into the selected field element aFcdElem[nColumn, nRow]. |
nGrp | UDINT | Group membership. Internally limited to a minimum value of 0. |
fCnr1X | REAL | X-coordinate of corner point 1 [m] |
fCnr1Y | REAL | Y-coordinate of corner point 1 [m] |
fWdwWdth | REAL | Window width [m] |
fWdwHght | REAL | Window height [m] |
Outputs
VAR_OUTPUT
fCnr2X : REAL;
fCnr2Y : REAL;
fCnr3X : REAL;
fCnr3Y : REAL;
fCnr4X : REAL;
fCnr4Y : REAL;
bErr : BOOL;
sErrDesc : T_MAXSTRING;
END_VAR
Name | Type | Description |
---|---|---|
fCnr2X | REAL | X-coordinate determined for corner point 2 of the window [m] (see function description) |
fCnr2Y | REAL | Y-coordinate determined for corner point 2 of the window [m] (see function description) |
fCnr3X | REAL | X-coordinate determined for corner point 3 of the window [m] (see function description) |
fCnr2Y | REAL | Y-coordinate determined for corner point 3 of the window [m] (see function description) |
fCnr4X | REAL | X-coordinate determined for corner point 4 of the window [m] (see function description) |
fCnr2Y | REAL | Y-coordinate determined for corner point 4 of the window [m] (see function description) |
bErr | BOOL | In case of a fault, e.g. if warning stages are active, this output is set to TRUE. |
sErrDescr | T_MAXSTRING | Contains the error description. |
Error description |
---|
01: Error: Index error! nColumn and/or nRow are outside the permissible limits 1... nSunPrt_MaxColumnFcd or 1... nSunPrt_MaxRowFcd. See list of facade elements. |
02: Error: The group index is 0, but at the same time another entry of the facade element is not zero. Only if all entries of a facade element are zero is it considered to be a valid, deliberately omitted facade component, otherwise it is interpreted as an incorrect entry. Note: Group entries less than zero are internally limited to zero. |
03: Error: The X-component of the first corner point (Corner1) is less than zero. |
04: Error: The Y-component of the first corner point (Corner1) is less than zero. |
05: Error: The window width is less than or equal to zero. |
06: Error: The window height is less than or equal to zero. |
/ Inputs/Outputs
VAR_IN_OUT
aFcdElem : ARRAY[1..Param.nSunPrt_MaxColumnFcd, 1..Param.nSunPrt_MaxRowFcd] OF ST_BA_FcdElem;
END_VAR
Name | Type | Description |
---|---|---|
aFcdElem | ARRAY OF ST_BA_FcdElem |
Requirements
Development environment | Required PLC library |
---|---|
TwinCAT from v3.1.4024.22 | Tc3_BA2 from v5.2.5.0 |