FB_ALY_DynamicTimeWarpingInterval

The Dynamic Time Warping Interval algorithm compares several input data with each other. The special feature of the algorithm is that signals with different speeds or even shifted signals can be compared. Only the signal interval of a configured window is considered for the comparison. New results are output after the window expires. As a result, the distance between the reference signal and the respective input signal is output. The smaller the distance, the more equal the compared signals are. If the distance is 0, both signals are identical. The amount of distance depends on the equality but also on the length of the signals.

Syntax

Definition:

FUNCTION_BLOCK FB_ALY_DynamicTimeWarpingInterval
VAR_OUTPUT
    ipResultMessage: Tc3_EventLogger.I_TcMessage;
    bError: BOOL;
    bNewResult: BOOL;
    bConfigured: BOOL;
    nBestMatchIdx: UDINT;
END_VAR

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

nBestMatchIdx

UDINT

Outputs the index of the input channel with the smallest distance to the reference channel.

FB_ALY_DynamicTimeWarpingInterval 2: Methods

Name

Definition location

Description

Call()

Local

Method for calculating the outputs for a specific configuration.

Configure()

Local

Configuration of the algorithm.

FB_init()

Local

Initializes the number of input channels.

GetChannelOutputVaue()

Local

Method for getting individual output values from the output array

GetChannelOutputArray()

Local

Method for getting the entire output array.

Reset()

Local

Resets all internal states or the calculations performed so far.

SetChannelValue()

Local

Method for passing values to the algorithm.

Sample

VAR
    fbDynamicTimeWarpingInterval : FB_ALY_DynamicTimeWarpingInterval(nNumChannels := 3);

    nWindowSize : UDINT := 100;
    bConfigure : BOOL := TRUE;
    
    fReference : LREAL;
    fInput1 : LREAL;
    fInput2 : LREAL;
    fInput3 : LREAL;

    aDistances : ARRAY[1..3] OF LREAL;
END_VAR
// Configure algorithm
IF bConfigure THEN
    bConfigure := FALSE;
    fbDynamicTimeWarpingInterval.Configure(nWindowSize);
END_IF

// Call algorithm
fbDynamicTimeWarpingInterval.SetChannelValue(0, fReference);
fbDynamicTimeWarpingInterval.SetChannelValue(1, fInput1);
fbDynamicTimeWarpingInterval.SetChannelValue(2, fInput2);
fbDynamicTimeWarpingInterval.SetChannelValue(3, fInput3);
fbDynamicTimeWarpingInterval.Call();

// Get results
fbDynamicTimeWarpingInterval.GetOutputArray(pArrayOut:=ADR(aDistances), nArrayOutSize:=SIZEOF(aDistances));

Requirements

Development environment

Target platform

Plc libraries to include

TwinCAT v3.1.4024.0

PC or CX (x64, x86)

Tc3_Analytics