Signal Routing with Mux, Demux, and Switch in Simulink
📖 Scenario: You are working on a simple signal routing system in Simulink. You want to combine multiple signals, select one signal based on a control input, and then split the combined signal back into individual signals.
🎯 Goal: Build a Simulink model that uses a Mux block to combine three input signals, a Switch block to select one signal based on a control input, and a Demux block to split the output signal back into separate signals.
📋 What You'll Learn
Create three constant input signals with values 1, 2, and 3.
Use a Mux block to combine the three signals into one vector signal.
Add a control signal to select which input passes through the Switch block.
Use a Demux block to split the output of the Switch block back into individual signals.
Display the final output signals using Display blocks.
💡 Why This Matters
🌍 Real World
Signal routing is essential in control systems, communication systems, and data processing to manage multiple data streams efficiently.
💼 Career
Understanding how to use Mux, Demux, and Switch blocks in Simulink is important for engineers working in embedded systems, automation, and signal processing.
Progress0 / 4 steps
1
Create three constant input signals
Create three Constant blocks named const1, const2, and const3 with values 1, 2, and 3 respectively.
Simulink
Hint
Use three Constant blocks and set their Value parameters to 1, 2, and 3.
2
Add a Mux block to combine signals
Add a Mux block named mux1 and connect the outputs of const1, const2, and const3 to its inputs.
Simulink
Hint
Use a Mux block with 3 inputs and connect each constant output to one input.
3
Add a Switch block with control input
Add a Switch block named switch1. Create a Constant block named control with value 2. Connect the output of mux1 to the first input of switch1 and the control block to the control input of switch1.
Simulink
Hint
Use a Switch block and a control Constant block with value 2. Connect mux output to switch input and control to switch control input.
4
Add Demux block and display outputs
Add a Demux block named demux1 with 3 outputs. Connect the output of switch1 to demux1. Add three Display blocks named disp1, disp2, and disp3. Connect each output of demux1 to one Display block. Finally, run the simulation and print the output values of the displays.
Simulink
Hint
Use a Demux block with 3 outputs, connect the switch output to it, then connect each output to a Display block. Run the simulation and print the display values.
Practice
(1/5)
1. What is the main purpose of a Mux block in Simulink signal routing?
easy
A. To select one signal from multiple inputs based on a condition
B. To split one signal into multiple signals
C. To combine multiple signals into one signal
D. To delay a signal by a fixed time
Solution
Step 1: Understand the function of Mux
A Mux block takes several input signals and combines them into a single output signal vector.
Step 2: Compare with other blocks
Demux splits signals, Switch selects signals, and Delay delays signals. Only Mux combines signals.
Final Answer:
To combine multiple signals into one signal -> Option C
What will be the value of demux_out[1] (the second output of Demux)?
medium
A. 3
B. Error: Index out of range
C. 5
D. 7
Solution
Step 1: Understand Mux output
Mux combines inputs [3, 7, 5] into a vector: mux_out = [3, 7, 5].
Step 2: Understand Demux output
Demux splits mux_out back into separate outputs: demux_out[0]=3, demux_out[1]=7, demux_out[2]=5.
Final Answer:
7 -> Option D
Quick Check:
Second Demux output = 7 [OK]
Hint: Mux packs inputs; Demux unpacks in same order [OK]
Common Mistakes:
Mixing up output indices (0-based vs 1-based)
Assuming Demux changes order
Expecting error due to indexing
4. You have a Switch block with inputs: Input1=10, Input2=20, and a control signal Control=0. If the Switch block is configured to output Input1 when Control is 0, but the output is always 20, what is the likely error?
medium
A. Control signal logic is inverted or misconfigured
B. Input1 and Input2 are swapped in the block
C. Switch block cannot handle numeric inputs
D. Control signal is not connected
Solution
Step 1: Analyze expected Switch behavior
With Control=0, output should be Input1=10, but output is 20 (Input2).
Step 2: Identify cause of wrong output
This suggests the control logic is inverted or misconfigured, causing the block to select Input2 when Control=0.
Final Answer:
Control signal logic is inverted or misconfigured -> Option A
Quick Check:
Wrong output means control logic error = D [OK]
Hint: Check control logic polarity if Switch output is unexpected [OK]
Common Mistakes:
Assuming inputs are swapped without checking control
Thinking Switch can't handle numbers
Ignoring control signal connection
5. You want to build a Simulink model that takes three sensor signals and selects one to output based on a control signal (0, 1, or 2). Which combination of blocks correctly achieves this?
hard
A. Use a Demux to split sensors, then multiple Switch blocks to select output
B. Use a Mux to combine sensors, then a Multiport Switch block with control signal to select output
C. Use a Mux to combine sensors, then a Switch block with control signal to select output
D. Use three Switch blocks each connected to one sensor, controlled by the same control signal
Solution
Step 1: Understand the requirement
We need to select one of three sensor signals based on a control signal with values 0, 1, or 2.
Step 2: Evaluate block combinations
A Multiport Switch block can select one input from many based on control. Combining sensors with Mux then using Multiport Switch fits this need.
Step 3: Why other options fail
Use a Mux to combine sensors, then a Switch block with control signal to select output uses a simple Switch which only selects between two inputs, not three. Use a Demux to split sensors, then multiple Switch blocks to select output uses Demux incorrectly. Use three Switch blocks each connected to one sensor, controlled by the same control signal uses multiple Switches but control signal can't select one cleanly.
Final Answer:
Use a Mux to combine sensors, then a Multiport Switch block with control signal to select output -> Option B
Quick Check:
Multiport Switch selects among many inputs = A [OK]
Hint: Use Multiport Switch for multiple input selection [OK]
Common Mistakes:
Using simple Switch for more than two inputs
Misusing Demux for selection
Trying multiple Switches with one control signal
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.