3.0

3.0 | 2 ratings Rate this file 77 Downloads (last 30 days) File Size: 1.48 KB File ID: #24638
image thumbnail

Arduino meets MATLAB

by Sreeram Mohan

 

04 Jul 2009 (Updated 25 Sep 2009)

Matlab Linked to Arduino

| Watch this File

File Information
Description

The current submission illustrates a way to use the popular open source arduino boards with MATLAB illustrating the capabilities of data acquisition and visualization in real time .

The Arduino Demilanove based on the ATMEGA 328 is used to send a series of time series through the serial interface and the matlab code acquires the data and performs a meaningful part of the same at a baud rate of 9600.

There are quite a few things that could be made more visually appealing by using Matlab with the microcontrollers !

I was happy to get my board at a low cost not bearing much custom duties and i have listed the vendor who markets them in India !

MATLAB release MATLAB 7.4 (R2007a)
Other requirements Arduino IDE for the controller ! Arduino Demilanove Hardware platform from TENET TECHNETRONICS INDIA www.tenettech.com
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (11)
30 Oct 2009 Daniel McKenna

Do you have the Arduino side of this code? I get a timeout when I try to read in the serial data using the serial.write() on the arduino. Is there a end of line that is required by Matlab?

03 Nov 2009 Sreeram Mohan

Hi Daniel,

You could look at the snap shot with the file-submission and the c-code is clearly visible.

hope this helps,

cheers,
Ram

06 Nov 2009 Daniel McKenna

Thanks Ram. I was using code similar to the screen shot and it was not solving the timeout problems. It took me quite some time to figure this out but here's what was happening (In case anyone else cares):

The Arduino Starts sending serial messages on bootup. If Matlab is stated after the Arduino Matlab has a lot of trouble framing the Serial messages. What does work is to reset the arduino, and then while the bootloader is starting up, open the serial port. That way Matlab doesn't time out and it gets the first reading for the arduino. Another solution is to implement some sort of handshaking.

09 Nov 2009 Sreeram Mohan

Hi Daniel,

A simple fix to the problem faced is to make the arduino to get a start command from the matlab and then start the communication from the arduino end.I have had success doing this and may be post an other sketch to the file exchange.

Cheers !
Ram

25 Oct 2010 Gautam Vallabha

See here for another freely downloadable implementation of a MATLAB <-> Arduino interface over a USB serial cable:
http://www.mathworks.com/academia/arduino-software/arduino-matlab.html

18 Mar 2011 fremond khoo

hi and good day to all,

i want to ask about the interface with arduino and matlab..i am now trying to get the data from potentiometer which is attached at my stepper motor shaft..can anybody tell me how to get the data from potentiometer through arduino board to my computer(MATLAB) and try to plot the graph at the same time?..i have the code to plot the graph but i cant run both files at the same..

either i run my motor or get data from potentiometer by turning the potentiometer myself..so how do i solve this??..

anyone would be so kind to help out here??

thanks in advance^^

28 May 2011 Alex is

Hi I am trying to generate sine waves from matlab and input into the arduino uno. can someone please help me in describing the procedure?

28 May 2011 Alex is

is it technically possible I mean?

14 Jul 2011 Sreeram Mohan

hi fremond khoo ,

Potentiometers are generally analog inputs which can be easily read through the pins on the arduino ! refer to the analogIn functions and a simple schematic on the arduino playground on how to do it !

Further the only interface through which the arduino can talk to any other software on a host (PC) is basically through the serial port.

so having said that
analogin --> Arduino --> serial.print --> matlab code

should be the psuedo path !

Hope this helps !

--sreeram

14 Jul 2011 Sreeram Mohan

Hi Alex is ,

Looks like what u need to do is the reverse of what my file submission does !

Instead of the fscanf u could do a fprintf to the com port that is assigned to the arduino on the PC and pass in the sinewave values from matlab !

Hope this helps !

--sreeram

15 Feb 2012 Suresh

I don't see anything on the graph.

I have a Microcontroller board(Arduino Uno) that sends data between 1 - 1024(digits)for every 1000 mili seconds to the COM port 5 of Windows XP PC.

I want to receive this data in to MatLab and display a graph of Time versus Data. I want to display both Static and Dynamic or whichever is possible easily.

Please login to add a comment or rating.
Updates
25 Sep 2009

Just added some places to find these boards in INDIA .

Tag Activity for this File
Tag Applied By Date/Time
arduino Sreeram Mohan 06 Jul 2009 11:49:56
microncontroller Sreeram Mohan 06 Jul 2009 11:49:56
data acquisition Sreeram Mohan 06 Jul 2009 11:49:56
measurement Sreeram Mohan 06 Jul 2009 11:49:56
arduino ash blanco 08 Jul 2011 05:30:52
data acquisition ash blanco 08 Jul 2011 05:30:57
measurement ash blanco 08 Jul 2011 05:31:01
microncontroller ash blanco 08 Jul 2011 05:31:09
arduino marco flores 17 Oct 2011 01:56:58
arduino Adriano Ferreira 20 Dec 2011 14:16:38

Contact us at files@mathworks.com