FB_BA_MultiCalc_XX
Multi-calculation function blocks exist for different variable types (LREAL, REAL, INT, UINT and UDINT) and in different input parameters (4 and 8), but they all have the same functionality.
The function block FB_BA_UDI08 is described as an example.
Functional description
In activate state (bEn=TRUE), the function block determines the following from the 8 input values udi01...udi08:
- the maximum value of all inputs udiMax
- the input at which this maximum value is applied udiMinActv
- the minimum value of all inputs udiMin
- the input at which this minimum value is applied udiMinActv
- the average of all inputs rAvrg
- the sum of all inputs rSum
- the difference between the maximum and minimum value udiDiff
If not all inputs are to be calculated, the number can be limited by an entry at udiNum: with udiNum=6, for example, the calculations are only performed for the inputs udi01...udi06.
An entry greater than 8 is automatically limited to 8, an entry less than 1 is automatically limited to 1.
Example:
Inputs | Output |
---|---|
bEn = TRUE | udiMax = 32 |
udi01 = 32 | udiMaxActv = 1 |
udi02 = 17 | udiMin = 5 |
udi03 = 5 | udiMinActv = 3 |
udi04 = 9 | rAvrg = 18.5 |
udi05 = 16 | rSum = 111 |
udi06 = 32 | udiDiff = 27 |
udi07 = 25 |
|
udi08 = 44 |
|
udiNum = 6 |
|
If bEn = FALSE, 0 is output at all outputs.
Inputs/outputs
VAR_INPUT
bEn : BOOL;
udi01 : UDINT;
udi02 : UDINT;
udi03 : UDINT;
udi04 : UDINT;
udi05 : UDINT;
udi06 : UDINT;
udi07 : UDINT;
udi08 : UDINT;
udiNum : UDINT;
bEn: activation of the block function
udi01...udi08: input values from which to calculate.
udiNum: number of input values to be used for the calculation.
VAR_OUTPUT
udiMax : UDINT;
udiMaxActv : UDINT;
udiMin : UDINT;
udiMinActv : UDINT;
rAvrg : REAL;
rSum : REAL;
udiDiff : UDINT;
udiMax: maximum value of all inputs
udiMaxActv: input to which the maximum value is applied.
udiMin: minimum value of all inputs
udiMinActv: input to which the minimum value is applied
rAvrg: average of all inputs
rSum: sum of all inputs
udiDiff: difference between the maximum and minimum value
Requirements
Development environment | Target system | required library | required supplement |
---|---|---|---|
TwinCAT 2.11 R3/x64 | PC/CX | TcBA library from V1.0.0 | TS8040 | TwinCAT Building Automation from V1.0.0 |