FB_ALY_EventTimingAnalysis_1Ch

The Event Timing Analysis 1Ch measures time differences between on- and off-event and counts the amount of raised events. An on-event is raised when the signal of the input channel passes the configured edge at a specific on-threshold and an off-event is raised when the off-threshold is passed by the same signal.

Syntax

Definition:

FUNCTION_BLOCK FB_ALY_EventTimingAnalysis_1Ch
VAR_INPUT
    bPersistent: BOOL;
    bInitWithThresholdLevel: BOOL
END_VAR
VAR_OUTPUT
    ipResultMessage: Tc3_EventLogger.I_TcMessage;
    bError: BOOL;
    bNewResult: BOOL;
    bConfigured: BOOL;
    bIsOn: BOOL;
    nSwitchedOn: ULINT;
    fbTimeCurrentInterval: FB_ALY_Timespan;
    fbTimeOnMin: FB_ALY_Timespan;
    fbTimeOnMax: FB_ALY_Timespan;
    fbTimeOnAvg: FB_ALY_Timespan;
    fbTimeOnTotal: FB_ALY_Timespan;
    fbTimeOffMin: FB_ALY_Timespan;
    fbTimeOffMax: FB_ALY_Timespan;
    fbTimeOffAvg: FB_ALY_Timespan;
    fbTimeOffTotal: FB_ALY_Timespan;
END_VAR

FB_ALY_EventTimingAnalysis_1Ch 1: Inputs

Name

Type

Description

bPersistent

BOOL

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

bInitWithThresholdLevel

BOOL

If the value is TRUE, the algorithm uses a threshold to initialize the internal state, instead of waiting for an edge.

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

bIsOn

BOOL

TRUE within the timespan between the On event and the Off result, otherwise FALSE.

nSwitchedOn

ULINT

Counts the number of On events that were triggered.

fbTimeCurrentInterval

FB_ALY_Timespan

Timespan of the current interval.

fbTimeOnMin

FB_ALY_Timespan

Minimum time between On event and Off event.

fbTimeOnMax

FB_ALY_Timespan

Maximum time between On event and Off event.

fbTimeOnAvg

FB_ALY_Timespan

Average time between On event and Off event.

fbTimeOnTotal

FB_ALY_Timespan

Total time between On events and Off events.

fbTimeOffMin

FB_ALY_Timespan

Minimum time between Off event and On event

fbTimeOffMax

FB_ALY_Timespan

Maximum time between Off event and On event

fbTimeOffAvg

FB_ALY_Timespan

Average time between Off event and On event

fbTimeOffTotal

FB_ALY_Timespan

Total time between Off events and On events.

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

ConfigureChannel()

Local

Channel-specific configuration for the respective algorithm.

Reset()

Local

Resets all internal states or the calculations performed so far.

SetChannelValue()

Local

Method for passing values to the algorithm.

FB_ALY_EventTimingAnalysis_1Ch 4: Properties

Name

Type

Access

Definition location

Initial value

Description

fTolerance

LREAL

Get, Set

Local

0.0

Tolerance value for the Equal / NotEqual comparisons

Sample

VAR
    fbEventTimingAnalysis : FB_ALY_EventTimingAnalysis_1Ch;
    fbSystemTime : FB_ALY_GetSystemTime;
    stThresholdEdge : ST_ALY_ThresholdOnOff;
    bConfigure : BOOL := TRUE;
    nInput : INT;
END_VAR
// Configure algorithm
IF bConfigure THEN
    bConfigure := FALSE;
    
    stThresholdEdge.On.eComparisonOperator := E_ALY_ComparisonOperator.Equals; 
    stThresholdEdge.On.fThreshold := 1;
    stThresholdEdge.Off.eComparisonOperator := E_ALY_ComparisonOperator.Equals; 
    stThresholdEdge.Off.fThreshold := 0;
    
    fbEventTimingAnalysis.ConfigureChannel(stThresholdEdge);
    fbEventTimingAnalysis.Configure();
END_IF

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

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

Requirements

Development environment

Target platform

Plc libraries to include

TwinCAT v3.1.4024.0

PC or CX (x64, x86)

Tc3_Analytics