FB_BA_ShdObjEntry

FB_BA_ShdObjEntry 1:

The function block FB_BA_ShdObjEntry serves for the administration of all shading elements in a facade, which are globally saved in a list of shading elements. It is intended to facilitate the input of the element information - also with regard to the use of the visualization. A schematic representation of the objects with description of the coordinates is shown in Shading correction: principles and definitions.

The shading elements are declared in the global variables:

VAR_GLOBAL
     arrShdObj : ARRAY[1..BA_Param.nSunPrt.nMaxShdObj] OF ST_BA_ShdObj;
END_VAR

Each individual element aShdObj[1] to aShdObj [nMaxShdObj] carries the information for one shading element (ST_BA_ShdObj). This information consists of the selected type of shading (rectangle or sphere) and the respectively associated coordinates. For a rectangle, these are the corner points (fP1x, fP1y, fP1z), (fP2x, fP2y, fP2z), (fP3x, fP3y, fP3z) and (fP4x, fP4y, fP4z) for a sphere this are the center point (fMx, fMy, fMz) and the radius fRads. In addition, the phase of the shading can be defined via the inputs nBegMth and nEndMth, which is important in the case of objects such as trees that bear no foliage in winter.

The function block thereby directly accesses the field of this information via the IN-OUT variable aShdObj.

Note: The fact that the rectangle coordinates fP2x, fP2z, fP4x, fP4y and fP4z are output values results from the fact that they are formed from the input parameters:

fP2x = fP1x; fP2z = fP1z; fP4x = fP3x; fP4y = fP1y; fP4z = fP3z;

That limits the input of a rectangle to the extent that the lateral edges stand vertically on the floor (fP2x = fP1x and fP4x = fP3x), that the rectangle has no inclination (fP2z = fP1z and fP4z = fP3z) and can only have a different height "upwards", i.e. in the positive y-direction (fP4y = fP1y).

The function block is used in three steps:

Read

Selection of the element from the list aShdObj[nId] is based on the entry at nId. A rising edge on bRd reads the data. These values are assigned to the input and output variables of the function block. These are the input values fP1x, fP1y, fP1z, fP2y, fP3x, fP3y, fP3z, fMx, fMy, fMz, fRads, the object enumerator eType and the output values fP2x, fP2z, fP4x, fP4y and fP4z. 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. If a rectangle is preselected at input eType via the value "eObjectTypeTetragon", the output values fP2x, fP2z, fP4x, fP4y, and fP4z result from the rectangle coordinates that were entered (see above).

The values entered are constantly checked for plausibility. The output bErr indicates whether the values are valid (bErr=FALSE). If the value is invalid, a corresponding error message is output at output sErrDescr .
If a rectangle is defined, only the inputs fP1x, fP1y, fP1z, fP2y, fP3x, fP3y and fP3z must be written to, the inputs fMx, fMy, fMz and fRads need not be linked. For a sphere definition, only fMx, fMy, fMz and fRads have to be described; the rectangle coordinates can remain unlinked

Write

The parameterized data are written to the list element with the index niId upon a positive edge on bWrt , regardless of whether they represent valid values or not. The element structure ST_BA_ShdObj therefore 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 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.

FB_BA_ShdObjEntry 2: Inputs

VAR_INPUT
  nId         : UDINT;
  bRd         : BOOL;
  bWrt        : BOOL;
  fP1x        : REAL;
  fP1y        : REAL;
  fP1z        : REAL;
  fP2y        : REAL;
  fP3x        : REAL;
  fP3y        : REAL;
  fP3z        : REAL;
  fMx         : REAL;
  fMy         : REAL;
  fMz         : REAL;
  fRads       : REAL;
  nBegMth     : UDINT;
  nEndMth     : UDINT;
  eType       : E_BA_ShdObjType;
END_VAR

Name

Type

Description

nId

UDINT

Index of the selected element. This refers to the selection of a field element of the array stored in the IN-OUT variable aShdObj. The variable nId must not be zero! This is due to the field definition, which starts with 1. However, an incorrect input is recognized and displayed as such at bErr/sErrDescr.

bRd

BOOL

The information of the selected element, aShdObj[nId], is read into the function block with a positive edge at this input and assigned to the input variables fP1x to eType and the output variables fP2x to fP4z. If at this time data have already been applied to the inputs fP1x to eType, the previously read data are immediately overwritten with these.

bWrt

BOOL

A positive edge writes the values applied to inputs fP1x to eType and the values determined and assigned to outputs fP2x to fP4z to the selected field element aShdObj[nId].

fP1x

REAL

X-coordinate of point 1 of the shading element (rectangle) [m].

fP1y

REAL

Y-coordinate of point 1 of the shading element (rectangle) [m].

fP1z

REAL

Z-coordinate of point 1 of the shading element (rectangle) [m].

fP2y

REAL

Y-coordinate of point 2 of the shading element (rectangle) [m].

fP3x

REAL

X-coordinate of point 3 of the shading element (rectangle) [m].

fP3y

REAL

Y-coordinate of point 3 of the shading element (rectangle) [m].

fP3z

REAL

Z-coordinate of point 3 of the shading element (rectangle) [m].

fMx

REAL

X-coordinate of the center of the shading element (ball) [m].

fMy

REAL

Y-coordinate of the center of the shading element (ball) [m].

fMz

REAL

Z-coordinate of the center of the shading element (ball) [m].

fRads

REAL

Radius of the shading element (ball) [m].

nBegMth

UDINT

Beginning of the shading period (month).

nEndMth

UDINT

End of the shading period (month).

eType

E_BA_ShdObjType

Selected element type: rectangle or sphere.

Remark about the shading period:

The month entries must not be 0 and not be greater than 12, all other combinations are possible.
Examples:
Start=1, End=1: shading in January.
Start=1, End=5: shading from the beginning of January to the end of May.
Start=11, End=5: shading from the beginning of November to the end of May (of the following year).

FB_BA_ShdObjEntry 3: / FB_BA_ShdObjEntry 4: Inputs/Outputs

VAR_IN_OUT
  aShdObj: ARRAY[1..BA_Param.nSunPrt_MaxShdObj] OF ST_BA_ShdObj;
END_VAR

Name

Type

Description

aShdObj

ARRAY OF ST_BA_ShdObj

List of shading objects

FB_BA_ShdObjEntry 5: Outputs

VAR_OUTPUT
  fP2x       : REAL;
  fP2z       : REAL;
  fP4x       : REAL;
  fP4y       : REAL;
  fP4z       : REAL;
  bErr       : BOOL;
  sErrDescr  : T_MAXSTRING;
END_VAR

Name

Type

Description

fP2x

REAL

Determined X-coordinate of point 2 of the shading element (rectangle) [m] (see "Note" above).

fP2Z

REAL

Determined Z-coordinate of point 2 of the shading element (rectangle) [m] (see "Note" above)

fP4x

REAL

Determined X-coordinate of point 4 of the shading element (rectangle) [m] (see "Note" above).

fP4y

REAL

Determined Y-coordinate of point 4 of the shading element (rectangle) [m] (see "Note" above).

fP4z

REAL

Determined Z-coordinate of point 4 of the shading element (rectangle) [m] (see "Note" above).

bErr

BOOL

Contains the error description.

sErrDescr

T_MAXSTRING

Contains the error description.

Error description

01: Error: The input nId is outside the permissible limits 1...nMaxShdObj.

02 Error: The sum of the angles of the rectangle is not 360°. This means that the corners are not in the order P1, P2, P3 and P4 but rather P1, P3, P2 and P4. This results in a crossed-over rectangle.

03: Error: The corners of the rectangle are not in the same plane.

04: Error: The z-component of P1 is less than zero. This corner would thus lie behind the facade.

05: Error: The z-component of P3 is less than zero. This corner would thus lie behind the facade.

06: Error: P1 is equal to P2. The object entered is thus not a rectangle.

07: Error: P1 is equal to P3. The object entered is thus not a rectangle.

08: Error: P1 is equal to P4. The object entered is thus not a rectangle.

09: Error: P2 is equal to P3. The object entered is thus not a rectangle.

10: Error: P2 is equal to P4. The object entered is thus not a rectangle.

11: Error: P3 is equal to P4. The object entered is thus not a rectangle.

12: Error: The radius entered is zero.

13: Error: The z-component of the ball center is less than zero. This point would thus lie behind the facade.

14: Error: Error object type eType - neither rectangle nor ball.

15: Error: Month input error.

Requirements

Development environment

Required PLC library

TwinCAT from v3.1.4024.22

Tc3_BA2 from v5.2.5.0