I want to measure the conversion rate of an arduino DUE. I know I could just take it from the datasheet but I need to measure it because I am running the ADC in free running mode. Hints are welcome, I really don't know where to start.
-
2What do you mean by "conversion rate"? Time to perform an acquisition? The easiest way is to save the millis value, perform 1000 acquisitions, then save again the millis value and make a subtraction. If the value is small, increase the number of acquisitions to have a reasonable time (1-10 s). Then make the division. For instance, 10000 acquisitions -> 7.92s means that each acquisition is 0.792ms, so 1262 samples/s– frarugi87Commented Jan 12, 2017 at 15:26
-
... Or make it toggle a pin each time the acquisition is done, then measure with an oscilloscope... Or tell us what you want to achieve, so hints can arrive...– frarugi87Commented Jan 12, 2017 at 15:28
-
Hi! Thanks for your answer! What I need is to measure the sample rate of the ADC because I need to do an Antialiasing Filter. My expectative is to achieve a sample rate of 400kHz. If this value is fixed, it would be a lot more easy to do the processing that I want to do (FFT, Correlation)– Augusto Bonelli ToroCommented Jan 12, 2017 at 15:45
-
If you plan on doing a real analysis on it a freerunning adc is not the way to go... You need precise timings for this. If you want to know what is the maximum speed you can achieve, go with the pin toggle or the multiple adc conversions techniques, but even if you manage to achieve a 400kHz sample rate then you have to actually process each sample and present results in less than 2.5 us...– frarugi87Commented Jan 12, 2017 at 17:35
-
No answer, but I'd be interested in this as well.– AdrianK.Commented May 2, 2018 at 10:57
Add a comment
|
1 Answer
Measure how many times per second was main loop called:
bool secondPassed()
{
static long lastTick = 0;
long now = millis();
if (now <= lastTick + 1000)
return false;
lastTick = now;
return true;
}
int counter = 0;
void loop()
{
analogRead(A0);
counter++;
if (secondPassed())
{
Serial.println(counter);
counter = 0;
}
}