I'm trying to change the analog reference voltage on an Arduino Duemilanove from the default (5v) to an external reference (in my case 3.3v) connected to the Aref pin. The Arduino is interfaced with MATLAB using the Arduino IO Package. From line 1392 of the included Arduino.m file, this should be achieved with
a.analogReference('external');
However, running any code after that command causes MATLAB to hang on 'Busy' for a few seconds before displaying the following error:
Warning: A timeout occurred before the Terminator was reached.
??? In an assignment A(I) = B, the number of elements in B and
I must be the same.
Error in ==> testIR at 8
data(n) = a.analogRead(analogPin);
Here is my minimal test code:
a = arduino('my COM port here')
analogPin = 1;
a.analogReference('external');
a.analogRead(analogPin)
The only way I've found to successfully change the reference voltage is by adding the command to the setup() section of the adiosrv.pde code before uploading it to the board using the Arduino IDE. This isn't ideal, as I'd like to be able to change it from within MATLAB, and that does seem to be a supported feature.
Any help is much appreciated. Thank you!