MC_AxUtiAverageDerivative_BkPlcMc (from V3.0)
The function block determines the derivative of a value through numeric differentiation over more than one cycle.
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. |
Inputs/outputs
VAR_INOUT
Axis: Axis_Ref_BkPlcMc;
END_VAR
Name | Type | Description |
---|---|---|
Axis | Axis_Ref_BkPlcMc | Here, the address of a variable of type Axis_Ref_BkPlcMc should be transferred. |
Outputs
VAR_OUTPUT
Output: LREAL:=0.0;
Error: BOOL:=FALSE;
ErrorID: UDINT:=0;
END_VAR
Name | Type | Description |
---|---|---|
Output | LREAL | The filtered value. |
Error | BOOL | This output indicates problems with the transferred parameters. |
ErrorID | UDINT | In the event of an error, coded information about the type of problem is reported here. |
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, the system responds with Error and coded information in ErrorID. Otherwise, with each call Input is entered in the filter buffer, and the average value of the modification 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 measuring 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 measuring 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. |