This function numerically differentiates a signal sampled equidistantly in time. For example, the velocity can be calculated from a measured locus curve, or the acceleration can be calculated from the measured velocity. In order to minimize the effects of a scattering measurement signal, this algorithm uses a compensating polynomial.
The function calculates the differentiated values acyclically.
The function reads an array that is differentiated. N-4 smoothed measured values can be calculated from N measured values. The output array contains the value 0 in the index (0,1,N-1,N). However, replacement values can be calculated.
LGF_DifferenceQuotientFC (FC) | ||||||||
---|---|---|---|---|---|---|---|---|
LReal | deltaT | Ret_Val | Void | |||||
error | Bool | |||||||
status | Word | |||||||
Array[*] of LReal | values | Array[*] of LReal | ||||||
Array[*] of LReal | derivatedValues | Array[*] of LReal | ||||||
Identifier | Data type | Description |
---|---|---|
deltaT | LReal | Equidistant distance between two measured values. (e.g. 1s) |
Identifier | Data type | Description |
---|---|---|
Ret_Val | Void | Void - Function has no return value |
error | Bool | FALSE: No error TRUE: An error occurred during the execution of the FB |
status | Word | 16#0000-16#7FFF: Status of the FB 16#8000-16#FFFF: Error identification (see following Table) |
Identifier | Data type | Description |
---|---|---|
values | Array[*] of LReal | Values that will be included in the differentiation. |
derivatedValues | Array[*] of LReal | The differentiated value range. |
Code / Value | Identifier / Description |
---|---|
16#0000 | STATUS_FINISHED_NO_ERROR Status: Execution finished without errors |
16#8200 | ERR_DELTA_T Error: Delta time `deltaT` must not be zero. |
16#8400 | ERR_ARRAYS_DIFFERENT Error: The Array sizes are not equal. The arrays `values` and `derivatedValues` must have the same size. |
16#8401 | ERR_NOT_ENOUGH_VALUES Error: Not enough values. The block requires five (5) values to calculate a differntiated value. Transfer additional values with a positive edge on the `insert` input. |
To calculate the difference quotient of a scattering signal, a third-degree compensation polynomial is first placed through the measured values. This polynomial is then differentiated. With this method, even a distorted input signal can be sensibly differentiated.
The difference quotient is calculated with the following formula:
y^{\prime}(n) = \frac{y(n-2) - 8y(n-1) + 8y(n+1) - y(n+2)}{12 \cdot deltaT}deltaT: equidistant distance between two measured values (e.g. 1s).
The function (FC) can calculate N-4 differentiated and smoothed measured values from N measured values. The output array would be assigned with 0 in the index (0,1,N-1,N). However, the following formalisms can be used to calculate substitute values:
y^{\prime}(n-2) = \frac{-125(y(n-2) + 136y(n-1) + 48y(n) - 88y(n+1) + 29y(n+2)}{84 \cdot deltaT} y^{\prime}(n-1) = \frac{-38(y(n-2) - 2y(n-1) + 24y(n) + 26y(n+1) - 10y(n+2)}{84 \cdot deltaT} y^{\prime}(n+1) = \frac{10(y(n-2) - 26y(n-1) - 24y(n) + 2y(n+1) + 38y(n+2)}{84 \cdot deltaT} y^{\prime}(n+2) = \frac{-29(y(n-2) + 88y(n-1) - 48y(n) - 136y(n+1) + 125y(n+2)}{84 \cdot deltaT}Version & Date | Change description | |
---|---|---|
01.00.00 | Siemens Industry Online Support | |
23.11.2018 | First released version | |
01.00.01 | Simatic Systems Support | |
15.11.2019 | Regions, comments and constants are added | |
03.00.00 | Simatic Systems Support | |
23.04.2020 | Set version to V3.0.0, harmonize the version of the whole library | |
03.00.01 | Simatic Systems Support | |
06.04.2021 | Insert documentation |