FB_ALY_CurveSketcher_1Ch

Curve Sketcher 1Ch identifies inversions (peaks and valleys) in an input data stream. Furthermore, local maxima of the absolute difference between two consecutive values (referred to as Delta) can be identified. Analogous to a continuous curve, the identified peaks and valleys correspond to local maxima and minima. Delta corresponds to the slope, so that a maximum of the absolute values of Delta can be associated with an inflection point.

Syntax

Definition:

FUNCTION_BLOCK FB_ALY_CurveSketcher_1Ch
VAR_OUTPUT
    ipResultMessage: Tc3_EventLogger.I_TcMessage;
    bError: BOOL;
    bNewResult: BOOL;
    bConfigured: BOOL;
    fLastPeak: LREAL;
    fbTimeLastPeak: FB_ALY_DateTime;
    nCountPeaks: ULINT;
    fLastValley: LREAL;
    fbTimeLastValley: FB_ALY_DateTime;
    nCountValleys: ULINT;
    fValueAtMaxDelta: LREAL;
    fMaxDelta: LREAL;
    fbTimeMaxDelta: FB_ALY_DateTime;
    nCountMaxDelta: ULINT;
END_VAR

FB_ALY_CurveSketcher_1Ch 1: 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.

fLastPeak

LREAL

Y-value of the last identified peak.

fbTimeLastPeak

FB_ALY_DateTime

Timestamp of fLastPeak.

nCountPeaks

ULINT

Total number of peaks counted.

fLastValley

LREAL

Y-value of the last identified valley.

fbTimeLastValley

FB_ALY_DateTime

Timestamp of fLastValley.

nCountValleys

ULINT

Number of valleys detected.

fValueAtMaxDelta

LREAL

Input variable guided by the last detected maximum of Delta. The Delta value is the difference between this value and the input value from one cycle before.

fMaxDelta

LREAL

The last detected local maximum of the absolute difference between two successive values in the input current.

fbTimeMaxDelta

FB_ALY_DateTime

Timestamp of fValueAtMaxDelta.

nCountMaxDelta

ULINT

Total number of counted local maxima of Delta.

FB_ALY_CurveSketcher_1Ch 2: 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
    fbCurveSketcher : FB_ALY_CurveSketcher_1Ch;
    fbSystemTime : FB_ALY_GetSystemTime;
    fThresholdReversal : LREAL := 0.0;
    bCalcInflection : BOOL := FALSE;
    fThresholdDelta : LREAL := 10.0;
    bConfigure : BOOL := TRUE;
    nInput : INT;
END_VAR
// Configure algorithm
IF bConfigure THEN
    bConfigure := FALSE;

    fbCurveSketcher.Configure(fThresholdReversal, bCalcInflection, fThresholdDelta);
END_IF

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

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

Requirements

Development environment

Target platform

Plc libraries to include

TwinCAT v3.1.4024.0

PC or CX (x64, x86)

Tc3_Analytics