Slow communication speed with Arduino
Mostra commenti meno recenti
Hi,
I am using a MAX6675 to measure the temperature of thermocouple. I tried to measure the temperature in two ways. Measure ways: 1. Arduino IDE and 2. Matlab read temperature by using a MAX6675 connected to Arduino. Their execution time is quite different.
%Arduino
void loop() {
unsigned long timeBegin = micros();
float temperature = module.readCelsius();
unsigned long timeEnd = micros();
unsigned long duration = timeEnd- timeBegin;
Serial.print("Temperature: ");
serial.print(temperature);
Serial.println(F("c"));
serial.print("Duration time (us):");
serial.println(duration);delay(1000);
}
The exercution time for Arduino IDE is about 520 microseconds.
%Matlab read temperature by using a MAX6675 connected to Arduino
tic;
T=readCelcius(a,cs,sclk);
toc;
disp(T);
The Matlab elapsed time is 1.616992 seconds.
The execution speed of these two ways are different by 3100 times!! While they are using the same function readCelcius.
How can I make the speed of connecting Arduino to the Matlab execute much more faster?
Any suggestion will be appreciated. Thank you!
Risposta accettata
Più risposte (1)
Sulaymon Eshkabilov
il 24 Dic 2022
Modificato: Sulaymon Eshkabilov
il 24 Dic 2022
1 voto
Note that in Arduino IDE: delay() command does not give a fixed sampling time.
You had better use: millis()
You can also try to use Data Streamer MS Excel app to record your Arduino Data.
2 Commenti
gdz
il 24 Dic 2022
Sulaymon Eshkabilov
il 24 Dic 2022
Use Data Streamer MS Excel app to record your Arduino Data that gives very accurate data export from Arduino into MS Excel.
Categorie
Scopri di più su MATLAB Support Package for Arduino Hardware in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!