what are the possible sampling rate the user can set in Arduino pro mini using ADCSRA registers. I want to set my desired sampling rate through registers, is it possible?
-
2maybe add a quote from the datasheet and explain what is what you don't understand– Juraj ♦Jan 5, 2022 at 6:34
-
What sampling rate do you want, chances are you won't achieve it if you are trying to run a high level language on the device.– Code GorillaJan 5, 2022 at 7:08
-
It depends on you accuracy requirement, as accuracy degrades with sampling speed.– Edgar BonetJan 5, 2022 at 8:18
1 Answer
The previous responders are correct; but, maybe some clarification may help. The data conversion rate determined by the ADCSRA register is the conversion rate of the hardware. There is no need to sample data readings faster than conversions are performed. Faster conversions show more jitter than slow ones. Your actual sample rate will usually depend more on the time it takes to run through your loops than on the conversion rate. Arduino library code is usually not the optimum choice for speed.
When you change the conversion rate in the ADCSRA, be sure to avoid clobbering the other bits:
ADCSRA = (ADCSRA & 0xF8) | (newRate & 7);
If you are getting the hang of writing the control registers, you might want to use the ADC's operation complete interrupt to retrieve each reading. That eliminates loop times.