Statistics_DINT (FB)ΒΆ
FUNCTION_BLOCK Statistics_DINT
This function block will update the values of minimum, maximum and average with respect to the integral input parameter \(x_{n}\), which will be added to a set of integral data \(x_{n-1},\dots,x_{1}\) (stemming from previous calls).
\[\left \lfloor \frac{\sum_{i=1}^{n}x_{i}+\left \lfloor \frac{n}{2} \right \rfloor}{n} \right \rfloor\]
Note
Pay attention, that the returned average is of type DINT. In contrast to the arithmetic mean the result will be rounded.
- InOut:
Scope
Name
Type
Initial
Comment
Input
xEnableBOOLReset
diInputDINTNew data \(x_{n}\)
Output
diMinDINT16#7FFFFFFF
Minimum of set \(x_{n},\dots,x_{1}\)
diMaxDINTDWORD_TO_DINT(16#80000000)
Maximum of set \(x_{n},\dots,x_{1}\)
diAverageDINTRounded avarage of data \(x_{n},\dots,x_{1}\)
xOverrunBOOLTRUE: In case of overflowThe module will compensate this by a minor weighting of the old data leading to inaccuracy of the result