FB_ALY_Multiplexer
The Multiplexer selects one channel out of one or more input channels. For each input channel a boolean input has to be provided additionally. The output corresponds to the first input channel, where the conditional input is TRUE. The priority of the configured channels is the order of configuration. If the condition is not met for any of the channels, the provided default channel is returned.
Syntax
Definition:
FUNCTION_BLOCK FB_ALY_Multiplexer
VAR_INPUT
bPersistent: BOOL;
END_VAR
VAR_OUTPUT
ipResultMessage: Tc3_EventLogger.I_TcMessage;
bError: BOOL;
bNewResult: BOOL;
bConfigured: BOOL;
fResult: LREAL;
nCurrentChannel: UDINT;
nCount: ULINT;
fbTimeLastEvent: FB_ALY_DateTime;
END_VAR
Inputs
Name | Type | Description |
---|---|---|
bPersistent | BOOL | If the value is |
Outputs
Name | Type | Description |
---|---|---|
ipResultMessage | 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 |
bNewResult | BOOL | When a new result has been calculated, the output is |
bConfigured | BOOL | Displays |
fResult | LREAL | Returns the signal of the selected input channel. |
nCurrentChannel | UDINT | Indicates the number of the selected channel. The value is 0 if the default result is selected. The input channels are numbered in the order of their configuration. |
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. |
Methods
Name | Definition location | Description |
---|---|---|
Call() | Local | Method for calculating the outputs for a specific configuration. |
FB_init() | Local | Initializes the number of input channels. |
Reset() | Local | Resets all internal states or the calculations performed so far. |
SetChannelValues() | Local | Method for passing channel-specific values to the algorithm. |
SetDefaultChannelValue() | Local | Method to pass a value to the algorithm that will be selected as default if no channel is selected. |
Sample
VAR
fbMultiplexer : FB_ALY_Multiplexer(nNumChannels := 3);
fbSystemTime : FB_ALY_GetSystemTime;
nInputCh1 : INT := 11;
fInputCh2 : LREAL := 1.5;
nInputCh3 : UDINT := 123;
fDefault : LREAL := 3.1415;
bConditionCh1 : BOOL;
bConditionCh2 : BOOL;
bConditionCh3 : BOOL;
END_VAR
// Get current system time
fbSystemTime.Call();
// Call algorithm
fbMultiplexer.SetChannelValues(1, bConditionCh1, nInputCh1);
fbMultiplexer.SetChannelValues(2, bConditionCh2, fInputCh2);
fbMultiplexer.SetChannelValues(3, bConditionCh3, nInputCh3);
fbMultiplexer.SetDefaultChannelValue(fDefault);
fbMultiplexer.Call(fbSystemTime.tSystemTime);
Requirements
Development environment | Target platform | Plc libraries to include |
---|---|---|
TwinCAT v3.1.4024.0 | PC or CX (x64, x86) | Tc3_Analytics |