MATLAB: Cannot connect Arduino Uno to Matlab R2014b

adiosrvadiosrv.pdearduinoarduinoioconnecterrormakermessageuno

—- Preceding statement: I know there's a similar question on here, but it didn't contain a solution for me. —-
I am attempting to connect an Arduino Uno to Matlab R2014b. I have uploaded the adiosrv.pde file from this google code page (because I cannot find a place to download it from the MatLab site):
https://code.google.com/p/arduinolab/source/browse/ArduinoIO/ArduinoIO/adiosrv/adiosrv.pde?r=b25efc9ea77bbfde5af8774ec57432f23b24a0f2
After entering:
supportPackageInstaller
to MatLab and installing everything, (including the ArduinoIO package for Matlab R2014b) and typing:
a = arduino('COM3','uno');
I then got the following message come up:
Updating server code on Arduino Uno (COM3). Please wait.
Cannot program Arduino board Uno (COM3). Please make sure the board is supported and the port and board type are correct.
When I enter:
which -all arduino
to MatLab I get:
C:\MATLAB\SupportPackages\R2014b\arduinoio\toolbox\matlab\hardware\supportpackages\arduinoio\arduino.m % arduino constructor
C:\Program Files\MATLAB\R2014b\toolbox\matlab\hardware\stubs\arduino.m % Shadowed
All help is appreciated!

Best Answer

Hi guys,
I've now moved on to bluetoothing to the arduino, (which works great btw), but I have had some success with USB connections too.
I found that connecting to the arduino works fine if I use the following to set up a serial:
function [s] = SetupSerial(comPort)
comPort='COM3';
s=serial(comPort);
set(s,'DataBits',8);
set(s,'StopBits',1);
set(s,'BaudRate',9600);
set(s,'Parity','none');
Then use fopen(s) to open, fread(s) to read and fprintf(s) to write.
The other issue I found was that it would be super awkward about connecting a second time. This was due to not closing the connections properly. If you run this script it clears everything and have been very useful for me:
clc
%clear all
if ~isempty(instrfind)
fclose(instrfind);
delete(instrfind);
end
%close all
clc
disp('Serial Port Closed')
Other things to look out for are probably obvious, but include checking your baudrate is right, COM port is right and you have the necessary support packages installed.
Related Question