Hi friends!

I have just found and tested a Blockset that interfaces MATLAB/SIMULINK and Arduino. You may find this at:


I highly suggest this program since it offers rapid prototyping capabilities to the famous and cheap arduino. The guys have build a block that interfaces with the Real Time Workshop of MATLAB and have also implemented C functions for all arduino operations (analog in, out, serial read/write etc.). Despite the fact that the code is obviously bigger one can gain advantage from the quick and abstract way of programming that simulink offers. It is a good work!

Happy coding!

Views: 16817

Comment by Mikael Mannberg on December 1, 2009 at 10:19am
Doesn't work on OS X/Linux :(
Comment by Jason Larocque on December 1, 2009 at 4:47pm
How do you wire up the Arduino and the MATLAB ? Is it with the FTDI cable ? Is there any Servo Output / PWM ? Do you need to erease the code in the Arduino to be able to use the MATLAB tool?
Comment by Dale on December 1, 2009 at 11:23pm
can get matlab for linux. but it's big $$$ regardless of os. can get a student version for cheap or free. the arduino tool is only tested / used so far in windows per the listing in mathworks exchange, but pretty sure no huge reason it shouldn't work in linux, the arduino ide does work in linux fine. go for it. if I get around to trying that, i would be using matlab on windows, so may as well flash straight from there.

matlab real time workshop (RTW) is for autocoding, creating c or other code from graphical simulink and stateflow control models. make and test a control scheme or part of the code, or some fancy calculations, and mathworks creates the code for the target controller. good way to fill up an arduino, but the advantage is how easy it should be, once rtw is set up and working, very quick & easy to make things without typing out lots of code manually. If you're familiar with matlab simulink stateflow, it could be very handy. Otherwise, might do just as well writing code normal way, getting matlab and figuring it out would be a good investment, but could be a lot of time by itself.

There's not anything to wire up differently, use the ftdi cable. Think must be able to use parts of program in c / arduino language, and other parts autocoded. Everytime you flash new program to arduino, you erase it, except leave the bootloader basic program still there.

it looks like it piggybacks on the existing arduino ide. here's more description on it.

Anyway, I think I may try this sometime. Thanks for finding this!
Comment by Dale on December 1, 2009 at 11:26pm
probably just simple 'include' would allow portions or all of the existing ardupilot code to be used, with autocoded parts hooked in. not sure till try it though, just suspect that's a way.
Comment by Kostas Alexis on December 2, 2009 at 1:27am
guys it is just straight forward, you install, you design on simulink and - if everything has gone well - you compile, build and download on arduino.
Comment by lionel on December 2, 2009 at 3:03am
It would be great if the same existed for Scilab ( http://www.scilab.org/ )
Comment by Roberto Hawkowski on December 2, 2009 at 4:35am
I think Arduino Target is very good start. Author Doug Eastman must be congratulated.

Those who have formal/deeper understanding in flight control theory may use this tool in Matlab/Simulink to create better controller algorithms.

According to the following figure

the current version of Arduino Target only support analog and digital input/analog, serial read/write and serial config blocks. However, the ZIP file of the Arduino Target further contains a servo output block.

It seems to be that Arduino Target does not support interrupts. May be someone with real experience on Arduino Target can correct me.

I am looking forward to see people sharing their Matlab/Simulink based control applications.
Comment by Christopher Korpela on January 7, 2010 at 6:03am
Has anyone been able to get the servo output block to work? How do you add it to the Arduino library? I can get the serial write and digital output (blink LED) working no problem. I am also looking for a PID model to use with my Arduino in Simulink. The goal is to read in wheel encoders (quadrature encoding) and output PWM to control DC motors to implement a cruise controller.
Comment by Sergio Biagioni on April 9, 2014 at 4:39pm

Update for Future Viewers of this thread: The current release of Simulink has the Arduino Support Package built into it which means you don't need to grab the files from the File Exchange for basic functionality. All you need to do is MATLAB and Simulink, and then type >> targetinstaller at the MATLAB Command Window and it guides you through the setup process.

If you're a student, you can purchase the Student Version. If you're not a student and are using it for personal use (non-commercial, non-academic), you can purchase MATLAB Home at a low price.

@Christopher: Example Quadrature Encoder blocks are provided in the Device Driver guide in the File Exchange. The "Continuous Servo Write" block can be used with a motor controller which takes in servo protocol (i.e. ESC) to control DC motors. I have tried this and it works well. The trick is to make sure that the ground pin from the Arduino, the negative terminal on the Battery and the ESC ground input line are all connected together.


You need to be a member of DIY Drones to add comments!

Join DIY Drones

© 2018   Created by Chris Anderson.   Powered by

Badges  |  Report an Issue  |  Terms of Service