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, UDINT and DINT) 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.
In active state (bEn=TRUE), the function block activates one of the input values rValxx at output rVal, depending on a selector udiSel and the corresponding input selector condition udiEnxx.
If several input selector conditions udiEn01...udiEn16 are identical and the selector udiSel matches a condition, the input value rVal01...rVal16 of the lowest active selector condition is activated at output rVal. udiEn01 is the lowest selector condition, udiEn16 the highest.
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 at rVal. bQ is then FALSE and udiActvPrio shows 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 |
|
|
|
If no priority is active, the value of the global constant Const.udiNoActvPrio is output at udiActvPrio.
VAR_INPUT
bEn : BOOL;
udiSel : UDINT;
udiEn01 : UDINT := Const.udiNoActvPrio;
rVal01 : REAL;
udiEn02 : UDINT := Const.udiNoActvPrio;
rVal02 : REAL;
udiEn03 : UDINT := Const.udiNoActvPrio;
rVal03 : REAL;
udiEn04 : UDINT := Const.udiNoActvPrio;
rVal04 : REAL;
udiEn05 : UDINT := Const.udiNoActvPrio;
rVal05 : REAL;
udiEn06 : UDINT := Const.udiNoActvPrio;
rVal06 : REAL;
udiEn07 : UDINT := Const.udiNoActvPrio;
rVal07 : REAL;
udiEn08 : UDINT := Const.udiNoActvPrio;
rVal08 : REAL;
udiEn09 : UDINT := Const.udiNoActvPrio;
rVal09 : REAL;
udiEn10 : UDINT := Const.udiNoActvPrio;
rVal10 : REAL;
udiEn11 : UDINT := Const.udiNoActvPrio;
rVal11 : REAL;
udiEn12 : UDINT := Const.udiNoActvPrio;
rVal12 : REAL;
udiEn13 : UDINT := Const.udiNoActvPrio;
rVal13 : REAL;
udiEn14 : UDINT := Const.udiNoActvPrio;
rVal14 : REAL;
udiEn15 : UDINT := Const.udiNoActvPrio;
rVal15 : REAL;
udiEn16 : UDINT := Const.udiNoActvPrio;
rVal16 : REAL;
rReplVal : REAL;
bEn: Activation of the block function.
udiSel: Selector. Internally limited to values between 0 and 4294967294.
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. If no priority is active, the value of the global constant Const.udiNoActvPrio is output at udiActvPrio.
Requirements
Development environment | Required PLC library |
---|---|
TwinCAT from v3.1.4024.7 | Tc3_BA from v1.1.6.0 |