universal control unit serial port connection
1 view (last 30 days)
Show older comments
Hello,
I have a universal control unit and want to use information from v3d to MATLAB to send to the control box. The control box has C2 vibration motors that can fire based on the downloaded user interface. The serial port is 'COM3'. I have tried connecting MATLAB to the serial('COM3') by using
s = serial('COM3');
fopen(s);
fprintf(s,'*IDN?');
out = fscanf(s);
fclose(s);
delete(s);
clear s;
but I get the following error:
Error using serial/fopen (line 72)
Open failed: Cannot connect to the COM3 port. Possible reasons are another
application is connected to the port or the port does not exist.
Also, s.status returns as 'closed' but I want to know how to have the serial port 'open' to send MATLAB commands for the vibration motors to fire given a certain quantity in v3d.
Does anyone know what is going on here and how I can connect to the control unit?
0 Comments
Answers (2)
Rohan Kale
on 5 Aug 2017
Use instrfind() function to find out the status of the current port that you want to connect to. That will do.
0 Comments
Rock Rocky
on 6 Aug 2017
The port you are using (COM3) is busy because it is connected to another application. try to check a free port and use it instead of COM3. This will solve your problem.
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!