Change analog reference voltage using Arduino IO Package.

조회 수: 2 (최근 30일)
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') % connect to Arduino
analogPin = 1;
a.analogReference('external'); % change aref voltage
a.analogRead(analogPin) % read from sensor connected to analog pin
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!

채택된 답변

Nicholas Flenghi
Nicholas Flenghi 2011년 10월 5일
For anyone interested,
It turns out you must be using the srv.pde sketch to be able to change the analog reference voltage from within MATLAB.
Note that srv.pde requires the adafruit motor shield libraries (AFmotor) be installed as well.
  댓글 수: 1
Krishnakumar Gopalakrishnan
Krishnakumar Gopalakrishnan 2017년 12월 7일
Can you please elaborate on this further? How does one go about changing the reference by editing srv.pde? What are the exact steps? Any help will be much appreciated.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Arduino Hardware에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by