Documentation

Smart Average (B48)

Block name

B48_SMART_AVERAGE

ST call

PROGRAM B48_TEST
VAR
IN1, IN2, IN3:REAL;
FB: LIB.CORE.V1_0.B48_SMART_AVERAGE;
END_VAR

FB(IN[1]:=IN1, IN[2]:= IN2);
O1:= FB.OUT;
END_PROGRAM

Library

LIB\CORE

Version

V1.0

Description

This block is an extension of the AVG block. The AVG block calculates just the arithmetic average, which may cause problems in field deployment: At sites with 3 or 4 room temperature sensors, which are averaged to obtain a room temperature as an input for a room controller, a sensor may get broken and feed a bad value, e.g. of 150 °C. The plain average temperature is useless, while the problem is difficult to detect.

On the other hand, B48 calculates the most probable average temperature by omitting all "out-of-range" values. This is achieved by calculating a median value, M. All input values (X), which are closer to M than the tolerance (tol), are used for average value calculation, while all values outside of the tolerance band are not taken into account.

Output BS gives the sign of the OUT value. If OUT>= 0, then BS=TRUE, else BS=FALSE. The BSN output is a negation of BS.

If the number of sensors is 3, the block is able to detect one false value. If the number of sensors is 5, the block detects up to 2 false values, etc.

To attach the input values, inputs IN0, IN1 a IN3 (or maximum 3 inputs) can be used, or the input array IN (multiioreal) for maximum 16 inputs.

Input signals must be enabled by setting the enable variable INENABLED to TRUE (such as inenabled[1]:=true; for the first input IN1).

Inputs

Input Type Description Default value
IN MULTIIOREAL Input values [0,0,...,0]
INENABLED MULTIIOBOOL Input enable [False,...,False]
IN0 REAL Input value  
IN1 REAL Input value  
IN2 REAL Input value  
TOL REAL Tolerance 2

Outputs

Output Type Description
OUT REAL Output signal
VAL INT Number of inputs used when calculating the output signal
INVAL INT Number of omitted outputs
BS BOOL Sign of the output signal
BSN BOOL Negation of bs

Application example