FB_ALY_Integrator_1Ch

The Integrator 1Ch integrates the input value over time with a base unit of one second and provides the result of this integration operation. For the approximation of this integral the trapezoidal rule is used. The trapezoidal FB_ALY_Integrator_1Ch 1: between two subsequent timestamps FB_ALY_Integrator_1Ch 2: and FB_ALY_Integrator_1Ch 3: with the values FB_ALY_Integrator_1Ch 4: and FB_ALY_Integrator_1Ch 5: is calculates as

FB_ALY_Integrator_1Ch 6:.

If the integration mode "absolute" ("|x|") is chosen in the configuration, FB_ALY_Integrator_1Ch 7: and FB_ALY_Integrator_1Ch 8: are substituted by their absolute values in the above equation.

In each cycle the trapezoidal between the current and the last timestamp is calculated and added to the sum of trapezoids starting from the beginning of the analysis. Additionally, this sum can be scaled by a factor that can be configured individually.

Syntax

Definition:

FUNCTION_BLOCK FB_ALY_Integrator_1Ch
VAR_INPUT
    bPersistent: BOOL;
END_VAR
VAR_OUTPUT
    ipResultMessage: Tc3_EventLogger.I_TcMessage;
    bError: BOOL;
    bNewResult: BOOL;
    bConfigured: BOOL;
    fResult: LREAL;
END_VAR

FB_ALY_Integrator_1Ch 9: Inputs

Name

Type

Description

bPersistent

BOOL

If the value is TRUE, the internal data is stored persistently.

FB_ALY_Integrator_1Ch 10: 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.

fResult

LREAL

Outputs the result of the integration.

FB_ALY_Integrator_1Ch 11: 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.

Reset()

Local

Resets all internal states or the calculations performed so far.

SetChannelValue()

Local

Method for passing values to the algorithm.

Sample

VAR
    fbIntegrator : FB_ALY_Integrator_1Ch;
    fbSystemTime : FB_ALY_GetSystemTime;
    eIntegrationMode : E_ALY_IntegrationMode := E_ALY_IntegrationMode.Direct;
    fFactor : LREAL := 1.0;
    bConfigure : BOOL := TRUE;
    nInput : INT;
END_VAR
// Configure algorithm
IF bConfigure THEN
    bConfigure := FALSE;

    fbIntegrator.Configure(eIntegrationMode, fFactor);
END_IF

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

// Call algorithm
fbIntegrator.SetChannelValue(nInput);
fbIntegrator.Call(fbSystemTime.tSystemTime);

Requirements

Development environment

Target platform

Plc libraries to include

TwinCAT v3.1.4024.0

PC or CX (x64, x86)

Tc3_Analytics