MATLAB Answers

Getting error while running Arduino in external mode in simulink(r2012b)

8 views (last 30 days)
shri raje
shri raje on 29 May 2013
Answered: Rok Avsec on 20 Dec 2018
Respected sir, I am getting following error when I am trying to communicate arduino mega 2560 with simulink in external mode, I have also followed all instruction provided in manual(from matlab) error:- "Error occurred while executing External Mode MEX-file 'ext_serial_win32_comm':Timed-out waiting for first connect response packet." ,plz help

Sign in to comment.

Answers (3)

Gergely Takács
Gergely Takács on 13 Feb 2014
Hello all;
Same problem here. The external mode does work with certain very simple models. For example an analog input>double conversion>Embedded function for a y = u(5/1024); voltage conversion> scope combination works flawlessly. However, as soon as I add another analog input, I get the same error as sri. The minimum not working example is two analog inputs with two scopes. The exact procedure goes like this: the building process is successful, and it says " Model Successfully Downloaded to Arduino Mega 2560 ". But then, upon trying to connect to the board, the process hangs at " Initializing " and after a while I get " Error occurred while executing External Mode MEX-file 'ext_serial_win32_comm': Timed-out waiting for first connect response packet. " I've also tried to run a simple embedded function with an extended Kalman filter inside (no inputs or outputs on Arduino) and a scope, but the same thing happened.
  • MATLAB Version: (R2012b)
  • Operating System: Microsoft Windows 7 Version 6.1 (Build 7601: Service Pack 1)
  • Java Version: Java 1.6.0_17-b04 with Sun Microsystems Inc. Java HotSpot™ 64-Bit Server VM mixed mode
  • Board: Arduino Mega 2560
  • Fixed Step Discrete Solver (tried 1, 0.1 sec)
  • External mode enabled.
  • Baud rates 9600
  • Overrun detection enabled, on pin 13
  • Computer Lenovo ThinkPad T410i
Any help would be much appreciated.
  1 Comment
Loup Letac
Loup Letac on 9 Apr 2017
Any news about this problem ? I have the same, even with one analog input and one output. But the program does compile properly.
Thank you
MATLAB Version: (R2016b)
MATLAB License Number: ••••••
Operating System: Microsoft Windows 7 Professional Version 6.1 (Build 7601: Service Pack 1)
Java Version: Java 1.7.0_60-b19 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
MATLAB Version 9.1 (R2016b)
Simulink Version 8.8 (R2016b)

Sign in to comment.

Rolfe Dlugy-Hegwer
Rolfe Dlugy-Hegwer on 28 Aug 2013
Thanks for your message, Shri. It looks like a problem with the physical connection or configuration. First test that you can run a model on the Mega 2560, without External mode. Then, enable External mode using ONLY those settings mentioned in


Community Treasure Hunt

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

Start Hunting!