FB_ALY_TimespanCompare_1Ch

The Timespan Compare 1Ch compares the input value with a reference value and returns the result of this comparison operation. A timespan with a resolution of 1 ns is supported as an input. The operator, the reference value and the count mode can be configured individually.

Syntax

Definition:

FUNCTION_BLOCK FB_ALY_TimespanCompare_1Ch
VAR_INPUT
    bPersistent: BOOL;
END_VAR
VAR_OUTPUT
    ipResultMessage: Tc3_EventLogger.I_TcMessage;
    bError: BOOL;
    bNewResult: BOOL;
    bConfigured: BOOL;
    bOperationOut: BOOL;
    nCount: ULINT;
    fbTimeLastEvent: FB_ALY_DateTime;
END_VAR

FB_ALY_TimespanCompare_1Ch 1: Inputs

Name

Type

Description

bPersistent

BOOL

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

FB_ALY_TimespanCompare_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.

bOperationOut

BOOL

Result of the comparison operation.

nCount

ULINT

Incremented when the output value is bOperationOut=TRUE. The behavior depends on the configuration parameter eCountMode.

fbTimeLastEvent

FB_ALY_DateTime

Timestamp of the last change to bOperationOut=TRUE.

FB_ALY_TimespanCompare_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.

Reset()

Local

Resets all internal states or the calculations performed so far.

SetChannelValue()

Local

Method for passing values to the algorithm. Resolution of the time values in 1 ns.

Sample

VAR
    fbTimespanCompare : FB_ALY_TimespanCompare_1Ch;
    fbSystemTime : FB_ALY_GetSystemTime;
    tReference : FB_ALY_Timespan :=(wSeconds := 42);
    eComparisonOperator : E_ALY_ComparisonOperator := E_ALY_ComparisonOperator.GreaterThan;
    eCountMode : E_ALY_CountMode := E_ALY_CountMode.OnChange;
    bUseAbsValues : BOOL := FALSE;
    bConfigure : BOOL := TRUE;
    tInput : LTIME;
END_VAR
// Configure algorithm
IF bConfigure THEN
    bConfigure := FALSE;

    fbTimespanCompare.Configure(tReference, eComparisonOperator, eCountMode, bUseAbsValues);
END_IF

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

// Call algorithm
fbTimespanCompare.SetChannelValue(tInput);
fbTimespanCompare.Call(fbSystemTime.tSystemTime);

Requirements

Development environment

Target platform

Plc libraries to include

TwinCAT v3.1.4024.0

PC or CX (x64, x86)

Tc3_Analytics