FB_ALY_XyGateMonitor_2Ch

The XY Gate Monitor 2Ch counts the amount of intersections of an XY input with a specified gate or its projection (straight line between the gate points) depending on the configured Gate Mode. The analysis period can be started with the inputs Start and Stop. The algorithm is direction sensitive, which means that just intersection in the right direction are counted. The direction interpretation depends on the order of the gate points (X1/Y1) and (X2/Y2). The possible intersection directions are visualized below.

Directions of the intersection points:

The blue arrow represents the signal direction and the black lines illustrate the gate with its gate points (X1/Y1) and (X2/Y2). The direction of the intersection points is counted when the signal rotates counterclockwise around the first gate point (X1/Y1).

FB_ALY_XyGateMonitor_2Ch 1:

Syntax

Definition:

FUNCTION_BLOCK FB_ALY_XyGateMonitor_2Ch
VAR_OUTPUT 
    ipResultMessage: Tc3_EventLogger.I_TcMessage;
    bError: BOOL;
    bNewResult: BOOL;
    bConfigured: BOOL;
    bExecuting: BOOL;
    bGateIntersection: BOOL;
    bOutlierIntersection: BOOL;
    fPosIntersectionX: LREAL;
    fPosIntersectionY: LREAL;
    nCountGateIntersections: ULINT;
    nCountOutlierIntersections: ULINT;
    fbTimeLastIntersection: FB_ALY_DateTime;
    eClassification: E_ALY_Classification_2Cls;
END_VAR

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

bExecuting

BOOL

TRUE if the Call() method was called with bStart:=TRUE. FALSE if the call method was called with bStop:=TRUE.

bGateIntersection

BOOL

TRUE if a gate intersection has been detected.

bOutlierIntersection

BOOL

TRUE if an outlier intersection has been detected.

fPosIntersectionX

LREAL

X coordinate of the last intersection.

fPosIntersectionY

LREAL

Y coordinate of the last intersection.

nCountGateIntersections

ULINT

Number of intersections detected.

nCountOutlierIntersections

ULINT

Number of outliers detected.

fbTimeLastIntersection

FB_ALY_DateTime

Timestamp of the last intersection.

eClassification

E_ALY_Classification_2Cls

Classification result. Depending on the configured gate mode.

FB_ALY_XyGateMonitor_2Ch 3:Methods

Name

Definition Location

Description

Call()

Local

method calculates the outputs for a given configuration.

Configure()

Local

General configuration of the algorithm with its parameterized conditions.

Reset()

Local

Resets all internal states or the calculations made so far.

SetChannelValue()

Local

Method to pass values to the algorithm.

Sample

VAR
    fbXyGateMonitor : FB_ALY_XyGateMonitor_2Ch;
    fbSystemTime : FB_ALY_GetSystemTime;
    eGateMode : E_ALY_GateMode := E_ALY_GateMode.IntersectGate;
    stGatePos1 : ST_ALY_XyPosition := ( X:= 0.0, Y := 0.0);
    stGatePos2 : ST_ALY_XyPosition := ( X:= 0.0, Y := 4.0);
    bConfigure : BOOL := TRUE;
    fInputChX : LREAL;
    fInputChY : LREAL;
    bStart : BOOL;
    bStop : BOOL;
END_VAR
// Configure algorithm
IF bConfigure THEN
    bConfigure := FALSE;

    fbXyGateMonitor.Configure(eGateMode, stGatePos1, stGatePos2);
END_IF

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

// Call algorithm
fbXyGateMonitor.SetChannelValue(1, fInputChX);
fbXyGateMonitor.SetChannelValue(2, fInputChY);
fbXyGateMonitor.Call(bStart, bStop, fbSystemTime.tSystemTime);

Requirements

Development environment

Target platform

Plc libraries to include

TwinCAT v3.1.4024.0

PC or CX (x64, x86)

Tc3_Analytics