# LGF_SimpleSmoothingFB (FB / 3.0.1)

Overview

Author: Siemens Digital Industry

## Short description

The function calculates the linear mean value cyclically.

The simplest form of smoothing a sequence of measured values is to calculate the linear mean value by three points.

The function reads-in a value with each positive edge on the `insert` input. As soon as three values have been read in, the block calculates a smoothed value and outputs it.

### Block Interface

| LGF_SimpleSmoothingFB (FB) |
--- | --- | ---
Bool |  |  | enable |  | smoothedValue |  |  | LReal
Bool |  |  | insert |  | error |  |  | Bool
LReal |  |  | value |  | status |  |  | Word

### Input parameter

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 `smoothedValue` if three values have been read in.
value | LReal | 0.0 | Value that is to be included in the smoothing.

### Output parameter

Identifier | Data type | Description
--- | --- | ---
smoothedValue | LReal | The smoothed 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)

### Status & Error codes

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 three (3) values to calculate a smoothed value. Transfer additional values with a positive edge on the `insert` input.

## Functional description

The function calculates the smoothed values using the following formula:

\overline{y(n)} = \frac{y(n-1) + y(n) + y(n+1)}{3}

The calculated value is output or the calculated values are output at output `smoothedValue`.

Based on this formula, the function cannot calculate values for the elements 0 and N.

## Change log

Version & Date | Change description
--- | ---
| 1.0.0 | Siemens Industry Online Support
| 23.11.2018 | First released version
| 1.0.3 | Simatic Systems Support
| 05.11.2019 | Regions, comments and constants are added
| 3.0.0 | Simatic Systems Support
| 23.04.2020 | Set version to V3.0.0, harmonize the version of the whole library
| 3.0.1 | Simatic Systems Support
| 06.04.2021 | Insert documentation