Connecting Simulink to USB and COM Ports: A Beginner's Guide

  • Thread starter Gean
  • Start date
  • Tags
    Simulink
In summary, the conversation discusses using MATLAB and Simulink to connect a USB device. It is suggested to use the built-in MATLAB serial functions and documentation is provided. The issue of only being able to connect to COM ports 1-8 is addressed and a solution is given for changing the port number. However, there is still confusion on how to use the built-in MATLAB functions.
  • #1
Gean
5
0
Hello,

I'm new to working with MATLAB and simulink, but I'm trying to connect a USB device with Simulink. Is there any way to connect Simulink with either a USB-port or a COM-port?

Thanks in advance!
 
Physics news on Phys.org
  • #2
You can make use of the built-in MATLAB serial stuff (navigate using the left-hand panel--this just links to the first page):
http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_external/f105659.html

Note, as per the first page I linked to above, that you don't need the Instrument Control Toolbox (extended serial port features and graphical user interface) or Data Acquisition Toolbox if you're just looking to communicate via the serial port.
 
Last edited by a moderator:
  • #3
I tried to make a connection with COM-port, but the problem was that Simulink "sees" only COM port 1 to 8 or something. The connected device is at COM 11.
 
  • #4
You can change the port number of a device (well most devices)
control panel->system->hardware->device manager
Select the device (under Ports)->properties->port settings->click advanced

You might have to disable some other devices to free up a low numbered com port first
 
  • #5
mgb_phys said:
You can change the port number of a device (well most devices)
control panel->system->hardware->device manager
Select the device (under Ports)->properties->port settings->click advanced

You might have to disable some other devices to free up a low numbered com port first

Allright, i have the com-port set to COM2, which allows me to select it from 'Query Instrument'. However, it does not seem to work.

MATLABdude said:
You can make use of the built-in MATLAB serial stuff (navigate using the left-hand panel--this just links to the first page):
http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_external/f105659.html

Note, as per the first page I linked to above, that you don't need the Instrument Control Toolbox (extended serial port features and graphical user interface) or Data Acquisition Toolbox if you're just looking to communicate via the serial port.

Like i said, I'm new to the entire Matlab and Simulink thing. I really have no idea how to use the built-in Matlab stuff :(
 
Last edited by a moderator:
  • #6
Gean said:
Allright, i have the com-port set to COM2, which allows me to select it from 'Query Instrument'. However, it does not seem to work.
Like i said, I'm new to the entire Matlab and Simulink thing. I really have no idea how to use the built-in Matlab stuff :(

Right: which is why I link to the documentation! Read through the stuff on the left hand side under serial interface and you'll be able to find some examples to help you with your application.

EDIT: Whoops! Didn't realize that link didn't autoload the left-hand menu. Click the first link (What is the MATLAB Serial Port Interface) under the "On This Page" box to have the left-hand menu open up the Serial Port I/O pages.
 
Last edited:

1. How do I connect Simulink to a USB port?

To connect Simulink to a USB port, you will need to use a USB block in your Simulink model. This block allows you to send and receive data through the USB port. You will also need to make sure that the USB device drivers are installed on your computer.

2. Can I connect multiple USB ports to Simulink?

Yes, you can connect multiple USB ports to Simulink as long as each port has its own USB block in the model. You can also use a USB hub to connect multiple USB devices to one port.

3. How do I connect Simulink to a COM port?

To connect Simulink to a COM port, you will need to use a serial port block in your Simulink model. This block allows you to send and receive data through the COM port. You will also need to make sure that the correct COM port settings are configured in your model.

4. Can I use Simulink to control external devices through USB or COM ports?

Yes, Simulink can be used to control external devices through USB or COM ports. You will need to use appropriate communication protocols and communication blocks in your model to send commands and receive data from the external device.

5. Do I need any additional hardware or software to connect Simulink to USB and COM ports?

In most cases, you will not need any additional hardware or software to connect Simulink to USB and COM ports. However, if you are using custom devices or protocols, you may need to install additional drivers or use external communication hardware.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
932
  • Electrical Engineering
Replies
6
Views
863
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
6K
  • Programming and Computer Science
Replies
1
Views
730
Replies
1
Views
3K
  • Electrical Engineering
Replies
15
Views
883
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
5K
  • Programming and Computer Science
Replies
2
Views
827
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
6K
  • Electrical Engineering
Replies
2
Views
884
Back
Top