ARDUINO IO (Also Known As: "TETHERED" MATLAB SUPPORT PACKAGE FOR ARDUINO):
This package allows using an Arduino connected to the computer to perform
Analog and Digital Input and Output, (and command motors) from MATLAB.
---------------------------------------------------------------------------
DETAILS ABOUT ARDUINO:
Arduino is a powerful and inexpensive open-source microcontroller board,
with an associated development environment: http://arduino.cc/
An extensive Knowledge base can be found here: http://www.freeduino.org/
BUYING AN ARDUINO BOARD:
An extensive list of sites where you can buy an Arduino is here:
http://www.arduino.cc/en/Main/Buy
In the US, adafruit industries (http://www.adafruit.com/)
provides a starter pack that includes pretty much everything that you
need to get started with the board.
While earlier version of this package were targeted at smaller boards like
the Uno and Nano, since August 2012 (ver 3.3) the package also works right
out of the box on the Mega boards, without requiring any Mega-related tweaking.
GETTING STARTED GUIDES:
The official getting started guide is here : http://arduino.cc/en/Guide/HomePage
and a very good tutorial is here: http://www.ladyada.net/learn/arduino/
However note that for the purpose of using this package you only need to have
the IDE environment installed but you won't need to use it, because you can
do all the programming in MATLAB.
CHIP KIT 32 BOARDS:
Note that the the package works fine with the ChipKit32 boards (Uno32, Max32):
http://www.digilentinc.com/Products/Catalog.cfm?NavPath=2,892&Cat=18
All of the analog and digital input and output functionality work fine,
but unfortunately not all the interrupts functionalities work in the same
way, so servos and encoders might not work exactly as on the Arduino boards.
Since Sep 2012, when the AFMotor library was updated to support PIC32,
the Adafruit Motor Sield also works with these boards.
The Cerebot MX7ck also works fine with the package. Note that in order to be
accessed with the MPIDE you need to short jumper JP11, set the switch to ON,
and connect it to the PC through the UART (not the DEBUG) usb port.
If you don't have external power then make sure to also set the power
jumper to UART (as opposite to the default position DBG).
TI LAUNCHPAD (MSP430) BOARDS:
Using the Energia IDE (http://energia.nu/Guide_MSP430LaunchPad.html)
the adio.pde and adioe.pde can be compiled for the MSP430G2553 and
MSP430G2452 (the G2231 does not have enough memory). The adioes.pde sketch
can be compiled for the FR5739. Note however that no real testing has been
performed on these platforms though.
---------------------------------------------------------------------------
DOWNLOADING AND INSTALLING THE IDE (to be done only once):
A step by step driver installation can be found at:
http://arduino.cc/en/Guide/HomePage and there is no need to duplicate it here.
It is a good idea to go trought all the 9 steps, although after you have
installed the drivers, maybe the shield library, and verified that the IDE
can communicate with the Arduino, you can already start using this package.
INSTALLING THE ADAFRUIT MOTOR SHIELD LIBRARY (to be done only once):
If you want to use this package with the ADAFRUIT motor shield, (either
version 1: http://learn.adafruit.com/adafruit-motor-shield or version 2:
http://learn.adafruit.com/adafruit-motor-shield-v2-for-arduino ), you need
to download and install the respective adafruit motor shield library
(follow instructions given in the above sites, which amount to download
a zip file and unzip it into the arduino-1.X/libraries folder.
As better explained in the next step, this you will also need to upload
eiter the motor_v1.pde or the motor_v2.pde sketch on the board.
NOTE that if you don't have the adafruit motor shield and you don't plan
to use it, you might also SKIP THIS STEP.
Also note that the "official" Arduino (not Adafruit) motor shield:
(http://arduino.cc/it/Main/ArduinoMotorShieldR3)
does not require any additional library, works fine with the chipkit32
boards, and can be used with this package right away. Therefore if you
plan to use the official motor shield then you can safely skip this step.
---------------------------------------------------------------------------
UPLOAD ADIOES.PDE TO THE ARDUINO BOARD (to be done only once):
The adioes.pde sketch is the "server" program that will continuously run
on the microcontroller board. It listens for MATLAB commands arriving from
the serial port, executes the commands, and, if needed, returns a result.
The following instructions are needed to upload the adioes.pde file into
the controller's flash memory. As long as no other file is uploaded later,
this step does not need to be repeated anymore, and the package can be
used as soon as the board is connected to the computer.
Note that if you want to use the adafruit shield library then you need to
both install the appropriate library (see previous step) and upload the
the appropriate sketch (either motor_v1.pde or motor_v2.pde) instead of
the adioes.pde sketch.
From the Arduino IDE, go to File > Open, locate the file adioes.pde,
(in the ArduinoIO/pde/adioes folder) and open it. If a dialog appears
asking for the permission to create a sketch folder and move the file,
press OK (this will create an adioes folder and move the adioes.pde
file inside it).
Connect the Arduino, make sure that the right board and serial port are
selected in the IDE, (Tools/Board and Tool/Serial Port) then select
File -> Upload to I/O Board and wait for the "Done Uploading" message.
At this point the adioes.pde file is uploaded and you can close the IDE,
which is not needed anymore for the purpose of this package. Actually
closing the IDE is suggested, so you can be sure that the serial connection
to the arduino board is not taken by the IDE when matlab needs to use it.
---------------------------------------------------------------------------
PACKAGE INSTALLATION (to be done only once):
When installing the Arduino IO package on your operating system it is
important that users have the right to access the serial port and modify
the pathdef.m file.
ON LINUX:
---------
To make sure that the pathdef.m file is writable, issue a command like this:
sudo chmod 777 usr/local/matlab/R2012a/toolbox/local/pathdef.m
(modify the path above according to where MATLAB is installed).
Also, still on Linux, create a symbolic link as follows:
sudo ln -s /dev/ttyACM0 /dev/ttyS101
and make sure it is accessible by any user:
sudo chmod 777 /dev/ttyS101
Forgetting this last step might lead to a serial port which is
unaccessible by a normal user (therefore being grayed-out in the IDE).
Then from MATLAB, launch the "install_arduino" command, this will simply
add the relevant ArduinoIO folders to the matlab path and save the path.
ON WINDOWS:
-----------
Run MATLAB as administrator (just one time for the purpose of installing
the package) by right-clicking on the MATLAB icon and selecting
"Run as Administrator". This will allow the updated path to be saved.
Then from MATLAB, launch the "install_arduino" command, this will simply
add the relevant ArduinoIO folders to the matlab path and save the path.
---------------------------------------------------------------------------
TYPICAL USAGE:
Make sure the board is connected to the computer via USB port, make sure
you know which serial port the Arduino is connected to (this is the same
port found at the end of the drivers installation step), and finally,
make sure that the port is not used by the IDE (in other words, the IDE must
be closed or disconnected), so that MATLAB can use the serial connection.
From MATLAB, launch the command a=arduino('port') where 'po