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.
It sounds as if you don't have write access to this directory.
John
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.
I try the ArduinoIO program again and reset the board right after initializing the arduino object. Success
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.
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.
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?