But what about other boards? Im specially interested in SAMD21 Cortex-M0+ 32bit boars (as for example MKR Zero). I try reading the documentation of the [ATSAMD21G18]( SAM D21/DA1 Family Data Sheet (microchip.com)) but I wasnt able to find it.
Could anybody please give me a hand or tell me which factors determinate the speed?
On ATmega based boards (UNO, Nano, Mini, Mega), it takes about 100 microseconds (0.0001 s) to read an analog input, so the maximum reading rate is about 10,000 times a second.
Secondly, page 2 of the sheet you linked:
One 12-bit, 350ksps Analog-to-Digital Converter (ADC) with up to 20 channels
• Differential and single-ended input
• 1/2x to 16x programmable gain stage
• Automatic offset and gain error compensation
• Oversampling and decimation in hardware to support 13-, 14-, 15- or 16-bit resolution
That should give you some ideas. Can't tell you what Arduino does with it, but it's a start.
To be clear, that's a "best coding effort" result that is unlikely to be attained by most codes/platforms. However, it suggests that performance should be much, much better than one can get on the Uno. How well it can do will be determined by the proficiency of the software developer, either rolling-your-own, or depending upon whatever feature set the Arduino team provides.
Let us know what you are able to find out, or determine empirically.
Lots of features described in the ADC section of the OP's linked manual, starting page 780; it remains to be seen just what is already predetermined by the core. Admittedly, I'm sure one can probably, with enough art, override everything and optimize, but realistically, that's beyond most general users here.
@DrDiettrich Not to be disrespectful, but with a prefix of Dr., I expect you can read as well as I can, and I'll be darned if I'll cut, paste, and translate a 40-page subsection of the manual for you. There is a lot of configuration available; a cursory glance tells me 350 ksamp is only doable for one channel in burst mode, but a thorough read, and testing, of the various settings will be required to tune the ADC to the needs of any particular project. The same is likely true for the processor in a Nano, for that matter - I'd bet the processor has loads of options not available in the plain vanilla Nano core available in the IDE. So, some learning and customization is the path forward.
Here's the calculations I did awhile back for the SAMD21's ADC:
Section 1 calculates the sample delay extention SAMPCTRL register, this allows the sample time to extended to a specific value. Arduino max this out to 64 ADC half clock cycles.
Section 2 calculates the total ADC conversion time.
Section 3 covers the source resistance calculations. (This equation can be found the SAMD21's "Electrical Characteristics" section of the datasheet).
Using the analogRead() function settings the ADC conversion time turns out to be around 430us, however this can be doubled, since analogRead() actually performs two ADC reads, this is to account for any change to the reference voltage.
Using the ADC peripheral's regsiters, it's possible to change the ADC clock prescaler and sample control to alter the sample rate. However, at a faster rate the source impedance must be low enough to charge the ADC's sample capacitor sufficiently quickly.
Yes, of course, but I have no personal interest in SAM architecture. I only wanted to point out details that affect effective analog speed of every ADC.
Yes, this is all in the domain of application of the processor to the job at hand, and what can or can not be done to tune the process within the limitations of the Arduino IDE, or beyond it. There's even a chance that this processor isn't as good as the one used in the Nano, it's not a foregone conclusion. I think we're both just trying to say the same thing, differently. But the OP may or may not wish to go down that rabbit hole, or any other; he needs to think about what his application needs, then research what options will meet that need. For all we know, he will want to do MHz sampling, and all this talk has been for naught.