Problem with de argument port?

Encounter this error when i tried to connect my arduino board with my matlab: Unable to create a communication link with the serial port. Please check the input argument PORT and verify that a device is connected.
Can anyone solve this?

13 Comments

My code:
a = arduino;
in_cero = 0;
in_hombro = 130;
in_brazo = 180;
in_mano1 = 90;
s_cuerpo = servo(a,'D2');
writePosition(s_cuerpo,(in_cero/180));
s_hombro = servo(a,'D3');
writePosition(s_hombro, in_hombro/180);
s_brazo = servo(a,'D4');
writePosition(s_brazo,in_brazo/180);
s_alabeo = servo(a,'D5');
writePosition(s_alabeo,in_mano1/180);
s_elevacion = servo(a,'D6');
writePosition(s_elevacion,in_cero/180);
s_cabeceo = servo(a,'D7');
writePosition(s_cabeceo, in_cero/180);
s_pinza = servo(a,'D8');
writePosition(s_pinza, in_cero/180);
Have you used
arduinosetup
Which port did arduinosetup identify for use with your installed device? Have you tried hardcoding that port name in the arduino() call ?
Also, are you using Windows, or are you using Mac or Linux ?
Which port did arduinosetup identify for use with your installed device?
It is the COM4 port.
Have you tried hardcoding that port name in the arduino() call ?
Yes, I have, and Matlab showed me the same message. Just to be sure, it is like this: a = arduino('COM4','Mega2560');
Also, are you using Windows, or are you using Mac or Linux ?
I'm usign Windows
If arduinosetup was able to communicate with the port, but MATLAB is not able to communicate, then I do not know what is going on -- other than the possibility that the port is already in use ?
freeports = serialportlist("available")
freeports = "/dev/ttyS0"
It seems like it is available.
Sorry, the only other possibility is that coming to mind is the possibility of mismatch on baud rate, if the arduino has somehow been configured to an unusual rate... but then I would expect problems with the configuration process.
I configured the arduino with a different rate one month ago. I changed because when I wanted to use "arduinosetup" Matlab was giving me an error. Do you want me to show you the rate I changed it for?
Try using 'BaudRate' when you arduino()
a = arduino('COM4', 'Mega2560', 'BaudRate', 38400);
or whatever baud rate you had set the arduino to. Try 9600, 38400, 19200
Well, that didn't work :/

Sign in to comment.

Answers (0)

Categories

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!