Error occurred while executing External Mode MEX-file 'ext_comm'

27 ビュー (過去 30 日間)
ben
ben 2024 年 3 月 21 日
回答済み: Raj 2024 年 4 月 22 日
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.

回答 (1 件)

Raj
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.

カテゴリ

Help Center および File ExchangeArduino Hardware についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by