Clear Filters
Clear Filters

Getting error message while running simulink model with Arduino Mega 2560

17 views (last 30 days)
I was trying to run simulink model connected to ARDUINO MEGA 2560. I get the following error message :
'The call to realtime_make_rtw_hook, during the after_make hook generated the following error: Could not connect to specified Arduino board. 2560 Verify that your board is connected to your host, and that the host COM port number and baud rate set in the model match the port settings in Windows.'
I manually set the COM port number in the model to match the port settings in Windows. I ran a=arduino('com1') before running simulink model and it passed. After running the model and the above error message, I tried a=arduino('com1') in command window again and got the following error:
'Open failed: Port: COM1 is not available. Available ports: COM3. Use INSTRFIND to determine if other instrument objects are connected to the requested device. Error using arduino (line 83) Could not open port: com1 '
A similar question in the forum was resolved by overwriting toolsinfodataArduinoMega2560.p in MATLAB/Targets/arduinomega2560/+realtime/+installer folder. I have .m file of same name instead of .p file in that folder. But replacing it with .p file didn't work aswell.
How to resolve this issue? Thanks

Answers (1)

Sreeram on 22 Jul 2014
Hi sharsad,
Could you please try the following to see if its because of a serial port object not being destroyed appropriately.
Steps : 1) Save and Close all the current open models 2) In the matlab command prompt try : clear all;clear classes;
If the above does not solve the issue. please check if restarting MATLAB session keeping the board connected helps.
Before trying any of the above it should be ensured that the drivers are rightly installed as well as the Arduino board shows up on the device manager with the current Com port number.
Hope this helps. Sreeram Mohan

Community Treasure Hunt

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

Start Hunting!