Pages: [1]   Go Down
Author Topic: Sending data from Matlab to Arduino?  (Read 2770 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 1
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi all,

To start off, I'll let you know that I have extremely minimal experience with both Matlab and Arduino.  This is the first project I've used either, and am still trying to grasp a basic understanding of how the data would be captured and transmitted by Matlab.

I am using a webcam to analyze the position of an object, and based on the data from Matlab, I want Arduino to control a motor's speed and direction.  I found a great tutorial for the type of motor I'm using (a stepper bipolar motor) so all I need to be passed from Matlab to Arduino is one integer.

Is this going to be easy?  A point in the direction of a tutorial on this subject would be a great starting point for me.

Thanks!
Logged

0
Offline Offline
Tesla Member
***
Karma: 118
Posts: 8962
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Use the search function at the top of this page and search for matlab. Lot of postings in the past.
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

0
Offline Offline
Faraday Member
**
Karma: 13
Posts: 2857
ruggedcircuits.com
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

MATLAB has published this in their community site:

http://www.mathworks.com/matlabcentral/fileexchange/24638-arduino-meets-matlab

--
The Quick Shield: breakout all 28 pins to quick-connect terminals
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 5
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

UPDATE: There are now 2 official and native ways to interact with the Arduino From MATLAB and Simulink. You can download the code for free form the mathworks web site (under Academia -> Hardware). I will give explicit links later.

MATLAB Interface for Arduino
This lets you control your Arduino board over USB from a MATLAB session, in either Windows, Mac or Linux. For example you can instantiate an Arduino object from MATLAB using:

>> a=arduino('COM5');

and then do stuff like:

>> av=a.analogRead(5);

>> a.pinMode(13,'output');
>> a.digitalWrite(13,1);

>> delete(a)

or if you have a ladyada motor shield:

>> a.servoAttach(1);
>> a.servoWrite(1,45);

>> a.motorSpeed(4,200)      
>> a.motorRun(4,'forward');    

>> a.stepperSpeed(1,10)      
>> a.stepperStep(1,'forward','double',100);

Arduino Target for Simulink
This lets you use Simulink to create programs that run directly on the Arduino board.

In other words this package (available for Windows only) allows a Simulink model (and possibly also Embedded Matlab Code) to be automatically converted to C/C++ code, compiled and downloaded to the Arduino. This is especially useful for control application that need to run at high sampling rate, and in cases where you don't want the Arduino to be connected to a host computer.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 5
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

LINKS

MATLAB Interface for Arduino:
http://www.mathworks.com/academia/arduino-software/arduino-matlab.html

You can also download these slides:
http://www.mathworks.com/matlabcentral/fileexchange/27843
or look at this video to learn more:
http://www.mathworks.com/company/events/webinars/wbnr43537.html

Arduino Target for Simulink
This lets you use Simulink to create programs that run directly on the Arduino board. You can download the code for free here :
http://www.mathworks.com/academia/arduino-software/arduino-simulink.html

You can also look at the Arduino playground wiki:
http://www.arduino.cc/playground/Interfacing/Matlab
Logged

Pages: [1]   Go Up
Jump to: