Skip to main content

7.7.5 MUX

Function

Select one function from multiple selections, select the input pin number based on the value of K, and assign it to OUT. If K equals 1, the value of the IN1 pin is obtained, similar to OUT:=IN1, and so on. When the value of K is not equal to the pin number, OUT:=DFLT

LD graphics

Alt text

Parameter description

Interface variableDeclarationData typeDescription
KVar_InputUINTSelect the output object
DFLTVar_InputANY_ELEMENTARYIf K is not in the range [1...n], the object of OUT output
IN1Var_InputANY_ELEMENTARYObject to be selected
IN2Var_InputANY_ELEMENTARYObject to be selected
Function nameReturn valueANY_ELEMENTARYOutput the selected object
warning
  • The parameter types of parameters DFLT, IN1, IN2 and OUT must be the same, otherwise the function cannot be executed
  • MUX is an extensible function, and inputs can be added by clicking the "+" in the graph
  • ANY_ELEMENTARY includes all basic types (bit strings, integers, floating point numbers, characters and strings, times and dates)

Example

  • LD sample animation is as follows:

alt text

  • ST example is shown in the following code:
OUT:=MUX(
K:=4,
DFLT:=1,
IN1:=10,
IN2:=100
);
OUT2:=MUX(
K:=4,
DFLT:=1,
IN1:=10,
IN2:=100,
IN3:=1000,
IN4:=10000,
IN5:=50000
);