FB_BA_MMUX_XX

FB_BA_MMUX_XX 1:

The function block FB_BA_MMUX_XX 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 values (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.

The function block switches one of the input values rValxx to the output fVal in the activated state (bEn = TRUE) depending on a selector nSel and the corresponding input selector condition nEnxx.
If several input selector conditions nEn01...nEn16 are equal and the selector nSel matches a condition, then the input value fVal01...fVal16 of the lowest active selector condition is switched to the output fVal. nEn01 is the lowest, nEn16 the highest selector condition.

The output variable bQ indicates that the selector nSel matches an input selector condition nEnxx.
The output variable nActvPrio indicates the active selector condition.
If no selector condition is active, fReplVal is output to fVal. bQ is then FALSE and nActvPrio indicates a 255.

Sample:

Inputs

Output

Variable

Value

Variable

Value

bEn

TRUE

bQ

TRUE

nSel

5

fVal

1.123

nEn01

4

nActvPrio

7

fVal01

123

 

 

nEn02

 

 

 

fVal02

 

 

 

nEn03

3

 

 

fVal03

321

 

 

nEn04

 

 

 

fVal04

 

 

 

nEn05

8

 

 

fVal05

345

 

 

nEn06

 

 

 

fVal06

 

 

 

nEn07

5

 

 

fVal07

1.123

 

 

nEn08

 

 

 

fVal08

 

 

 

nEn09

5

 

 

fVal09

5.4321

 

 

nEn10

 

 

 

fVal10

 

 

 

nEn11

 

 

 

fVal11

 

 

 

nEn12

 

 

 

fVal12

 

 

 

nEn13

 

 

 

fVal13

 

 

 

nEn14

 

 

 

fVal14

 

 

 

nEn15

 

 

 

fVal15

 

 

 

nEn16

 

 

 

fVal16

 

 

 

fReplVal

 

 

 

If no active priority is present, then the value of the global constant BA_Globals.nNoActivePrio is output at the output nActvPrio.

FB_BA_MMUX_XX 2: Inputs

VAR_INPUT
  bEn        : BOOL;
  nSel       : UDINT;
  nEn01      : UDINT := BA_Globals.nNoActvPrio;
  fVal01     : REAL;
  nEn02      : UDINT := BA_Globals.nNoActvPrio;
  fVal02     : REAL;
  nEn03      : UDINT := BA_Globals.nNoActvPrio;
  fVal03     : REAL;
  nEn04      : UDINT := BA_Globals.nNoActvPrio;
  fVal04     : REAL;
  nEn05      : UDINT := BA_Globals.nNoActvPrio;
  fVal05     : REAL;
  nEn06      : UDINT := BA_Globals.nNoActvPrio;
  fVal06     : REAL;
  nEn07      : UDINT := BA_Globals.nNoActvPrio;
  fVal07     : REAL;
  nEn08      : UDINT := BA_Globals.nNoActvPrio;
  fVal08     : REAL;
  nEn09      : UDINT := BA_Globals.nNoActvPrio;
  fVal09     : REAL;
  nEn10      : UDINT := BA_Globals.nNoActvPrio;
  fVal10     : REAL;
  nEn11      : UDINT := BA_Globals.nNoActvPrio;
  fVal11     : REAL;
  nEn12      : UDINT := BA_Globals.nNoActvPrio;
  fVal12     : REAL;
  nEn13      : UDINT := BA_Globals.nNoActvPrio;
  fVal13     : REAL;
  nEn14      : UDINT := BA_Globals.nNoActvPrio;
  fVal14     : REAL;
  nEn15      : UDINT := BA_Globals.nNoActvPrio;
  fVal15     : REAL;
  nEn16      : UDINT := BA_Globals.nNoActvPrio;
  fVal16     : REAL;
  fReplVal   : REAL;
END_VAR

Name

Type

Description

bEn

BOOL

Activation of the block function

nSel

UDINT

Selector. Internally limited to values between 0 and 4294967294.

nEn01…nEn16

UDINT

Input values to select from.

fReplVal

REAL

Substitute value, if no input selector condition is active.

FB_BA_MMUX_XX 3: Outputs

VAR_OUTPUT
  bQ           : BOOL;
  fVal         : REAL;
  nActvPrio    : UDINT;
END_VAR

Name

Type

Description

bQ

BOOL

TRUE if the selector nSel matches an input selector condition nEnxx.

fVal

REAL

Value of the selected input selector condition.

nActvPrio

UDINT

Indicates which input selector condition is active. If no active priority is present, then the value of the global constant BA_Globals.nNoActivePrio is output at the output nActvPrio.

Requirements

Development environment

Required PLC library

TwinCAT from v3.1.4024.22

Tc3_BA2 from v5.2.5.0