LGF_DifferenceQuotientFC (FC / 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 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.

Block Interface

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
       
   

Input parameter

IdentifierData type Description
deltaTLReal Equidistant distance between two measured values. (e.g. 1s)

Output parameter

IdentifierData type Description
Ret_ValVoid Void - Function has no return 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)

In/Out parameter

IdentifierData type Description
valuesArray[*] of LReal Values that will be included in the differentiation.
derivatedValuesArray[*] of LReal The differentiated value range.

Status & Error codes

Code / ValueIdentifier / Description
16#0000STATUS_FINISHED_NO_ERROR
Status: Execution finished without errors
16#8200ERR_DELTA_T
Error: Delta time `deltaT` must not be zero.
16#8400ERR_ARRAYS_DIFFERENT
Error: The Array sizes are not equal. The arrays `values` and `derivatedValues` must have the same size.
16#8401ERR_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.

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
15.11.2019Regions, 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