- https://www.mathworks.com/matlabcentral/answers/559907-error-occurred-while-executing-external-mode-mex-file-ext_comm-exttargetpktpending-call-failed
- https://www.mathworks.com/matlabcentral/answers/366909-why-does-external-mode-not-work-for-arduino-clones-when-using-simulink-support-package-for-arduino
Error occurred while executing External Mode MEX-file 'ext_comm'
26 次查看(过去 30 天)
显示 更早的评论
Hello,
i get this error every time I run the Model. I am basically trying to control a servo motor using a potentiometer and the shaft of the servo is connected to another potentiometer. so, in short i am trying to get the values on the display. Here's the error:
Error occurred while executing External Mode MEX-file 'ext_comm': Failed to connect to the target. A time-out occurred while waiting for the connection response from the target. Possible reasons for the time-out: a) The target is not switched on. b) The target is not connected to your host machine. c) The application for the model is not running on the target. You might have clicked the Stop button. If the Run button is not dimmed, click it. Otherwise, click the Build button, which downloads and runs your application on the target.
By using Build,Deploy and Start option I can control my servo but am unable to get the values onto the display. where as when I use Monitor and Tune I get the Above mentioned Error.
Thanks in Advance for your Assistance.
0 个评论
回答(1 个)
Raj
2024-4-22
Hi @ben
This problem occurs with certain Arduino board variants produced by third-party manufacturers that opt for a 'CH340' serial-over-USB chip, rather than the standard Atmega 16U2 chip. 'CH340' cannot handle baudrate greater than 230400. This is the reason that External mode fails.
You can check the default External mode baudrate by executing the following command-
>>codertarget.arduinobase.registry.setBaudRate(gcs)
If you want to change the baudrate to a lower value say 230400 then use the following-
>>codertarget.arduinobase.registry.setBaudRate(gcs,230400)
If External mode still doesn't work after setting the baud rate to 230,400, keep lowering the baud rate until it works.
You can also refer to the following resources regarding a similar user case-
I hope this resolves your query.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Arduino Hardware 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!