LGF_DifferenceQuotientFB (FB / V3.0.1)

Overview

Author: Siemens Digital Industry

Short description

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.

Block Interface

LGF_DifferenceQuotientFB (FB)
Bool  enable derivatedValue  LReal
    
Bool  insert error  Bool
    
LReal  value status  Word
    
LReal  deltaT   
    
   

Input parameter

IdentifierData type Default value Description
enableBool FALSE Activates the block. As long as enable is `TRUE`, the block can accept values on the parameter `value`.
insertBool FALSE Accepts the value at the input `value` at positive edge and outputs a `derivatedValue` if five values have been read in.
valueLReal 0.0 Value that must be included in the differentiation.
deltaTLReal 0.0 Equidistant distance between two measured values. (e.g. 1s)

Output parameter

IdentifierData type Description
derivatedValueLReal The differentiated value.
errorBool FALSE: No error
TRUE: An error occurred during the execution of the FB
statusWord 16#0000-16#7FFF: Status of the FB
16#8000-16#FFFF: Error identification (see following Table)

Status & Error codes

Code / ValueIdentifier / Description
16#7000STATUS_NO_CALL
Status: No call of FB. The block waits for activation through the parameter `enable`.
16#7001STATUS_FIRST_CALL
Status: First call of FB after enabling
16#7002STATUS_SUBSEQUENT_CALL
Status: Processing is active. Subsequent call of FB.
16#7010STATUS_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#8200ERR_DELTA_T
Error: Delta time `deltaT` must not be zero.

Functional description

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}

Change log

Version & DateChange description
01.00.00Siemens Industry Online Support
23.11.2018First released version
01.00.01Simatic Systems Support
04.11.2019Code reworked.
Regions, comments and constants are added
03.00.00Simatic Systems Support
23.04.2020Set version to V3.0.0, harmonize the version of the whole library
03.00.01Simatic Systems Support
06.04.2021Insert documentation