How to execute arduino functions using MATLAB interface

3 visualizaciones (últimos 30 días)
Akshat
Akshat el 17 de Jun. de 2013
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 comentarios
Akshat
Akshat el 17 de Jun. de 2013
Sorry about the code being garbled. The link for the code is http://tinyurl.com/kzp9b3a
Kaustubha Govind
Kaustubha Govind el 17 de Jun. de 2013
In the future, please use the {}Code button to format your code.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre MATLAB Support Package for Arduino Hardware en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by