How to execute arduino functions using MATLAB interface

3 ビュー (過去 30 日間)
Akshat
Akshat 2013 年 6 月 17 日
I need to execute commands other than IO commands while interfacing with arduino through MATLAB. In particular I need to measure correctly the current supply voltage to precisely convert the ADC values into voltage signals. The code for arduino is
long readVcc() {
long result;
// Read 1.1V reference against AVcc
ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
delay(2); // Wait for Vref to settle
ADCSRA |= _BV(ADSC); // Convert
while (bit_is_set(ADCSRA,ADSC));
result = ADCL;
result |= ADCH<<8;
result = 1126400L / result; // Back-calculate AVcc in mV
return result;
}
void setup() {
Serial.begin(9600);
}
void loop() {
Serial.println( readVcc(), DEC );
delay(1000);}
My main thrust is to somehow port the readVcc function so that I can execute it from MATLAB. Is this possible and if any guide is available for this is available, please link it. My main thrust is to execute a command like follows
a=arduino('COM5')
vcc=a.readVcc()
If any other information is further required please ask.
  2 件のコメント
Akshat
Akshat 2013 年 6 月 17 日
Sorry about the code being garbled. The link for the code is http://tinyurl.com/kzp9b3a
Kaustubha Govind
Kaustubha Govind 2013 年 6 月 17 日
In the future, please use the {}Code button to format your code.

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB Support Package for Arduino Hardware についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by