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 block calculates the differentiated values cyclically.
The function block reads-in a value with each positive edge on the insert
been read in, the block calculates a differentiated value and outputs it.
LGF_DifferenceQuotientFB (FB) | ||||||||
---|---|---|---|---|---|---|---|---|
Bool | enable | derivatedValue | LReal | |||||
Bool | insert | error | Bool | |||||
LReal | value | status | Word | |||||
LReal | deltaT | |||||||
Identifier | Data type | Default value | Description |
---|---|---|---|
enable | Bool | FALSE | Activates the block. As long as enable is `TRUE`, the block can accept values on the parameter `value`. |
insert | Bool | FALSE | Accepts the value at the input `value` at positive edge and outputs a `derivatedValue` if five values have been read in. |
value | LReal | 0.0 | Value that must be included in the differentiation. |
deltaT | LReal | 0.0 | Equidistant distance between two measured values. (e.g. 1s) |
Identifier | Data type | Description |
---|---|---|
derivatedValue | LReal | The differentiated 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) |
Code / Value | Identifier / Description |
---|---|
16#7000 | STATUS_NO_CALL Status: No call of FB. The block waits for activation through the parameter `enable`. |
16#7001 | STATUS_FIRST_CALL Status: First call of FB after enabling |
16#7002 | STATUS_SUBSEQUENT_CALL Status: Processing is active. Subsequent call of FB. |
16#7010 | STATUS_NOT_ENOUGH_VALUES Status: Not enough values. The block requires five (5) values to calculate a differentiated value. Transfer additional values with a positive edge on the `insert` input. |
16#8200 | ERR_DELTA_T Error: Delta time `deltaT` must not be zero. |
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 | |
04.11.2019 | Code reworked. 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 |