FB_BA_MMUX_XX

The function block activates an input value on the output, depending on a selector and the corresponding input selector condition.

Multiplexer function blocks exist for different variable types (BOOL, INT, LREAL, REAL, USINT, UINT and UDINT) and in different input parameters (4, 8, 12, 16 and 24), but they all have the same functionality.
The function block FB_BA_MMUX_R16 is described as an example.

FB_BA_MMUX_XX 1:

Functional description

The function block switches one of the input values rValxx to the output rVal in the activated state (bEn=TRUE) depending on a selector udiSel and the corresponding input selector condition udiEnxx.
If several input selector conditions udiEn01...udiEn16 are equal and the selector udiSel matches a condition, then the input value rVal01...rVal16 of the lowest active selector condition is switched to the output rVal. udiEn01 is the lowest, udiEn16 the highest selector condition.

The output variable bQ indicates that the selector udiSel matches the input selector condition udiEnxx.

The output variable udiActvPrio indicates the active selector condition.

If no selector condition is active, rReplVal is output to rVal . bQ is then FALSE and udiActvPrio indicates a 255.

Example:

Inputs

Output

Variable

Value

Variable

Value

bEn

TRUE

bQ

TRUE

udiSel

5

rVal

1.123

udiEn01

4

udiActvPrio

7

rVal01

123

 

 

udiEn02

 

 

 

rVal02

 

 

 

udiEn03

3

 

 

rVal03

321

 

 

udiEn04

 

 

 

rVal04

 

 

 

udiEn05

8

 

 

rVal05

345

 

 

udiEn06

 

 

 

rVal06

 

 

 

udiEn07

5

 

 

rVal07

1.123

 

 

udiEn08

 

 

 

rVal08

 

 

 

udiEn09

5

 

 

rVal09

5.4321

 

 

udiEn10

 

 

 

rVal10

 

 

 

udiEn11

 

 

 

rVal11

 

 

 

udiEn12

 

 

 

rVal12

 

 

 

udiEn13

 

 

 

rVal13

 

 

 

udiEn14

 

 

 

rVal14

 

 

 

udiEn15

 

 

 

rVal15

 

 

 

udiEn16

 

 

 

rVal16

 

 

 

rReplVal

 

 

 

Inputs/outputs

VAR_INPUT

bEn       : BOOL;
udiSel    : UDINT;
udiEn01   : UDINT := 255;
rVal01    : REAL;
udiEn02   : UDINT := 255;
rVal02    : REAL;
udiEn03   : UDINT := 255;
rVal03    : REAL;
udiEn04   : UDINT := 255;
rVal04    : REAL;
udiEn05   : UDINT := 255;
rVal05    : REAL;
udiEn06   : UDINT := 255;
rVal06    : REAL;
udiEn07   : UDINT := 255;
rVal07    : REAL;
udiEn08   : UDINT := 255;
rVal08    : REAL;
udiEn09   : UDINT := 255;
rVal09    : REAL;
udiEn10   : UDINT := 255;
rVal10    : REAL;
udiEn11   : UDINT := 255;
rVal11    : REAL;
udiEn12   : UDINT := 255;
rVal12    : REAL;
udiEn13   : UDINT := 255;
rVal13    : REAL;
udiEn14   : UDINT := 255;
rVal14    : REAL;
udiEn15   : UDINT := 255;
rVal15    : REAL;
udiEn16   : UDINT := 255;
rVal16    : REAL;
rReplVal  : REAL;

bEn: activation of the block function

udiSel: selector

udiEn01..udiEn16: input selector condition.
The input variables are pre-initialized to the value 255.

rVal01...rVal16: input values to select from.

rReplVal: substitute value, if no input selector condition is active.

VAR_OUTPUT

bQ           : BOOL;
rVal         : REAL;
udiActvPrio  : UDINT;

bQ: TRUE if the selector udiSel matches an input selector condition udiEnxx.

rVal: value of the selected input selector condition

udiActvPrio: indicates which input selector condition is active.

Requirements

Development environment

Target system

required library

required supplement

TwinCAT 2.11 R3/x64

PC/CX

TcBA library from V1.0.0

TS8040 | TwinCAT Building Automation from V1.0.0