MUX_INT block
Short summary
Name |
MUX_INT |
→POU type |
|
Category |
|
Conform to →IEC-standard |
more possible than defined in IEC-standard
but also:
currently restricted |
Graphical interface |
|
Available since |
|
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 |
Description |
|
Inputs: |
K |
INT |
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 |
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 |
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 |
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 |
|
Input EN and output ENO are available when →calling the block. See "Execution control: EN, ENO" for information on input EN and output ENO.
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 < 0 or > 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, result5 : INT;
stateENO1, stateENO2 : BOOL;
END_VAR
result1 := MUX_INT(K :=
2
, IN0 :=
1
, IN1 :=
2
, IN2 :=
3
, IN3 :=
4
, IN4 :=
5
); (* The variable
'result1'
evaluates to
'3'
. *)
result2 := MUX_INT(K :=
4
, IN0 :=
1
, IN1 :=
2
, IN2 :=
3
, IN3 :=
4
, IN4 :=
5
); (* The variable
'result2'
evaluates to
'5'
. *)
result3 := MUX_INT(K :=
0
, IN0 :=
1
, IN1 :=
2
, IN2 :=
3
, IN3 :=
4
, IN4 :=
5
); (* The variable
'result3'
evaluates to
'1'
. *)
result4 := MUX_INT(K := -
2
, IN0 :=
1
, IN1 :=
2
, IN2 :=
3
, IN3 :=
4
, IN4 :=
5
, ENO => stateENO1); (* The variable
'result4'
evaluates to
'0'
,
'stateENO1'
to
'FALSE'
. *)
result5 := MUX_INT(K :=
7
, IN0 :=
1
, IN1 :=
2
, IN2 :=
3
, IN3 :=
4
, IN4 :=
5
, ENO => stateENO2); (* The variable
'result5'
evaluates to
'0'
,
'stateENO2'
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.