Code covered by the BSD License  

Highlights from
Arduino IO package: Slides and Examples

5.0

5.0 | 11 ratings Rate this file 528 Downloads (last 30 days) File Size: 2.26 MB File ID: #27843
image thumbnail

Arduino IO package: Slides and Examples

by

 

06 Jun 2010 (Updated )

Slides for the webinar: "Learning Basic Mechatronics Concepts Using the Arduino Board and MATLAB".

Editor's Notes:

This file was selected as MATLAB Central Pick of the Week

| Watch this File

File Information
Description

This zip file contains the slides (and some MATLAB examples) used for this webinar:

http://www.mathworks.com/videos/learning-basic-mechatronics-concepts-using-the-arduino-board-and-matlab-81717.html

The webinar introduces the ArduinoIO package, which allows the user to perform Analog and Digital Input and Output, as well as to control DC, Servo and Stepper Motors interactively from the MATLAB command window, without having to write, debug, compile, upload and run C programs.

The examples included is this file are taken from the "example" folder of the Arduino IO package.

NOTE: You can download the Arduino IO package from here: http://www.mathworks.com/matlabcentral/fileexchange/32374

Acknowledgements

This file inspired Teaching Mechatronics With Low Cost Hardware: Webinar Examples.

MATLAB release MATLAB 7.10 (R2010a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (58)
17 Oct 2014 Jacob

I have the same problem as wayan.

I'm using the ArduinoIO pacaage on Matlab2014a/Linux Ubuntu 12.04, Arduino Deumilanove

=arduino('/dev/ttyUSB0')
Attempting connection .............
Warning: Unsuccessful read: A timeout occurred before the Terminator was reached.
Error using arduino (line 104)
Connection unsuccessful, please make sure that the board is powered on, running a sketch provided with the package, and connected to the indicated serial
port. You might also try to unplug and re-plug the USB cable before attempting a reconnection.

The power indicator LED of the Arduino is ON, reconnecting USB and restarting computer don't work. What could be the problem??

30 Sep 2014 Soheil  
30 Sep 2014 Soheil

Hi Giampiero,

Thanks so much for this great package. I am willing to use an ArduinoUno board to control a step motor. I have installed the libraries and am able to run a DC motor with the motor_sim block without any problem. However, if I run the stepper_sim and try to run a Step motor, it will have a lot of delay until it realizes and executes the commands for its input. I also plugged in a good power supply for the motor shield since I thought it might be due to power shortage but it did not seem to fix the problem.

Bottom line is, The package works quite well with the DC motor but not working properly with the step motor.

Is there anything I am doing wrong?

06 Sep 2014 wayan

HELP...
I'm using Arduino UNO

when I enter

>> a=arduino('COM4');
Attempting connection .............
Warning: Unsuccessful read: A timeout occurred before the Terminator was reached.
Error using arduino (line 104)
Connection unsuccessful, please make sure that the board is powered on, running a sketch
provided with the package, and connected to the indicated serial port. You might also try
to unplug and re-plug the USB cable before attempting a reconnection.

15 Aug 2014 Giampiero Campa

Hi Colm, you should probably connect a good external power source to the motor shield.

Anyway, in the version1 of the motor shield library the stepper commands are blocking, so, while you can have 2 stepper connected, you can only operate them one at a time, not both at the same time.

I think (but I am not sure) that the same is true for the version 2 of the board.

Note that instead you can run up to 4 DC motor simultaneously since DC motor commands are not blocking.

15 Aug 2014 Colm

Hi,

I am using the ArduinoIO package and a Adafruit Motor Shield with 2 motors. I am having a little difficulty powering the motors. Is there anyway of having two simultaneous stepper motor outputs?

Thank you in advance

31 Jul 2014 Sina

Hi. Thanks for your help.
Actually, I haven't used that Arduino.m file since it didn't suggest to do so. Why should I change this?
Actually, the arduino libraries I have for the motor and encoder, have some functions integrated which can call some pin values as inputs and defines the PWM voltage values as outputs in order to be able to control the torque on the motor. I am not sure how to use this package to control torque instead of speed. Thanks again.

30 Jul 2014 MathWorks Classroom Resources Team

Hi Sina,
have a look at the section of the readme.txt file that concerns customizing the package. The bottom line is that you will have to rewrite parts of the sketch running on the arduino and maybe slightly modify the arduino.m class file.

Hope that helps.

28 Jul 2014 Sina

Hi Everyone,
I am using the arduino with a prototype shield to run and control a DC motor (wit built in encoder) which is driven by a pololu motor driver (http://www.pololu.com/product/1451).
Now, I am trying to use the Arduino IO package to be able to use matlab or simulink with my system.
Both the motor and the encoder have libraries available. I was wondering how I can use the IO package with matlab and have those libraries and commands integrated as well?
Thank you for your support in advance.
Sina

28 Jul 2014 Fyraj Fyraj  
14 Jul 2014 EDWIN ALVAREZ

vishnu vardhan before that, have you uploaded any sketh on arduino for Matlab Communication? example Adiosrv.ino or Adioes.ino? and have you copy the files arduino.m and install arduino in current folder or matlab?

21 May 2014 worawat

Hi All.
I get help . I'm using Arduino Mega 2560
Run on windown 7 64 bit and run on Matlab R2013a.
When i enter "a=arduino('com4')"
Attempting connection .............
Warning: Unsuccessful read: A timeout occurred before the Terminator was reached.
Error using arduino (line 104)
Connection unsuccessful, please make sure that the board is powered on, running a sketch provided with the package, and
connected to the indicated serial port. You might also try to unplug and re-plug the USB cable before attempting a
reconnection.

24 Mar 2014 vishnu vardhan

Hi All. Hope I get help .
Im using Arduino Mege 2560. When I enter "a=arduino('COM42');" in the
command window of Matlab13, im getting error as "Undefined function
'arduino' for input
arguments of type
'char'."
Please Resolve This.

03 Mar 2014 EDWIN ALVAREZ

Hi all ok i have finished a simple tutorial about some problems and i think that is a option for u.

see you my post Communication Matlab and Arduino (9600 Bps) Xbee Modules

http://elagmecatronica.blogspot.com/

if u have more douts please send me a email.

24 Feb 2014 Mohnish Lad

Hi Folks,
I am trying to plot the real time graph of all the axes of the accelerometer wirelessly by XBee through MATLAB. I have achieved the following till now :
On the transmitter side, I have an Arduino connected with an Xbee shield. I am using a Series 2 Xbees for this purpose. I have an ADXL335 breakout board accelerometer hooked in to the analog pins Arduino+Shield combo and also the XBee ( Co-Ordinator API) on the shield . On the receiver side, I have an XBee (Router AT) connected to a computer which will record the output and plot it on MATLAB. I also wanna mention that I am using the Arduino library for MATLAB for the Arduino code.
Now when i wire up the Arduino ( i.e i dont use the Xbee) then i get a perfect output of all the axis of the accelerometer. but when i hook in the Xbee and try to communicate with the arduino i get nothing. For eg. when use the Xbee the command to plot the graph is:
a = arduino(COM X) ; where X is the COM port where the Arduino is connected.
Now what changes should do in the command when i connect my Xbee? Recalling again that my Arduino and accelerometer are not connected to the computer but my receiver side Xbee is.

Here is my MATLAB code:

a.pinMode(15,'input');
a.pinMode(16,'input');
a.pinMode(17,'input');
a.pinMode(18,'output');
a.pinMode(19,'output');
a.digitalWrite(18,0);
a.digitalWrite(19,1);
xval = zeros();
yval = zeros();
zval = zeros();

xval(1) = a.analogRead(3);
yval(1) = a.analogRead(2);
zval(1) = a.analogRead(2);

pause(.001);

for i = 2:1000

xval(i) = a.analogRead(3);
yval(i) = a.analogRead(2);
zval(i) = a.analogRead(2);


xmod = (xval-496)/300;
ymod = (yval-511)/300;
zmod = (zval-508)/300;

subplot( 3,1,1)
plot(xmod, 'r');
axis([1 1000 -0.5 0.5]);
title( 'x' );

subplot( 3,1,2)
plot(ymod, 'r');
axis([1 1000 -0.5 0.5]);
title( 'y' );

subplot( 3,1,3)
plot(zmod, 'r');
axis([1 1000 -0.5 0.5]);
title( 'z' );




pause(0.001);

end

28 Nov 2013 EDWIN ALVAREZ

Hi guys, im edwin and if you have a project with xbee modules or similar, i can help you.

18 Oct 2013 Jeff

Where do I get the .pde files to download onto the Arduino? Thanks for the help.

08 Sep 2013 Thomas

I have successfully installed all IO files, .pde files, and can connect my arduino (plus motor shield) to matlab. However, when the connection is established, matlab lists off servos 2-69, instead of the 2 associated with my motor shield. Additionally, no commands will operate my stepper, servos or motors (which I have tested in the IDE workspace, they work fine).

Matlab says
EDU>> a=arduino('COM3')
Attempting connection .............
Motor Shield Script detected !
Arduino successfully connected !
But nothing works, not even the test code. Any idea?

11 May 2013 EDWIN ALVAREZ

Arduino+Matlab+Xbee

http://www.youtube.com/watch?v=use_eEh-X7c&feature=youtu.be

this is my video

06 May 2013 Tobias

Hey,
thank you for this very useful package, it will help me a lot. Is it possible to use this package to manage the Arduino Due board or does it only support Arduino Mega / Uno

greatings from Germany
Tobias

01 May 2013 EDWIN ALVAREZ

greetings.
First, thank you very much to you, Giampiero Campa =).
and i am attempting to control a robot with Xbee modules. and for the wireless communication we are using 2 Xbee pro series 1. They have been configured and the adiosrv.pde file has been uploaded into the arduino. I have been using your code for a=arduino('com5') in Matlab and I am getting this error:

Warning: Unsuccessful read: A timeout occurred before the Terminator was reached.
Error using arduino (line 101)
Connection unsuccessful, please make sure that the Arduino is powered on, running
either srv.pde, adiosrv.pde or mororsrv.pde, and that the board is connected to
the indicated serial port. You might also try to unplug and re-plug the USB cable
before attempting a reconnection.

Sometimes the error occurs at line 115, but I haven't done anything different to my procedure when I get this error.

ok, i have a solution for this,

is the xbee have a speed of 9600 bps by default. file has a default adiosrv 115200 and arduino.m file also. then I put them all at 9600 bps and it worked =)
is wonderful to make this interaction between matlab and arduino xbee modules through. again thank you very much Giampiero Campa

19 Mar 2013 Giampiero Campa

Patricia what did you put instead of that "12" in the fourth comment below ? You mentioned you tried higher values but perhaps it wasn't big enough.

I would suggest, with a testing program running on the Arduino which sends data continuously, to see if you can create a connection with the serial command from MATLAB. Try sending and receiving data using that command and possibly the serial block of the instrument control toolbox.

If all fails, another option could be trying to use the Simulink Support Package instead, which might even be more appropriate in your case since it does not require a MATLAB connection to work.

18 Mar 2013 Patricia

Giampiero,
I am using an Xbee USB Adapter for one Xbee and a Xbee 5V/3.3V Adapter connected to the arduino. In this configuration, I can send "testing" on the arduino and can view it with the IDE and a terminal program called XTCU.
When I try a=arduino('com5') in matlab I am still getting the same error at line 101, but I noticed that the RSSI light on the Xbee shield connected to the arduino comes on as matlab is trying attempting the connection. The other xbee is constantly transmitting the signal. Any suggestions?

15 Mar 2013 Giampiero Campa

Patricia, i can't think of anything. Other people were successful in using the BTShield, and, i think, the Xbee too. Does the same hardware setup work when using the IDE directly without matlab ? Can you establish a connection with a terminal program like hyperterminal ?
Let me know if you find anything.

Giampiero

15 Mar 2013 Patricia

After trying your suggestions, I am still getting the same time out error. I noticed that the Rx and Tx lights on the Xbee connected to the arduino are not even lighting up. When I tested the arduino and the Xbees it did? Any other suggestions?

15 Mar 2013 MathWorks Classroom Resources Team

Hi Patricia and everybody else. If you get the timeout error one thing i would suggest is to go into the arduino.m
file, find these lines:

fprintf(1,'Attempting connection .');
for i=1:12,
pause(1);
fprintf(1,'.');
end

and increase that 12 up to 15 or more until it works. Another suggestion
is using the adiosrv.pde file instead of motorsrv.pde or srv.pde.

15 Mar 2013 Patricia

I am attempting to control an unmanned boat, but I am having difficulty getting the serial communication to work. For the wireless communication we are using 2 Xbee series 1. They have been configured and the srv.pde file has been uploaded onto the arduino. I have been using your code for a=arduino('com5') in Matlab and I am getting this error:

Warning: Unsuccessful read: A timeout occurred before the Terminator was reached.
Error using arduino (line 101)
Connection unsuccessful, please make sure that the Arduino is powered on, running
either srv.pde, adiosrv.pde or mororsrv.pde, and that the board is connected to
the indicated serial port. You might also try to unplug and re-plug the USB cable
before attempting a reconnection.

Sometimes the error occurs at line 115, but I haven't done anything different to my procedure when I get this error.

Do you have any ideas how to get past this problem?

25 Jan 2013 Kevin

please help I am also getting a timeout error, using matlab 2010b and arduino 0022

23 Nov 2012 André

Hi, I'm doing a experiment with arduino board that require port manipulation. I would like to know how to do that in Matlab. I have to connect 5 DC motors with the arduino simultaneously.

Thanks for your attention!

20 Oct 2012 Joseph

Good day guys. Can someone help me, because my gizDuino appears as "libusp" in device manager not as connected in any comport. Therefore I cant communicate with my board and matlab.

10 Sep 2012 Stefan

I am considering using Arduino coupled with Matlab for a project and would like to know what the maximum throughput for the interface between MATLAB and the Arduino board is. Is it a USB simulated serial connection, or does it support full USB speeds? I would be most grateful if someone could give me a number of pin reads/writes / sec if possible.
Thanks!

28 Jul 2012 MAYANK

Hi I´m using Matlab R2010a, target arduino , software arduino-0022,
I've uploaded the adiosrv, and had no errors uploading
When I try a=arduino('Com6') in MATLAB 2010a, I get a timeout error.
why is it happening?
what m i supposed to do in this case?

07 Jun 2012 Giampiero Campa

Hernan, No I have not included any command specific for the LCD library, so probably not.

If you are interested in a solution for LCD let me know though, I can guide you if you decide to try to modify the code so that it would work with it.

06 Jun 2012 Hernan

Hello, I was wondering if the arduino io would work with the liquid crystal library for the Arduino? I am trying to display a message from matlab on an LCD using the arduino.

06 Jun 2012 Hernan  
07 Apr 2012 Roger Su

hi, I am trying to read the analog input data from arduino in Matlab, but i don't know how to start. Can someone help me, please ?

26 Mar 2012 Giampiero Campa

Andrey, the MATLAB support package for arduino, (ArduinoIO), and the Simulink Support Package, (now renamed Embedded Coder support package), are completely different and are not supposed to work with one another. Either you use one or the others. If you have problems regarding the Embedded Coder Package, (that's what it looks like) i suggest that you can try looking where you actually downloaded that package.

25 Mar 2012 Andrey Zagvazdin

Hello! I MatLAB 7.12 (R2011a) 64-bit. OS Windows 7
Fee clone Arduino, Russian assembly Freeduino (http://freeduino.ru/arduino/index.html), a complete analog Ardruino Uno / Duemilanove w/ATmega328.
My actions:
1 - Connection "Arduino" to MatLAB
* Set ArduinoIO (http://www.mathworks.com/matlabcentral/fileexchange/32374);
* Unpack the package into C: \ arduinoIO;
* >> Cd c: \ arduinoIO
* >> Install_arduino
* >> Savepath
* Flashed "Arduino" core srv.pde (https://github.com/adafruit/Adafruit-Motor-Shield-library/zipball/master);
* >> A = arduino ('COM4');
At this point, everything is OK! From the window MatLAB, board responds and takes command.

2 - Connection "Arduino" to SIMULINK
* Downloading the package Simulink Support Package for Arduino (http://www.mathworks.com/matlabcentral/fileexchange/30277);
* "Simulink Support Package for Arduino" unpacked to C: \ arduino_simulink
* Downloading Wednesday Arduino IDE (arduino-1.0) and extract it to c: \ ArduinoTarget
* >> Cd c: \ arduino_simulink
* >> Addpath (fullfile (pwd, 'arduino'), fullfile (pwd, 'blocks'), fullfile (pwd, 'demos'))
* >> Savepath
* >> Sl_refresh_customizations
* Plug-in board "Arduino" to your computer.
* Indicates the path to the environment Arduino IDE >> arduino.Prefs.setArduinoPath ('c: \ ArduinoTarget')

That's all up to this point NORMALLY PUT.

* Determine the current platform team
>> Arduino.Prefs.setBoard ('atmega328') or >> arduino.Prefs.setMcu ('atmega328')
Throws an error
>> Arduino.Prefs.setBoard ('atmega328')
?? Reference to non-existent element of a cell
array.
Error in ==> Prefs> Prefs.parseBoardsFile at 227
lhs = parsedLines {i} {1} {1}%
can be of the form xx.yy.zz
Error in ==> Prefs> Prefs.setBoard at 66
boards =
arduino.Prefs.parseBoardsFile (boardsFile);
>> Arduino.Prefs.setMcu ('atmega328')
?? Error using ==> Prefs> Prefs.setMcu at 129
This function is deprecated. Use
arduino.Prefs.setBoard instead, e.g.
arduino.Prefs.setBoard ('uno')

TRIED TO IGNORE THIS OPTION AND KEEP SETTING, BUT IN MODELING, DEMANDS categorically specify the model.

25 Mar 2012 Andrey Zagvazdin

Hello! I MatLAB 7.12 (R2011a) 64-bit. OS Windows 7
Fee clone Arduino, Russian assembly Freeduino (http://freeduino.ru/arduino/index.html), a complete analog Ardruino Uno / Duemilanove w/ATmega328.
My actions:
1 - Connection "Arduino" to MatLAB
* Set ArduinoIO (http://www.mathworks.com/matlabcentral/fileexchange/32374);
* Unpack the package into C: \ arduinoIO;
* >> Cd c: \ arduinoIO
* >> Install_arduino
* >> Savepath
* Flashed "Arduino" core srv.pde (https://github.com/adafruit/Adafruit-Motor-Shield-library/zipball/master);
* >> A = arduino ('COM4');
At this point, everything is OK! From the window MatLAB, board responds and takes command.

2 - Connection "Arduino" to SIMULINK
* Downloading the package Simulink Support Package for Arduino (http://www.mathworks.com/matlabcentral/fileexchange/30277);
* "Simulink Support Package for Arduino" unpacked to C: \ arduino_simulink
* Downloading Wednesday Arduino IDE (arduino-1.0) and extract it to c: \ ArduinoTarget
* >> Cd c: \ arduino_simulink
* >> Addpath (fullfile (pwd, 'arduino'), fullfile (pwd, 'blocks'), fullfile (pwd, 'demos'))
* >> Savepath
* >> Sl_refresh_customizations
* Plug-in board "Arduino" to your computer.
* Indicates the path to the environment Arduino IDE >> arduino.Prefs.setArduinoPath ('c: \ ArduinoTarget')

That's all up to this point NORMALLY PUT.

* Determine the current platform team
>> Arduino.Prefs.setBoard ('atmega328') or >> arduino.Prefs.setMcu ('atmega328')
Throws an error
>> Arduino.Prefs.setBoard ('atmega328')
?? Reference to non-existent element of a cell
array.
Error in ==> Prefs> Prefs.parseBoardsFile at 227
lhs = parsedLines {i} {1} {1}%
can be of the form xx.yy.zz
Error in ==> Prefs> Prefs.setBoard at 66
boards =
arduino.Prefs.parseBoardsFile (boardsFile);
>> Arduino.Prefs.setMcu ('atmega328')
?? Error using ==> Prefs> Prefs.setMcu at 129
This function is deprecated. Use
arduino.Prefs.setBoard instead, e.g.
arduino.Prefs.setBoard ('uno')

TRIED TO IGNORE THIS OPTION AND KEEP SETTING, BUT IN MODELING, DEMANDS categorically specify the model.

31 Jan 2012 David Batterbee

I'm having similar problems with the UNO described above. In particular, typing "arduino.Prefs.searchForComPort" returns an empty results even though my Device Manager shows that the Arduino Uno is connected to COM11.

I have no problem at all with the Arduino Duemilanove and the searchForComport function works fine.

How can I get Matlab to see the UNO?

14 Dec 2011 Deepak Mohan

can i implement all the functions in an arduino when interfaced with matlab....

06 Sep 2011 Giampiero Campa

You can try to use Hyperterminal (or the IDE) to communicate with adiosrv.

There are some instructions at the top of the adiosrv.pde file that tells you how to do it. For example if you establish serial connection and type "2n1" in the IDE (or in Hyperterminal) you should set pin #13 high and the led should light up.

This will allow you to further narrow the problem down.

03 Sep 2011 Justin

I'm having trouble getting MATLAB to communicate w/t my Arduino Uno.

I've uploaded the adiosrv (I'm not using the motor shield), and had no errors uploading (I tried the srv file, got an error, but realized that since i'm not using the motor shield I should be using the adiosrv file anyways).

When I try a=arduino('Com6') in MATLAB 2009a, I get a timeout error. Using TMtool, I can't find the Arduino using matlab. So it seems that the adiosrv is not doing its job, but I'm not sure where to go from here!

Any help would be much appreciated!

18 Aug 2011 Imran

very informative but the Arduino Uno target files don't work.

15 Aug 2011 Héctor Corte

Simon. I can´t find the line you are saying with addpath on Arduino.m ¿Anyone have the same problem and solve it the same way?

29 Jul 2011 Mihir Shah  
15 Jul 2011 UMAGON

hi, is there any video for this? why cant i access to it?

15 Jul 2011 Giampiero Campa

The Arduino IO (works fine on 64 bit windows platforms).

The Arduino Target works with the UNO, but you have to use arduino.Prefs.setMcu('atmega328p-pu')
in the instructions above (in general this is the name printed on the microcontroller).

A newer version with a better readme file is coming out soon.

07 Jul 2011 Ryan Stafford

I'm having exacting the same problem as Mario... a connection issue when using the Arduino Uno with Simulink. The odd thing is, I also have the older Arduino board (Duemilanove) and this works absolutely fine with the Simulink examples provided. As far as I am aware, these two boards use exactly the same chip (328P) but the UNO now uses ATmega8U2 instead of the FTDI chip. I'm not sure how to resolve this issue or why this is causing a problem... any ideas? The Uno works fine within the Arduino environment and I can also make a connection when using the arduino.m file, but when I try to download a Simulink model to the board I receive the same error message Mario has listed above. Thanks,
-Ryan Stafford

09 Jun 2011 Dave Rowland

Thanks for the very helpful submission! I was curious if there are files for 64bit windows? For example, when I try to run serial('COM3'), I get an error saying:
"The serial port object is supported on the Solaris, 32-bit Windows and
32-bit Linux platforms only."
Thanks,
Dave Rowland

19 May 2011 mario

Hi I´m using Matlab R2010a, target arduino UNO, software arduino-0022, but i have a problem when I use my board in SIMULINK,
I follow steps in README

Arduino Target for Use With Simulink Software, Version 1.0 (R2010a) 01-July-2010
>> cd c:\ARDUINO_TARGET
>> addpath(fullfile(pwd,'arduino'),fullfile(pwd,'blocks'),fullfile(pwd,'demos'))
>> savepath
>> sl_refresh_customizations
>> arduino.Prefs.setArduinoPath('c:\Program Files\ArduinoPRGM\arduino-0022')
>> arduino.Prefs.setMcu('atmega328p')
>> comPorts=arduino.Prefs.searchForComPort;
>> arduino.Prefs.setComPort(comPorts{1});
??? Cell contents reference from a non-cell array object.

but i don´t know why this problem
I try to use arduino.Prefs.setComPort('COM1')
but demo_arduino_blink.mdl doesn´t work

Download failed. Check your serial connection and and run the command arduino.Prefs.getMcu to check you have specified the correct MCU.

The call to arduino_make_rtw_hook, during the after_make hook generated the following error:
Download failed. Check your serial connection and and run the command arduino.Prefs.getMcu to check you have specified the correct MCU.
The build process will terminate as a result.

### If your target board has TX and RX LED you should see them flashing ...
avrdude: stk500_getsync(): not in sync: resp=0x30
avrdude: stk500_disable(): protocol error, expect=0x14, resp=0x51

What can I do?
Thankyou
Mario Camacho

06 Apr 2011 Giampiero Campa

Thanks Simon !

Tee, the connection is automatically set up as 9600baud, 8,N,1, on both the MATLAB and Arduino (adiosrv.pde) sides.

If you want to change the baudrate you will need to do that in both the arduino.m and adiosrv.pde files.

06 Apr 2011 Tee

I have some question on obtain data from arduino which connect to optical encoder. I have using following code to obtain data from Arduino

function encoder1pushbutton9_Callback(hObject, eventdata, handles)
handles.a.pinMode(2,'input');
handles.a.digitalRead(2)
numberOfDatas = 200;
data = zeros(1, numberOfDatas);
i = 1;
% Main graph figure
figure(1);
hold on;
title('Incomming Data from External Device');
xlabel('Data Number');
ylabel(' output (0-1)');
for i=1:numberOfDatas
% Get the data from the serial object
data(i) = handles.a.digitalRead(2);
% Plot the data
figure(1);
plot(i, data(i), 'm*');
drawnow;
end
Did i have to set the Baudrate, databits and stopbits to acquire data from arduino???

22 Mar 2011 fremond khoo

can i ask how do i plot a graph in MATLAB GUI using the data i obtained through arduino?

20 Mar 2011 Simon

To run in R2008a, line 21 of arduino.m needs to be:
addpath(fullfile(pwd,''));
instead of:
addpath(fullfile(pwd));

I sussed it out and thought I'd share it here. I have yet to test it with a more up to date version of Matlab. I guess the function could have changed(?).

Without this modification the fullfile function returns:
??? Error using ==> fullfile at 21
Not enough input arguments.

09 Mar 2011 fremond khoo

yeah..same prob..can u tell us how to solve it?

09 Feb 2011 Mohd Ismail

Hi,

Found your link from Arduino blog. I just started to work on interfacing Arduino with Matlab. But unable to run the example file. Matlab connection unsuccessful when send command a=arduino('com7'). Any idea?

??? Error using ==> arduino>arduino.arduino at 100
Connection unsuccessful, please make sure that the Arduino is powered on, running
either adiosrv.pde or mororsrv.pde, and that the board is connected to the indicated
serial port. You might also try to unplug and re-plug the USB cable before attempting
a reconnection.

Cheers

09 Feb 2011 Mohd Ismail  
Updates
27 Aug 2010

Inserted link to download arduino class files.

09 Sep 2010

Uploaded figure, put copyrights in the two example files, and referenced the Arduino page in the description.

10 Sep 2010

Mainly i have updated the description text.

13 Sep 2010
14 Sep 2010

Removed redundant license file.

09 Apr 2014

Updated slides and examples to reflect all changes in the package from 2010 until 2014.

Contact us