Sunday, October 17, 2010

What is the maximum sampling frequency for the Arduino ADC?

The ATMega 328 processor has multiple 10 bit ADC (Analog to Digital Converter) ports. By default it takes 111 microseconds to read an analog value, thus the default sampling frequency is 9KHz. But it is possible to configure the chip to read at 62.5 KHz with little loss of resolution, then the reading delay will be of 16 us.

You can use the following code to do that:

#ifndef cbi
        #define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
    #ifndef sbi
        #define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
    void setup() {
        sbi(ADCSRA,ADPS2) ;
        cbi(ADCSRA,ADPS1) ;
        cbi(ADCSRA,ADPS0) ;

No comments:

Post a Comment