MUX (Multiplexer)
Selects one of N input values based on an integer selector index.
The MUX (Multiplexer) function selects one of multiple input values based on an integer selector input (K). When K=0, IN0 is selected; when K=1, IN1 is selected; and so on. MUX extends the binary selection of SEL to support multiple choices. It is used for recipe parameter selection, multi-mode operation, selecting between multiple sensor inputs, and implementing lookup-table logic without using arrays.
Parameters
Inputs
| Name | Type | Description |
|---|---|---|
| K | INT | Selector index (0 to N-1) |
| IN0 | ANY | Value selected when K=0 |
| IN1 | ANY | Value selected when K=1 |
| IN2 | ANY | Value selected when K=2 |
| INn | ANY | Additional inputs as needed |
Outputs
| Name | Type | Description |
|---|---|---|
| OUT | ANY | Selected input value |
Structured Text Example
// Select speed based on gear position
Motor_Speed := MUX(K := Gear_Position,
IN0 := 0.0, // Neutral
IN1 := 500.0, // Low speed
IN2 := 1000.0, // Medium speed
IN3 := 1500.0 // High speed
);
// Equivalent CASE statement:
CASE Gear_Position OF
0: Motor_Speed := 0.0;
1: Motor_Speed := 500.0;
2: Motor_Speed := 1000.0;
3: Motor_Speed := 1500.0;
END_CASE;20 Production-Ready Ladder Logic Templates
Stop writing the same rungs from scratch. Get copy-paste-ready templates for motor control, PID loops, safety interlocks, conveyors, and more.
Platform-Specific Implementation
Siemens (TIA Portal)
Use MUX instruction in TIA Portal. Available in FBD and SCL.
Allen-Bradley (Studio 5000)
No direct MUX; implement with CASE/CMP and MOV instructions.
CODESYS
Use MUX() function in ST. Supports variable number of inputs.
Common Applications
- Recipe parameter tables
- Multi-speed selection
- Multi-mode operation parameters
- Sensor input selection
- State-dependent output values
Frequently Asked Questions
What is MUX (Multiplexer) in PLC programming?
Selects one of N input values based on an integer selector index. The MUX (Multiplexer) function selects one of multiple input values based on an integer selector input (K). When K=0, IN0 is selected; when K=1, IN1 is selected; and so on.
What are common applications of MUX (Multiplexer)?
MUX (Multiplexer) is commonly used for: Recipe parameter tables, Multi-speed selection, Multi-mode operation parameters, Sensor input selection, State-dependent output values.
How do I use MUX (Multiplexer) in different PLC platforms?
Siemens: Use MUX instruction in TIA Portal. Available in FBD and SCL. Allen-Bradley: No direct MUX; implement with CASE/CMP and MOV instructions. CODESYS: Use MUX() function in ST. Supports variable number of inputs.
Related Function Blocks
SEL (Binary Selector)
Selects between two values based on a boolean condition: FALSE=IN0, TRUE=IN1.
View Reference →MAX (Maximum Selection)
Returns the larger of two or more input values.
View Reference →MIN (Minimum Selection)
Returns the smaller of two or more input values.
View Reference →LIMIT (Value Limiter)
Constrains input value to specified minimum and maximum range.
View Reference →Stop Writing Ladder Logic From Scratch
Get 20 production-ready ladder logic templates for $29 -- download instantly and use them on your next project today.
Instant download - 30-day money-back guarantee - Use on unlimited projects