IEC selection operator for multiplexing operation.
OUT := MUX(K, IN0,...,INn)) means:
OUT := INk
IN0, ...,INn and OUT can be any identical data type. Make sure that variables of the identical data type are used at these positions, especially when using user-defined data types. The compiler verifies the identity of the types and returns compiler errors. Assigning function block instances to interface variables is not supported.
K has to be BYTE, WORD, DWORD, LWORD, SINT, USINT, INT, UINT, DINT, LINT, ULINT or UDINT.
MUX selects the Kth value from among a group of values.
Result is 30
LD 0
MUX 30 ,
40 ,
50 ,
60 ,
70 ,
80
ST Var1
Var1:=MUX(0,30,40,50,60,70,80); (* Result is 30 *);
NOTE: An expression occurring ahead of an input other than INk will not be processed to save run time. Only in simulation mode will all expressions be executed.