This small program shows that Arduino UNO is capable of recording analog readings at a rate of at least 77 kHz (maybe even 154 kHz).
First, the analog digital converter setup registers (ADSCRA and ADSCRB) are set in such a way that analog values will be read and put in the ADCH register continuously at a rate of 77 kHz. This ADCH register may then be read at any desired frequency. If the reading frequency is faster than 77kHz, the same value will be reported multiple times.
Advantage of this approach is that no interrupt is needed (most sketches that I found so far wait for the analog read to get a new fresh result and will then read that value).
Instead of 10-bit, only the 8 most significant bits are read. This reduces noise and allows for much more compact storage. An 8 bit number can be stored in a byte, a 10 bit number will take an integer (2 bytes). At a sampling rate of 77 kHz, the memory of arduino will be full very rapidly....
Timer2 is used to read the values at regular intervals. First the timer overflow flag is set to zero. Then actions are performed. Then the controller waits for the overflow flag to be set. As long as the execution time of all actions fits in the period for the flag to be set, this will yield a very regular sampling.
The result is shown as a graph in the Serial Monitor. I guess a graphical display will allow for a much better view of the data (work to be done).
Below you see the serial output of a 1953 Hz square wave filtered through a three stage low pass filter sampled at 77 kHz
Comments
Please log in or sign up to comment.