FB_ALY_Demultiplexer

The demultiplexer selects an output channel based on the input value. For this purpose, the input value is interpreted as an integer. This value corresponds to the output channel. If the value is outside the configured number of channels, the output channel is set to 0.

Syntax

Definition:

FUNCTION_BLOCK FB_ALY_Demultiplexer
VAR_OUTPUT
    ipResultMessage: Tc3_EventLogger.I_TcMessage;
    bError: BOOL;
    bNewResult: BOOL;
    bConfigured: BOOL;
    bSwitched: BOOL;
    nCurrentChannel: UDINT;
    nCount: ULINT;
    fbTimeLastEvent: FB_ALY_DateTime;
END_VAR

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

bSwitched

BOOL

TRUE if a channel change has taken place.

nCurrentChannel

UDINT

Indicates the number of the selected channel. The value is 0 if the selected channel is outside the configured channels.

nCount

ULINT

Starts with 1 for the channel selected at the start of the analysis and increments each time another channel is selected.

fbTimeLastEvent

FB_ALY_DateTime

Timestamp of the last channel change.

FB_ALY_Demultiplexer 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

FB_init()

Local

Initializes the number of output channels.

Reset()

Local

Resets all internal states or the calculations performed so far.

SetChannelValue()

Local

Method for passing channel-specific values to the algorithm.

Sample

VAR
    fbDemultiplexer : FB_ALY_Demultiplexer(nNumChannels := 3);
    fbSystemTime : FB_ALY_GetSystemTime;
    nInput : INT := 1;
    aResults : ARRAY[0..3] OF BOOL;
END_VAR
// Get current system time
fbSystemTime.Call();

// Call algorithm
fbDemultiplexer.SetChannelValue(nInput);
fbDemultiplexer.Call(fbSystemTime.tSystemTime, ADR(aResults), SIZEOF(aResults));

Requirements

Development environment

Target platform

Plc libraries to include

TwinCAT v3.1.4024.0

PC or CX (x64, x86)

Tc3_Analytics