MC_AxUtiSlidingAverage_BkPlcMc (from V3.0)
The function block determines a sliding average value.
Inputs
VAR_INPUT
Input: LREAL:=0.0;
MinIdx: DINT:=0;
MaxIdx: DINT:=0;
pBuffer: POINTER TO LREAL:=0;
END_VAR
Name | Type | Description |
---|---|---|
Input | LREAL | The raw value of the parameter to be filtered. |
MinIdx | DINT | The index of the first filter buffer element to be used. |
MaxIdx | DINT | The index of the last filter buffer element to be used. |
pBuffer | POINTER | The address of the first filter buffer element. |
Outputs
VAR_OUTPUT
Output: LREAL:=0.0;
END_VAR
Name | Type | Description |
---|---|---|
Output | LREAL | Output: The filtered value. |
Behavior of the function block
With each call the function block checks the address of the filter buffer pBuffer and the indices of the elements MinIdx and MaxIdx to be used. If the transferred values are obviously nonsensical, Input is output as Output. Otherwise, with each call Input is entered in the filter buffer, and the average value over the set of values available in the buffer is formed and returned as Output.
The set of values for averaging contains (MaxIdx - MinIdx + 1) values. The filter time is determined by multiplication of this number with the cycle time. |
The principle of sliding averaging leads to a delay amounting to half the filter time. If the filtered parameter can be used in a control loop, the resulting frequency-dependent phase shift can lead to restrictions for the parameter selection. |
The function block has no way to fully check the transferred values of pBuffer, MinIdx and MaxIdx. The user must ensure that these values can be used safely. Otherwise may behave in an unpredictable manner (overwriting of memory) or abortion of the PLC operation. |