How to execute arduino functions using MATLAB interface

3 visualizzazioni (ultimi 30 giorni)
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 Commenti
Akshat
Akshat il 17 Giu 2013
Sorry about the code being garbled. The link for the code is http://tinyurl.com/kzp9b3a
Kaustubha Govind
Kaustubha Govind il 17 Giu 2013
In the future, please use the {}Code button to format your code.

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su MATLAB Support Package for Arduino Hardware in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by