FB_MovingAverage - General Information
Type: |
Function block |
Available as of: |
V1.0.7.0 |
Inherits from: |
- |
Implements: |
- |
Versions: |
Current version |
Sliding-type mean value generation with an adjustable number of values that shall be determined
Numerical values of the type LREAL are entered into a FIFO buffer. The size of the FIFO buffer is defined with Gc_uiMovingAverageMaxOrder.
At first the buffer has to be initialized with the method Init. This defines over how many values a mean value is generated (query the setting via the property uiOrder). If less values are entered into the buffer than the order setting, then the mean value is only generated over the values entered so far.
The number of values that shall be determined can be changed via the SetOrder method while the system is running. Thereby values that are already entered in the buffer are not lost, they are still considered if the numbers of values that shall be determined are increased.
The mean value according to the mentioned settings can be requested with the property lrAverage.
The number of the valid values entered in the buffer can be requested via the uiLevel property. If uiLevel has the value Gc_uiMovingAverageMaxOrder, then the oldest value is overwritten when a new value is entered into the buffer, following the FIFO principle.
With the Init method the buffer can be reinitialized, which means that the number of valid values in the buffer are set to 0 and the currently calculated mean value is set to 0 too.
NOTE: POU is not addressable!
The POU must not be called up.
The function block can be used by calling it up over methods and properties.
Name |
Description |
---|---|
Basic initialization before the first call-up or reset to the initial state (all the saved values are deleted) |
|
Insert value into buffer |
|
Set the number of measured values to generate the sliding-type mean value |
Name |
Data type |
Accessing |
Description |
---|---|---|---|
lrAverage |
LREAL |
Read |
Mean value on the basis of uiLevel and uiOrder An inquiry before calling up the Init method provides the value 0.0 |
uiLevel |
UINT |
Read |
Filling level of the buffer memory to generate the mean value An inquiry before calling up the Init method provides the value 0 |
uiOrder |
UINT |
Read |
Used number of measured values to generate the sliding-type mean value An inquiry before calling up the Init method provides the value 1 |