Problem connecting to Arduino Mega 2560 using the Simulink Support package
10 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I am trying to program a simple serial stream in Simulink, which is intended to be programmed onto an Arduino and print the stream on Serial 1. However, I am having trouble connecting to the Arduino in Simulink. I have tried the "Connect" button under Hardware - Run on Hardware, but I receive the following error:
Model Action Rebuild Reason
=============================================================================
ArduinoODrive Code generated and compiled Generated code was out of date.
1 of 1 models built (0 models already up to date)
Build duration: 0h 0m 13.541s
=== Model Save (ArduinoODrive) (Elapsed: 0.112 sec) ===
=== Simulation (Elapsed: 34 sec) ===
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.
I am not sure if this could be related to the baud rate of the Arduino. I have set the baud rate to 115200 in device manager, and ensured the Application Download baud rate in Hardware Settings is also set to 115200. I have also tried changing Connected I/O communication, External Mode over Serial, or PIL communication to be set to 115200, but this causes a different error:
Model Action Rebuild Reason
=============================================================================
ArduinoODrive Code generated and compiled Generated code was out of date.
1 of 1 models built (0 models already up to date)
Build duration: 0h 0m 13.443s
=== Simulation (Elapsed: 9 sec) ===
Error:The model that you are trying to run in External mode does not match the application running on your target. Checksum test (TARGET_DATA_MAP) failed. The host model's structural checksum is [3275053445, 432961726, 1886467804, 2800626016] and the target application's structural checksum is [1560877088, 2889573147, 1495144667, 3729665762]. Rebuild the model, run it on your target, and start External mode simulation again.
I am not sure how to proceed with fixing these two errors. Any advice would be greatly appreciated.
0 comentarios
Respuestas (1)
arsal javed
el 11 de Jul. de 2022
hi Nathan
just go to the command line and enter the following command
codertarget.arduinobase.registry.setBaudRate('your simulink filename',9600);
after that baudrate will be set and u will not get this error anymore
the problem here is the baudrate setting
0 comentarios
Ver también
Categorías
Más información sobre Arduino Hardware en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!