MATLAB: Arduino Nano won’t work with simulink Arduino Support Package

arduinomakersimulinksupport package

Hi, I'm trying to connect my Arduino Nano to Simulink using the Arduino Support package, but when i try to upload the program, it shows the following 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.
Component:Simulink | Category:Block diagram error
Unable to connect to the 'Arduino Nano 3.0' target for 'Caracterizacion'.
%
I've already changed the Model configuration parameters to Arduino ano 3.0 I've already set the COM port to the one connected to the Arduino and also I've set the Simulation mode to external.
I know that the Arduino is working because i've tried it using the Arduino IDE, I think the problem is setting the processor (Changed it from ATmega328P TO ATmega328P (old bootloader)), because that's what i had to do in the Arduino IDE in order to make the Nano work, but i don't know how to change the processor from Simulink.
Thanks in advance for any help you can provide.

Best Answer

Okay, I think i found the answer!! This issue depends solely on the Arduino board. In my case I was using an Arduino nano with a CH340G chip. The default settings on the simulink package have the baud rate set at 921600 and the Arduino boards that have the CH340G chip can support a maximum baud rate of 230400, then it is necessary to set the baud rate of the simulink model at 230400 or less if the error still appears. This is the link where I found the solution, hope this results useful for you!!
https://la.mathworks.com/matlabcentral/answers/351957-do-simulink-deploy-to-hardware-and-external-modes-work-with-arduino-uno-clones