FB_ALY_RMS_1Ch

RMS 1Ch calculates the root mean square over the input values according to the formula

FB_ALY_RMS_1Ch 1:

The number of samples N that are included in the calculation can be configured by specifying a time interval. A cascaded output can be configured to realize a long-term RMS in a resource-saving way and to pick up intermediate results. The time interval of the configured cascade must correspond to an integer multiple of the time interval of the previous cascade.

Syntax

Definition:

FUNCTION_BLOCK FB_ALY_RMS_1Ch
VAR_OUTPUT
    ipResultMessage: Tc3_EventLogger.I_TcMessage;
    bError: BOOL;
    bNewResult: BOOL;
    bConfigured: BOOL;
END_VAR

FB_ALY_RMS_1Ch 2: Outputs

Name

Type

Description

ipResultMessage

I_TcMessage

Contains more detailed information on the current return value. This special interface pointer is internally secured so that it is always valid/assigned.

bError

BOOL

This output is TRUE if an error occurs.

bNewResult

BOOL

When a new result has been calculated, the output is TRUE.

bConfigured

BOOL

Displays TRUE when the function block is successfully configured.

FB_ALY_RMS_1Ch 3: Methods

Name

Definition location

Description

Call()

Local

Method for calculating the outputs for a specific configuration.

Configure()

Local

General configuration of the algorithm with its parameterized conditions.

SetCascades()

Local

Method for configuring the cascades. The call is made after the call to the Configure method.

Reset()

Local

Resets all internal states or the calculations performed so far.

SetChannelValue()

Local

Method for passing values to the algorithm.

Sample

VAR
    fbRMS_1Ch : FB_ALY_RMS_1Ch;
    fbSystemTime : FB_ALY_GetSystemTime;
    nNumCascades : UDINT := 5;
    fSampleRate : UDINT := 1000;
    eStartupBehaviour : E_ALY_CascadeStartupBehaviour := E_ALY_CascadeStartupBehaviour.UsePreviousCascadeValue;
    aCascadesConfigArray : ARRAY[1..5] OF LTIME := [LTIME#20MS, LTIME#1S, LTIME#1M, LTIME#1H, LTIME#1D];
    bConfigure : BOOL := TRUE;
    fInput : LREAL;
    aRMS : ARRAY[1..5] OF LREAL;
    aNewResult : ARRAY[1..5] OF BOOL;
END_VAR
// Configure algorithm
IF bConfigure THEN
    bConfigure := FALSE;

    fbRMS_1Ch.Configure(nNumCascades, fSampleRate, eStartupBehaviour);
    fbRMS_1Ch.SetCascades(ADR(aCascadesConfigArray), SIZEOF(aCascadesConfigArray));    
END_IF

// Get current system time
fbSystemTime.Call();

// Call algorithm
fbRMS_1Ch.SetChannelValue(fInput);
fbRMS_1Ch.Call(fbSystemTime.tSystemTime, ADR(aRMS), SIZEOF(aRMS), ADR(aNewResult), SIZEOF(aNewResult));

Requirements

Development environment

Target platform

Plc libraries to include

TwinCAT v3.1.4024.0

PC or CX (x64, x86)

Tc3_Analytics