LGF_SmoothByPolynomFC (FC / V3.0.1)

Overview

Author: Siemens Digital Industry

Short description

This function calculates the smoothed values by polynomial acyclically.

For smoothing, a 3rd degree polynomial is placed through five value points. The error squares of the distances between polynomial and real value are minimized. The smoothed values can be determined from the polynomial parameters obtained in this way.

The function reads an array that is smoothed. 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_SmoothByPolynomFC (FC)
   Ret_Val  Void
    
   error  Bool
    
   status  Word
    
Array[*] of LReal  values  Array[*] of LReal
       
Array[*] of LReal  smoothedValues  Array[*] of LReal
       
   

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 are to be included in the smoothing.
smoothedValuesArray[*] of LReal The smoothed values.

Status & Error codes

Code / ValueIdentifier / Description
16#0000STATUS_FINISHED_NO_ERROR
Status: Execution finished without errors
16#8400ERR_ARRAYS_DIFFERENT
Error: The Array sizes are not equal. The arrays `values` and `smoothedValues` must have the same size.
16#8401ERR_NOT_ENOUGH_VALUES
Error: Not enough values. The block requires five (5) values to calculate a smoothed value. Increase the size of the array at the input parameter `values`. Adapt the array on the output parameter `smoothedValues` to the new size.

Functional description

The 3rd degree compensation polynomial is calculated as follows:

\overline{y(n)} = \frac{1}{35} \cdot (-3 \cdot y(n-2) +12 \cdot y(n-1) +17 \cdot y(n) +12 \cdot y(n+1) -3 \cdot y(n+2))

N-4 smoothed measured values can thus be calculated from the N measured values. The output array contains the value 0 in the index (0.1, N-1, N).

These “missing” values are calculated with the following formalisms:

\overline{y(n-2)} = \frac{1}{70} \cdot (69 \cdot y(n-2) +4 \cdot y(n-1) -6 \cdot y(n) +4 \cdot y(n+1) -y(n+2)) \overline{y(n-1)} = \frac{2}{70} \cdot (2 \cdot y(n-2) +27 \cdot y(n-1) +12 \cdot y(n) -8 \cdot y(n+1) +2 \cdot y(n+2)) \overline{y(n+1)} = \frac{2}{70} \cdot (2 \cdot y(n-2) -8 \cdot y(n-1) +12 \cdot y(n) +27 \cdot y(n+1) +2 \cdot y(n+2)) \overline{y(n+2)} = \frac{1}{70} \cdot (-y(n-2) +4 \cdot y(n-1) -6 \cdot y(n) +4 \cdot y(n+1) +69 \cdot y(n+2))

Change log

Version & DateChange description
01.00.00Siemens Industry Online Support
23.11.2018First released version
01.00.05Simatic 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