Go Down

Topic: Fast sampling ADC (Read 5 times) previous topic - next topic


If you need 10 bit resolution, the Arduino ADC is a key limit.  For full resolution on a 16 MHz CPU, the maximum ADC clock is 125 kHz.  It take 13 cycle for a conversion so you are limited to about 9,600 conversions per second.

It will be much less than that if you include Serial overhead.


The fastest you can sample is limited by the ADC clock, which can be as fast as the main clock frequency divided by 2, or 8 MHz. Now, at that sampling frequency your results will not be accurate! In addition, the datasheet says the ADC clock should not exceed 1 MHz (I'm guessing results will just be ridiculously wrong beyond that point). The "recommended" ADC clock frequency to meet datasheet parameters is 200 kHz or less (many of the ADC parameters are specified at 200 kHz). Another parameter of note is the "input bandwidth", which has a typical specification of 38.5 kHz so (according to Nyquist's theorem) there's no information beyond 77 kHz of sampling (though it is beneficial to sample faster than that if your signal truly does have spectral content up to 38.5 kHz).

OK, so with that out of the way, let's say you settle on 200 kHz, that means you are sampling data every 5 microseconds.

There seems some confusion here - the ADC does not sample at the ADC clock rate.  It takes something like 13 ADC clock cycles to convert one sample (one clock for each result bit and some setup-overhead).  An ADC clock of 200kHz means max sample rate around 13kHz.  The default arduino setting is ADC clock = 125kHz, so about 100us per conversion.  This is about 100kbit/s, just beyond the capability of serial with baud rate of 115200.

The datasheet suggests using an ADC clock of 50kHz to 200kHz for good results.
[ I won't respond to messages, use the forum please ]


This is about 100kbit/s, just beyond the capability of serial with baud rate of 115200.

As stated above baudrate can go 3x higher, but that still leaves a gap of a factor 3-4.  So you should investigate if the signal can be compressed if you want to send it over serial.

If the signal does not change fast or often runlength encoding can be interesting. Note with the help of a local buffer "peaks" of fast changes can be handled too.

If signal does change often but not by a big amount consider sending the delta in one signed byte. Keep one value free for "here comes a new 16 bits value" flag

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)


Thank you all for the information provided!

I have to say I will need to attack this on a different approach than I initially intended. This is what I'm trying to do...

A signal comes in, which will be between 0V and 5V. The signal is between 1ms and 5ms long. I would be sampling this as fast as possible, storing the values and later sending them over a wireless serial radio. So the main thing then would be a way to store as many samples as possible during that short amount of time. If the Arduino could simply store those samples in it's memory then great! But I think it is beyond it's memory capacity, but I could use external EEPROM to store the information and send it after the signal has finished. How fast could I sample then if I don't have to worry about the baud rate, only storing on EEPROM ?

I see you guys mention how fast the ADC on the Arduino samples, I was not aware that you could manipulate the sampling rate of the ADC on the Arduino, any light on this?
I also like the idea of a faster baurdrate to help do most of this on a real time basis, I might end up doing this on a separate project for signal detection.
No trees were harmed by the transmission of this message. However a few million electrons were temporarily inconvenienced.


EEPROM is slow - store it in much faster SRAM instead, then transfer to EEPROM at your leisure if you want to keep it long term.
Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Go Up