LGF_FloatingAverage (FB / V3.0.2)

Overview

Author: Siemens Digital Industry

Short description

This function calculates a moving arithmetic mean value from REAL values. This method can be used to smooth data series. The values can be read in cyclically or triggered.

Block Interface

LGF_FloatingAverage (FB)
Bool  cyclicExecution average  LReal
    
Bool  trigger windowSizeReached  Bool
    
LReal  value error  Bool
    
Int  windowSize status  Word
    
Bool  reset   
    
   

Input parameter

IdentifierData type Default value Description
cyclicExecutionBool false TRUE: cyclic operation, trigger not in use
triggerBool FALSE Read in `value` with every pulse at input `trigger`
valueLReal 0.0 Value/s from which the moving average is to be determined.
windowSizeInt 100 Window length for sliding averaging in the range from 1..100.
The standard value is 100.
resetBool FALSE TRUE: The block is reset and the calculation starts again.

Output parameter

IdentifierData type Description
averageLReal Moving / Floating average
windowSizeReachedBool FALSE: Maximum window width not yet reached,
TRUE: Maximum window width reached
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#0000STATUS_FINISHED_NO_ERROR
Status: Execution finished without errors
16#8200ERR_WRONG_WINDOW_SIZE
Error: Incorrect window size/width set. Set a value between 1 and 100.

Functional description

Note
The block LGF_FloatingAverage does not query the data type for the input parameter value. For data types other than REAL, either an implicit conversion is performed automatically or an error is generated during compilation.
You can find further information in the Chapter “Overview of Data Type Conversion” in the Online Help section of the TIA Portal or under:
https://support.industry.siemens.com/cs/ww/en/view/109773506/100611494667

The block calculates the (moving) mean value based on the set window width. The window width indicates the maximum number of values read in last. After the maximum number of values has been read, the output windowSizeReached is set and each newly read value replaces the oldest value (FIFO principle).

Two options are available for reading the values. With the input cyclicExecution, the values are read and calculated cyclically. With the trigger input, the values are read in and calculated with each pulse.

Change log

Version & DateChange description
01.00.00Siemens Industry Online Support
16.06.2016First released version
01.00.01Siemens Industry Online Support
02.01.2017Upgrade: TIA Portal V14 Update 1
01.01.00Siemens Industry Online Support
21.02.2017Adding variable window size for calculation
Optimizing calculation algorithm
01.01.01Siemens Industry Online Support
17.08.2018Upgrade: TIA V15 Update 2
01.01.02Siemens Industry Online Support
23.11.2018Upgrade: TIA V15.1
01.01.03Simatic Systems Support
07.11.2019Code refactoring, comments 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
16.06.2020refactor and simplify code
03.00.02Simatic Systems Support
06.04.2021Insert documentation