FB_ALY_SectionTimer_1Ch

The Section Timer 1Ch calculates the timespan the input is in range of each configured section. It can be configured with the amount of sections and the borders of each section. Each section is defined with lower border (greater than or equal to) and upper border (less than). The following sections lower border is set by the previous upper border. Values that are less than the minimal border are stored in the first array element. Values that are greater or equal than the maximal border are stored in the last array element.

Syntax

Definition:

FUNCTION_BLOCK FB_ALY_SectionTimer_1Ch
VAR_OUTPUT
    ipResultMessage: Tc3_EventLogger.I_TcMessage;
    bError: BOOL;
    bNewResult: BOOL;
    bConfigured: BOOL;
    nSection: UDINT;
END_VAR

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

nSection

UDINT

Currently classified section of the input.

FB_ALY_SectionTimer_1Ch 2: Methods

Name

Definition location

Description

Call()

Local

Method for calculating the outputs for a specific configuration.

GetResults()

Local

Getting the result array without adding new values.

Configure()

Local

General configuration of the algorithm with its parameterized conditions.

SetSections()

Local

Setting individual sections.

Reset()

Local

Resets all internal states or the calculations performed so far.

SetChannelValue()

Local

Method for passing values to the algorithm.

SetInitial()

Local

Method for setting start section times.

Sample

VAR
    fbSectionTimer : FB_ALY_SectionTimer_1Ch;
    fbSystemTime : FB_ALY_GetSystemTime;
    nNumSections : UDINT := 4;
    fFirstLowerBorder : LREAL := 10;
    aUpperBorders : ARRAY[1..4] OF LREAL := [20,30,40,50];
    bConfigure : BOOL := TRUE;
    nInput : INT;
    aTimespansOut : ARRAY [0..5] OF LINT;
END_VAR
// Configure algorithm
IF bConfigure THEN
    bConfigure := FALSE;

    fbSectionTimer.Configure(nNumSections);
    fbSectionTimer.SetSections(fFirstLowerBorder, ADR(aUpperBorders), SIZEOF(aUpperBorders));
END_IF

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

// Call algorithm
fbSectionTimer.SetChannelValue(nInput);
fbSectionTimer.Call(fbSystemTime.tSystemTime, ADR(aTimespansOut), SIZEOF(aTimespansOut));

Requirements

Development environment

Target platform

Plc libraries to include

TwinCAT v3.1.4024.0

PC or CX (x64, x86)

Tc3_Analytics