Moving average

In this example, the way that the Condition Monitoring library is used is shown by the calculation of a moving average as an example. The FB_CMA_MovingMean block is used here. Similarly, a moving standard deviation, skewness, and excess can also be calculated using the FB_CMA_MovingStandardDeviation, FB_CMA_MovingSkew, and FB_CMA_MovingExcess function blocks.

The source code for the sample is available for download from here:MovingMoments_Sample.zip

Block diagram

Moving average  1:

Program parameters

This table contains a list of the parameters that are important for configuring the function blocks.

Oversamples/buffer length

10

Population (stream)

100

Stack length (spectrum)

400

Window length

800

FFT length

1024

FFT result length

513

Explanations

The scope project contained in this sample shows the calculated moving averages of a sine wave and a pulse in a streaming context in a YT chart. In order to ensure that the output data is processed correctly, it is important to consider how time influences the averaging. This is explained below.

Furthermore, the project includes the display of a calculated averaged spectrum in a separate array bar chart. This shows a magnitude spectrum for a range from 0 to 1 kHz. The current spectrum is shown as a bar chart, the moving average is shown as a continuous line.

Moving average  2:

Requirements

Development environment

Target platform

PLC libraries to include

TwinCAT v3.1.4022.25

PC or CX (x86, x64)

Tc3_CM, Tc3_CM_Base