Atmega328 (UNO) ADC - AREF

I am trying to build my own Arduino using Atmega328 with help of http://arduino.cc/en/Main/Standalone.
I am confused for the connection of AREF pin. In that guide, it is connected to 5V, while looking at the Eagle schematics of UNO shows it's not connected to 5V (just a capacitor and ground). I was able to read ADCs with UNO without connecting AREF to 5V. I want to read the ADC values from 0 to 5 V. So, should I connect AREF to 5V or just leave it as in the Eagle schematics?

1 Like

The Aref pin is used for an external voltage reference. If you attach it to 5V then you can't attach it to an external reference voltage.

With it disconnected you can program the pin to internally connect to 5V. The capacitor is just for decoupling and noise reduction when using it as a real voltage reference pin.

I just need to read ADC from 0 - 5 V. Thats all.
So, I do not need to connect AREF to 5 V, right?
About programming to set AREF to 5V, I didn't do that while testing with my Arduino. I directly read using analogread() and it worked.

It defaults to using the internal connection to 5V for the Aref.

If you want more precise readings, it's useful to connect the Aref pin to a high precision voltage reference, but for "normal" operation, just stick a cap on it.

The AREF decoupling capacitor is required whether or not its internally connected to 5V - otherwise the ADC will perform below spec. That cap should be between AREF and the neighbouring GND pin as close as possible.

What value cap is recommended?

Arduino boards use 100nF. But I generally use 10nF for other ICs.

Thats an interesting question - the datasheet seems quiet on the matter - it recommends a capacitor but says nothing about the value. I suspect people use 0.1uF out of habit, but since this is an analog circuit a larger value might perform better.

Atmel Application Note "Atmel AVR042: AVR Hardware Design Considerations"
has this for Aref cap value:

"To be able to obtain good accuracy with the ADC the analog supply voltage must be
decoupled separately, in the same manner as the digital supply voltage. AREF must
also be decoupled, a typical value for the capacitor is 100nF."

Also discusses the 10K Reset pullup resistor and diode:

"The RESET pin on the AVR is active LOW, and setting the pin LOW externally will
thus result in a reset of the AVR. The RESET has two purposes:

  1. To release all lines by tri-stating all pins (except XTAL pins), initialize all I/O
    registers and set program counter to zero.
  2. To enter programming mode (for some parts also the PEN line is used to enter
    programming mode). Furthermore it is possible to enter high-voltage/parallel
    programming mode by drawing the RESET pin “very” high, where very high means
    11.5 – 12.5V (refer to the datasheet of the device for more information).

The reset line has an internal pull-up resistor, but if the environment is noisy it can be
insufficient and reset can therefore occur sporadically. Refer to datasheet for value of
pull-up resistor on specific devices.

Connecting the RESET so that it is possible to enter both high-voltage programming
and ordinary low level reset can be achieved by applying a pull-up resistor to the
RESET line. This pull-up resistor makes sure that reset does not go low unintended.
The pull-up resistor can in theory be of any size, but if the Atmel®AVR® should be
programmed from e.g. STK500/AVRISP the pull-up should not be so strong that the
programmer cannot activate RESET by draw the RESET line low. The recommended
pull-up resistor is 4.7k? or larger when using STK500 for programming. For
debugWIRE to function properly, the pull-up must not be smaller than 10k?.

To protect the RESET line further from noise, it is an advantage to connect a
capacitor from the RESET pin to ground. This is not directly required since the AVR
internally have a low-pass filter to eliminate spikes and noise that could cause reset.
Applying an extra capacitor is thus an additional protection. However, note that this
capacitor cannot be present if debugWIRE or PDI is used.

If not using High Voltage Programming it is recommended to add an ESD protecting
diode from RESET to Vcc, since this is not internally provided due to High Voltage
Programming. Alternatively, or in addition, a zener diode can be used to limit the
RESET voltage relative to GND. The zener diode is highly recommended in noisy
environments. The components should be located physically close to the RESET pin
of the AVR. Figure 3-1 shows the recommended circuit on the RESET line."