ATmega32u4

A conversion takes 13 ADC clocks. The ADC clock needs to be set using a prescaller from the main OSC to give an acceptable ADC clock rate.

To get the full 10 bits of resolution

The successive approximation circuitry requires an input clock frequency between 50kHz to 200kHz.

Faster with 10bit resolution

Setting the ADHSM bit in ADCSRB allows an increased ADC clock frequency at the expense of higher power consumption. Setting it to 1 enables the ADC High Speed mode.

Faster with less resolution

If a lower resolution than 10 bits is needed, the input clock frequency to the ADC can be higher than 200kHz to get a higher sample rate.

Arduino default ADC clock rate

16 MHz divided by a prescale factor of 128

16MHz / 128 = 125kHz ADC clock x 13 clocks = 104uS per conversion = 9615Hz

Faster analog reads using Arduino

The Arduino digital and anlog read/write abstractions that make the platform so easy to use reduce the execution time over what could be achieved if using low level code to directly access the analog input peripheral.

A simple change is to alter the prescale setting which will cause analogRead() to return faster, but potentially with a loss of resolution. For more refined control you’ll need to access other AtoD register directly.

The ATmega32u4 is specified as offering: 65 – 260μs Conversion Time and ADC clock frequency between 50kHz to 200kHz to get maximum resolution. 13 ADC clocks per conversion at 200kHz = 65uS.

The Arduino uses a 16MHz oscillator to give 16MHz clock speed.

Prescaling is set by the ADPS bits in ADCSRA. Available division factors are: 2, 4, 8, 16, 32, 64, 128,

The conversion time for the standard Arduino implementation:

16MHz / 128 = 125kHz ADC clock x 13 = 104uS per conversion

Changing the prescaler to 64 would give:

16MHz / 64 = 250kHz ADC clock x 13 = 52uS per conversion

This is too fast for 10 bit resolution, which is why 128 is used.

USEFUL?
We benefit hugely from resources on the web so we decided we should try and give back some of our knowledge and resources to the community by opening up many of our company’s internal notes and libraries through mini sites like this. We hope you find the site helpful.
Please feel free to comment if you can add help to this page or point out issues and solutions you have found, but please note that we do not provide support on this site. If you need help with a problem please use one of the many online forums.

Comments

Your email address will not be published. Required fields are marked *