top of page
Writer's pictureLMS Solution

Using Multiport in Simulink for Signal Selection

Using Multiport in Simulink for Signal Selection


1. Setting Up the Model in Simulink

Creating a New Model

  1. Open MATLAB and Simulink

  • Launch MATLAB and open Simulink by clicking on the Simulink icon.

  1. Create a Blank Model

  • Click on "Blank Model" to start a new project.



Adding Components

  1. Insert a Multiport Switch

  • Go to the "Library Browser" and navigate to "Signal Routing."

  • Drag and drop the "Multiport Switch" block into your model.

  1. Configure the Multiport Switch

  • The Multiport Switch block consists of two types of ports:

  • Control Port: Determines which input is selected.

  • Data Ports: The actual inputs to choose from.

  • By default, there are three data ports, but you can adjust this to your needs.

2. Connecting Inputs and Outputs

Setting Up Signal Inputs

  1. Add Input Signals

  • For demonstration, add three different signal sources:

  • Sine Wave: Set the frequency to 1 kHz and amplitude to 1.

  • Triangular Wave: Set the frequency to 1 kHz and amplitude to 1.

  • Square Wave: Set the frequency to 1 kHz and amplitude to 1.

  • Connect these signals to the data ports of the Multiport Switch.

  1. Add a Control Signal

  • Use a "Repeating Sequence" block to generate the control signal.

  • Configure it to output values in a sequence (e.g., 1, 2, 3, 2, 1) with a sample time of 2 seconds.

  1. Connect the Control Signal

  • Connect the output of the Repeating Sequence block to the control port of the Multiport Switch.

Setting Up the Scope

  1. Add a Scope Block

  • Drag and drop the "Scope" block into your model.

  • Connect the output of the Multiport Switch to the scope to visualize the selected signal.

  1. Configure the Scope

  • Set up the scope with two layouts to view both the control input and the output.

  • Adjust the scale and style as needed for clarity.

3. Running the Simulation

Configure Simulation Settings

  1. Adjust Simulation Parameters

  • Go to "Model Configuration Parameters."

  • Set the maximum step size to 1e-5 for better accuracy.

  1. Run the Simulation

  • Click the "Run" button to start the simulation.

  • Observe the results in the scope.

Results and Discussion

  1. Observing Output Changes

  • When the control signal is 1, the output will be the sine wave.

  • When the control signal is 2, the output will be the triangular wave.

  • When the control signal is 3, the output will be the square wave.

  • The Multiport Switch routes the selected input based on the control signal, allowing you to see the different waveforms as specified.

  1. Output Analysis

  • The scope will display the selected signal based on the control input, demonstrating how the Multiport Switch routes different signals effectively.

3 views0 comments

Comments


bottom of page