Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Arduino Matlab Integration

169 views
Skip to first unread message

Sean

unread,
Jul 24, 2010, 1:19:06 AM7/24/10
to
Dr. Campa from MathWorks recently sent me his ArduinoIO program, and I'm having problems connecting to my board from Matlab.

I uploaded the accompanying sketch to my arduino and tested that it was uploaded correctly via the arduino IDE... everything is fine at this point.

When I try to open a connection to the arduino via Matlab, I'm getting some errors:

>> a=arduino('COM3')
Warning: Unable to save path to file 'C:\Program Files\MATLAB\R2010a\toolbox\local\pathdef.m'.
> In savepath at 162
In arduino>arduino.arduino at 22
Attempting connection ......
Warning: A timeout occurred before the Terminator was reached.
??? 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.

I don't think I am worried about the pathdef.m error, but it's the timeout that I can't figure out what the problem is. I think that it stems from fwrite(a.aser,[57 57],'uchar'); which is soliciting the board to respond with "1". The .m file checks for this response with chk=fscanf(a.aser,'%d'); but since chk is empty, the script returns the "Connection unsuccessful ..." error and closes the connection to the arduino.

If anyone familiar with ArduinoIO has some insight on this problem, I'd love to hear it. I tried contacting Dr. Campa about this to no avail.

John D'Errico

unread,
Jul 24, 2010, 7:28:03 AM7/24/10
to
"Sean " <sdv...@mail.mizzou.edu> wrote in message <i2dt4a$vl$1...@fred.mathworks.com>...

> Dr. Campa from MathWorks recently sent me his ArduinoIO program, and I'm having problems connecting to my board from Matlab.
>
> I uploaded the accompanying sketch to my arduino and tested that it was uploaded correctly via the arduino IDE... everything is fine at this point.
>
> When I try to open a connection to the arduino via Matlab, I'm getting some errors:
>
> >> a=arduino('COM3')
> Warning: Unable to save path to file 'C:\Program Files\MATLAB\R2010a\toolbox\local\pathdef.m'.

It sounds as if you don't have write access to this directory.

John

Sean

unread,
Jul 24, 2010, 1:42:04 PM7/24/10
to
"John D'Errico" <wood...@rochester.rr.com> wrote in message <i2eio3$nof$1...@fred.mathworks.com>...

Right, I changed the permissions on pathdef.m right after posting the original. The main problem I'm having is getting the code to connect to the hardware.

Sean

unread,
Jul 25, 2010, 12:38:04 AM7/25/10
to
I found a solution for anyone that has had the same problem. I uploaded a simple sketch that blinks pin 13 and sends a value of "1" through serial. As expected, the led starts blinking once the sketch is uploaded. I open a connection in MATLAB and the led blinking stops, so I press the reset button on the board and sure enough, the 1's start coming through and the led starts blinking again.

I try the ArduinoIO program again and reset the board right after initializing the arduino object. Success

Sam

unread,
Jul 27, 2010, 5:02:21 PM7/27/10
to
"Sean " <sdv...@mail.mizzou.edu> wrote in message <i2gf3c$dg3$1...@fred.mathworks.com>...

Sean,

Where did you find the contact information for Dr. Campa? We are trying to change our lab over from LabView to Matlab, and have done quite a lot so far using Instrument Control Toolbox (and no Arduino board). However, we are looking into using the board for some applications. Do you know if it can be used with the instrument control toolbox? I would be interested in getting the ArduinoIO file from Dr. Campa as well. Thanks.

Marty Pomeroy

unread,
Dec 3, 2010, 2:48:05 PM12/3/10
to

If you have the arduino.m, you also probably have the adiosrv.pde and mororsrv.pde in the same folder tree.

TWIMC the whole package is available here:
http://www.mathworks.com/academia/arduino-software/arduino-matlab.html
Down in "MathWorks Downloads", click on "ArduinoIO Package for MATLAB", accept the agreement and download, then unzip to a work folder.

Open the Arduino IDE, use File -> Open and navigate to that work folder, select either adiosrv or mororsrv subfolder and one of the pde files, and use the Upload button to load one on the card.

Once one of these is loaded on the card, you can cd MATLAB to the work folder, and the a=arduino( 'COMn') should work for you.

Marty

PS Follow the instructions from Arduino to determine your COM port. If you can load and run the 'blink' program, see the active Tools -> Serial Port setting.

Raga

unread,
Feb 20, 2011, 10:09:12 PM2/20/11
to
"Sean" wrote in message <i2gf3c$dg3$1...@fred.mathworks.com>...

> I found a solution for anyone that has had the same problem. I uploaded a simple sketch that blinks pin 13 and sends a value of "1" through serial. As expected, the led starts blinking once the sketch is uploaded. I open a connection in MATLAB and the led blinking stops, so I press the reset button on the board and sure enough, the 1's start coming through and the led starts blinking again.
>
> I try the ArduinoIO program again and reset the board right after initializing the arduino object. Success


Sean,

I am having the same error as you and I can't get the arduino to work in Matlab. I am not using a USB arduino but rather the Arduino BT (bluetooth). Do you have any ideas on how to get rid of this error?

0 new messages