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 件のコメント

Juan Israel García Celedón
Juan Israel García Celedón 2021 年 11 月 28 日
編集済み: Walter Roberson 2021 年 11 月 28 日
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);
Walter Roberson
Walter Roberson 2021 年 11 月 28 日
Have you used
arduinosetup
Juan Israel García Celedón
Juan Israel García Celedón 2021 年 11 月 28 日
Yes, I have
Walter Roberson
Walter Roberson 2021 年 11 月 28 日
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 ?
Juan Israel García Celedón
Juan Israel García Celedón 2021 年 11 月 29 日
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
Walter Roberson
Walter Roberson 2021 年 11 月 29 日
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"
Juan Israel García Celedón
Juan Israel García Celedón 2021 年 11 月 30 日
It seems like it is available.
Walter Roberson
Walter Roberson 2021 年 11 月 30 日
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.
Juan Israel García Celedón
Juan Israel García Celedón 2021 年 11 月 30 日
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?
Walter Roberson
Walter Roberson 2021 年 11 月 30 日
Try using 'BaudRate' when you arduino()
Juan Israel García Celedón
Juan Israel García Celedón 2021 年 11 月 30 日
How do I do that?
Walter Roberson
Walter Roberson 2021 年 11 月 30 日
a = arduino('COM4', 'Mega2560', 'BaudRate', 38400);
or whatever baud rate you had set the arduino to. Try 9600, 38400, 19200
Juan Israel García Celedón
Juan Israel García Celedón 2021 年 11 月 30 日
Well, that didn't work :/

サインインしてコメントする。

回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeArduino Hardware についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by