FB_BA_MultiCalc_XX

FB_BA_MultiCalc_XX 1:

The multi-calculation function blocks exist for the variable types LREAL and REAL, although they all have the same functionality.
The function block FB_BA_R08 is described as an example.

In enabled state (bEn=TRUE), the function block determines the following from the 8 input values r01...r08:

If not all inputs are used for the calculation, the number can be limited via an entry at udiNum: udiNum=6, for example, can be used to limit the calculations to inputs r01 to r06.
Any entry greater than 8 is automatically limited to 8, any entry less than 1 is automatically set to 1.

Sample:

Inputs

Output

bEn = TRUE

rMax = 32

r01 = 32

udiMaxActv = 1

r02 = 17

rMin = 5

r03 = 5

udiMinActv = 3

r04 = 9

rAvrg = 18.5

r05 = 16

rSum = 111

r06 = 32

rDiff = 27

r07 = 25

 

r08 = 44

 

udiNum = 6

 

If bEn=FALSE, 0 is output at all outputs.

VAR_INPUT

bEn     : BOOL;
r01     : REAL;
r02     : REAL;
r03     : REAL;
r04     : REAL;
r05     : REAL;
r06     : REAL;
r07     : REAL;
r08     : REAL;
udiNum  : UDINT;

bEn: Activation of the block function.

r01...r08: Input values to be used for the calculation.

udiNum: Number of input values to be used for the calculation.

VAR_OUTPUT

rMax        : REAL;
udiMaxActv  : UDINT;
rMin        : REAL;
udiMinActv  : UDINT;
rAvrg       : REAL;
rSum        : REAL;
rDiff       : REAL;

rMax: Maximum value of all inputs.

udiMaxActv: Input at which the maximum value is present.

rMin: Minimum value of all inputs.

udiMinActv: Input at which the minimum value is present.

rAvrg: Mean value of all inputs.

rSum: Sum of all inputs.

rDiff: Difference between maximum and minimum value.

Requirements

Development environment

Required PLC library

TwinCAT from v3.1.4024.7

Tc3_BA from v1.1.6.0