MUX_DWORD block

Short summary

Name

MUX_DWORD

→POU type

→function

Category

IEC-block, Select, block with internal error diagnostic

Conform to →IEC-standard

images/s/b2ic8e/9012/1ca6q62/_/images/icons/emoticons/add.svg more possible than defined in IEC-standard
(IEC demands ANY_ELEMENTARY for the inputs and the return value.)

but also:

images/s/b2ic8e/9012/1ca6q62/_/images/icons/emoticons/error.svg currently restricted
(IEC demands data type ANY_ELEMENTARY for the inputs, hence the following data types are demanded as well: LTIME, WSTRING, WCHAR, LDATE_AND_TIME, LTIME_OF_DAY and LDATE. Currently, these data types are not supported for the block.)

Graphical interface

images/download/thumbnails/414782336/MUX_DWORD-version-1-modificationdate-1535099984763-api-v2.png

Available since

  • version 1.22.0 (for logi.CAD 3) – initial variant

  • version 1.109.0 (for logi.CAD 3) – enhancement: STRING and CHAR for IN0, IN1 ... IN15 and for the return value

  • version 3.0.1 (for library Standard) – enhancement: user-defined data types and references for IN0, IN1 ... IN15 and for the return value

Functionality

Depending on the input K, the block selects one of the values connected at the other inputs.

If value 0 is connected at input K, the block returns the value connected at input IN0. Value 1 for input K has the block return the value connected at input IN1, value 2 has the value of input IN2 returned etc.

Inputs, return value


Identifier

→Data type

Description

Inputs:

K

DWORD

selector

IN0

REAL, LREAL, USINT, UINT, UDINT, ULINT, SINT, INT, DINT, LINT, TIME, BOOL, BYTE, WORD, DWORD, LWORD, STRING, CHAR, DATE_AND_TIME, DATE, TIME_OF_DAY, a →user-defined data type or a →reference
Restriction: In case of →array data types, only one-dimensional arrays are allowed.

1st value

IN1

REAL, LREAL, USINT, UINT, UDINT, ULINT, SINT, INT, DINT, LINT, TIME, BOOL, BYTE, WORD, DWORD, LWORD, STRING, CHAR, DATE_AND_TIME, DATE, TIME_OF_DAY, a →user-defined data type or a →reference
Restriction: In case of →array data types, only one-dimensional arrays are allowed.

2nd value

... (extensible until)


IN15

REAL, LREAL, USINT, UINT, UDINT, ULINT, SINT, INT, DINT, LINT, TIME, BOOL, BYTE, WORD, DWORD, LWORD, STRING, CHAR, DATE_AND_TIME, DATE, TIME_OF_DAY, a →user-defined data type or a →reference
Restriction: In case of →array data types, only one-dimensional arrays are allowed.

16th value

Return value:

REAL, LREAL, USINT, UINT, UDINT, ULINT, SINT, INT, DINT, LINT, TIME, BOOL, BYTE, WORD, DWORD, LWORD, STRING, CHAR, DATE_AND_TIME, DATE, TIME_OF_DAY, a →user-defined data type or a →reference
Restriction: In case of →array data types, only one-dimensional arrays are allowed.


Input EN and output ENO are available when →calling the block. See "Execution control: EN, ENO" for information on input EN and output ENO.

See:

Internal error diagnostic for block

The block checks the value connected to inpu t K before it is executed.
If the value for K is > the highest connected input, the output ENO of the block is set to value FALSE (or an equivalent) and the block returns the value 0.

Example for usage within ST-editor

PROGRAM Test
VAR
result1, result2, result3, result4 : DWORD;
stateENO1 : BOOL;
END_VAR
result1 := MUX_DWORD(K := 16#0000_0002, IN0 := 16#0000_0001, IN1 := 16#0000_0002, IN2 := 16#0000_0003, IN3 := 16#0000_0004, IN4 := 16#0000_0005); (* The variable 'result1' evaluates to '16#0000_0003'. *)
result2 := MUX_DWORD(K := 16#0000_0004, IN0 := 16#0000_0001, IN1 := 16#0000_0002, IN2 := 16#0000_0003, IN3 := 16#0000_0004, IN4 := 16#0000_0005); (* The variable 'result2' evaluates to '16#0000_0005'. *)
result3 := MUX_DWORD(K := 16#0000_0000, IN0 := 16#0000_0001, IN1 := 16#0000_0002, IN2 := 16#0000_0003, IN3 := 16#0000_0004, IN4 := 16#0000_0005); (* The variable 'result3' evaluates to '16#0000_0001'. *)
result4 := MUX_DWORD(K := 16#0000_0007, IN0 := 16#0000_0001, IN1 := 16#0000_0002, IN2 := 16#0000_0003, IN3 := 16#0000_0004, IN4 := 16#0000_0005, ENO => stateENO1); (* The variable 'result4' evaluates to '0', 'stateENO1' to 'FALSE'. *)
END_PROGRAM

When creating your application within the ST-editor, enter a call of a block by typing the text as requested by the syntax or use Content Assist.