How to execute arduino functions using MATLAB interface
조회 수: 3 (최근 30일)
이전 댓글 표시
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
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 MATLAB Support Package for Arduino Hardware에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!