FB_BA_MultiCalcREAL32

FB_BA_MultiCalcREAL32 1:

The multi-calculation function block FB_BA_MultiCalcREAL32 exists for the variable type REAL.

In enabled state (bEn = TRUE), the function block determines the following from the input values aVal:

If not all inputs are to be calculated, the number can be limited by an entry at nNumOfElem: with nNumOfElem= 6, for example, the calculations are performed only for the first six entries of aVal.
An entry greater than 32 is automatically limited to 32, an entry less than 1 is automatically limited to 1.

Sample:

Inputs

Output

bEn = TRUE

fMax = 32

aVal[1] = 32

nMaxActv = 1

aVal[2] = 17

fMin = 5

aVal[3] = 5

nMinActv = 3

aVal[4] = 9

fAvrg = 18.5

aVal[5] = 16

fSum = 111

aVal[6] = 32

fDiff = 27

aVal[7] = 25

 

aVal[8] = 44

 

nNumOfElem = 6

 

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

FB_BA_MultiCalcREAL32 2: Inputs

VAR_INPUT
  bEn         : BOOL;
  aVal        : ARRAY [1..???] of REAL;
  nNumOfElem  : UDINT;
END_VAR

Name

Type

Description

bEn

BOOL

Activation of the block function.

aVal

ARRAY OF REAL

Field with the values to be calculated.

nNumOfElem

UDINT

Number of input values to be used for the calculation.

FB_BA_MultiCalcREAL32 3: Outputs

VAR_OUTPUT
  fMax        : REAL;
  nMaxActv    : UDINT;
  fMin        : REAL;
  nMinActv    : UDINT;
  fAvrg       : REAL;
  fSum        : REAL;
  fDiff       : REAL;
  bErr        : BOOL;
END_VAR

Name

Type

Description

fMax

REAL

Maximum value of all inputs.

nMaxActv

UDINT

Input at which the maximum value is present.

fMin

REAL

Minimum value of all inputs.

nMinActv

UDINT

Input at which the minimum value is present.

fAvrg

REAL

Average value of all inputs

fSum

REAL

Sum of all inputs

fDiff

REAL

Difference between maximum and minimum value.

bErr

BOOL

This output is switched to TRUE if the parameters entered are erroneous.

Requirements

Development environment

Required PLC library

TwinCAT from v3.1.4024.22

Tc3_BA2 from v5.2.5.0