AverageCh (FB)

FUNCTION_BLOCK AverageCh

Short Descritpion

Creation of a mean of up to six weighted numerical input sizes

Typical application: Creation of a room temperature average from different sensors

Portrayal

../_images/AverageCh_FB.png

Interfaces

Inputs

Name

Datatype

Range

Init-Value

Function

rIn1 REAL    

Analog value input 1

rIn2 REAL    

Analog value input 2

rIn3 REAL    

Analog value input 3

rIn4 REAL    

Analog value input 4

rIn5 REAL    

Analog value input 5

rIn6 REAL    

Analog value input 6

xEn1 BOOL    

Enable analog value input 1

xEn2 BOOL    

Enable analog value input 2

xEn3 BOOL    

Enable analog value input 3

xEn4 BOOL    

Enable analog value input 4

xEn5 BOOL    

Enable analog value input 5

xEn6 BOOL    

Enable analog value input 6

Outputs

Name

Datatype

Range

Init-Value

Function

rOut REAL    

Mean value

xErr BOOL    

Collective fault

Setpoints/parameters

Name

Datatype

Range

Init-Value

Function

iLoading6 INT   10

Weighting - analog value input 6

iLoading5 INT   10

Weighting - analog value input 5

iLoading4 INT   10

Weighting - analog value input 4

iLoading3 INT   10

Weighting - analog value input 3

iLoading2 INT   10

Weighting - analog value input 2

iLoading1 INT   10

Weighting - analog value input 1

Functional Description

Mean value rOut

The mean value is formed by multiplying the analog value inputs rInX by their individual weighting iLoadingX and
then all products are added up (dividend).
The sum of the weightings is formed by the addition of the individual weightings (= divisor).
The resulting quotient is finally available as mean rOut.

The individual weighting of an analog value input X always has the value 0.0, as long as the approval of the analog value input X xEnX is disabled (= FALSE).
If the sum of the weights (divisor) = zero, then the value 0.0 is constantly emitted at the output rOut.

Legend: X = 1 to 6

Collective fault xErr

The collective fault is active (= TRUE) if at least one of the analog value inputs rInX is disabled (xEnX = FALSE).
In all other cases, the collective fault is not active (= FALSE).

Visualization




Information

Element

Authors

Date

Version

Information

Function

Adam Bartod 07.2016 1.0

Initial version

Programming

Adam Bartod 07.2016 1.0

Initial version

Test Alexander Halter 07.2016 1.0

Initial version

Documentation

Jochen Reu 11.2017 1.0

Initial version

Codesys

InOut:
Scope Name Type Initial Comment
Input rIn1 REAL  

Analog value input 1

rIn2 REAL  

Analog value input 2

rIn3 REAL  

Analog value input 3

rIn4 REAL  

Analog value input 4

rIn5 REAL  

Analog value input 5

rIn6 REAL  

Analog value input 6

xEn1 BOOL  

Enable analog value input 1

xEn2 BOOL  

Enable analog value input 2

xEn3 BOOL  

Enable analog value input 3

xEn4 BOOL  

Enable analog value input 4

xEn5 BOOL  

Enable analog value input 5

xEn6 BOOL  

Enable analog value input 6

iLoading6 INT 10

Weighting - analog value input 6

iLoading5 INT 10

Weighting - analog value input 5

iLoading4 INT 10

Weighting - analog value input 4

iLoading3 INT 10

Weighting - analog value input 3

iLoading2 INT 10

Weighting - analog value input 2

iLoading1 INT 10

Weighting - analog value input 1

Output rOut REAL  

Mean value

xErr BOOL  

Collective fault