# Question about Analog to Digital Converter pins of ATmega328P

hello,
i would like please to have some explanation about the AREF of the Atmega, it says analog reference but what would this do exactly ?

and about the AVCC, if i am not using analog i must connect it to VCC but should i connect it to GND if i want to use the Analog pins ?

Aref provides the upper level used for ADC conversion.
At 5V, each but represents ~4.88mV (Vcc/1023)
At 1.1V (internal), each bit represents ~ 1mV (1.1V/1023), but level at analog input needs to stay under 1.1V.

AVCC MUST connect to VCC (3.3V or 5V) no matter what. If using analog inputs, can be a good idea to connect to VCC thru an inductor for less noise in the analog readings.

When you do an analogRead(), you get back an integer between 0 and 1023. That integer stands for a voltage, using the following equation:

voltage = (number returned by analogRead()/1023)*ARef,

where ARef is the voltage value supposedly represented by the highest returned value (i.e., 1023).

You can use the default ARef, equal to the supply voltage, or you can establish your own ( not to exceed the supply voltage), provided you declare analogReference(EXTERNAL), or you can use the 1.1 v. level, by declaring
analogReference(INTERNAL1V1) (different on some chips).

Since you are dividing the voltage range (0, ARef) into 1023 parts, greater accuracy comes with a lower value of ARef.

Argh! The divisor is 1024! (@CrossRoads, you know better!)

After the conversion is complete (ADIF is high), the conversion result can be found in the ADC Result Registers
For single ended conversion, the result is
where VIN is the voltage on the selected input pin and VREF the selected voltage reference (see Table 24-3 on
page 248 and Table 24-4 on page 249). 0x000 represents analog ground, and 0x3FF represents the selected
reference voltage minus one LSB."

Yeah, okay, 1024.
Rearranging, Vin = (ADC * VREF)/1024
For a result of 1023 then, VIN = 1023*5V/1024 = 4.995V

The correct best estimate of pin voltage given a reading of N is (N+0.5)*Vcc/1024,
the result number indicates which of 1024 equal voltage bins the incoming signal
resides in, and the estimated value is the middle of this bin's voltage, hence the 0.5

AVcc and Vcc should differ by no more than 0.3V according to the datasheet, allowing
for RC or LC filtering on AVcc to reduce analog noise. They don't have to be wired together,
but this is the simplest thing to do.

pin 21 = AREF
pin 20 = AVCC

you should be working with a printout of the ATmega328 chip in front of you at all times for this project. I realize they are close together but the datasheet clearly explains their function. The questions you are asking indicate you have never laid eyes on the datasheet , which is a very bad practice and poor form to say the least. When you start working with microprocessors you are supposed to do your due diligence.

raschemmel:
pin 21 = AREF
pin 20 = AVCC

you should be working with a printout of the ATmega328 chip in front of you at all times for this project. I realize they are close together but the datasheet clearly explains their function. The questions you are asking indicate you have never laid eyes on the datasheet , which is a very bad practice and poor form to say the least. When you start working with microprocessors you are supposed to do your due diligence.

i have checked the datasheet pins description it's the same as the tutorial i am using as reference and what i wrote in my notebook

Aref provides the upper level used for ADC conversion.
At 5V, each but represents ~4.88mV (Vcc/1023)
At 1.1V (internal), each bit represents ~ 1mV (1.1V/1023), but level at analog input needs to stay under 1.1V.

AVCC MUST connect to VCC (3.3V or 5V) no matter what. If using analog inputs, can be a good idea to connect to VCC thru an inductor for less noise in the analog readings.

ok so i should connect the Aref to 5V, but is it connected on the 5V on the arduino ?
and about the inductor, is it possible to use a capacitor instead ? or caps are not low filter ?
and if i am not using the analog pins on the atmega as analog, it is not necessary to attach the Aref ?

Research REACTANCE
At DC a cap is an OPEN. At DC an inductor is a SHORT.
( duh)

raschemmel:
Research REACTANCE
At DC a cap is an OPEN. At DC an inductor is a SHORT.
( duh)

you're right i think i got it,
a capacitor is usually used in parallel, but an inductor is simply a wire which is wrapped to for do its job as it supposed to do it, that's why it is a closed but for cap it's open circuit
but what do they use on the arduino board itself ? i do not see any inductors

Research power supply CHOKE

I thiink 10 uH might be good but not sure.

You would put the inductor in series with the supply line, the capacitor in parallel with the supply line.
Do not connect Aref to 5V. That connection is made internally as the default reference source. Only use a cap to Gnd,
I suppose the cap is not needed if digital signals only are to be used. I would add it anyway to help keep from picking up noise on the unconnected pin.
Don’t confuse Aref and Avcc. Avcc helps power that corner of the chip and needs to be connected to Vcc - either directly and with a 0.1uF cap to Gnd, or thru an inductor, still with the cap to gnd.

See the two App Notes for more discussion.

Arduino board only uses caps no inductors, except on the USB shield. I use caps only on my designs.
Section 24.6.2 of the datasheet, Figure 24-9, show 10uH and 100nF (0.1uF) cap connected in series/parallel as described above.

raschemmel:
Research power supply "choke"

I thiink 10 uH might be good but not sure.

ok will do thanks for your help

You would put the inductor in series with the supply line, the capacitor in parallel with the supply line.
Do not connect Aref to 5V. That connection is made internally as the default reference source. Only use a cap to Gnd,
I suppose the cap is not needed if digital signals only are to be used. I would add it anyway to help keep from picking up noise on the unconnected pin.
Don't confuse Aref and Avcc. Avcc helps power that corner of the chip and needs to be connected to Vcc - either directly and with a 0.1uF cap to Gnd, or thru an inductor, still with the cap to gnd.

thank you CrossRoads, so for Aref, just caps to GND or nothing

See the two App Notes for more discussion.

Arduino board only uses caps no inductors, except on the USB shield. I use caps only on my designs.
Section 24.6.2 of the datasheet, Figure 24-9, show 10uH and 100nF (0.1uF) cap connected in series/parallel as described above.

i do not see any section 24 or 2.4
i think you are referring to 1.2 titled Analog Supply ?

ATmega328 DATASHEET

Section 24.6.2 is in the Atmege328 datasheet, not the App Notes.
http://www.atmel.com/devices/ATMEGA328P.aspx

in the Atmege328 datasheet

is there an echo in here ?

The APP note mentions a FERITE BEAD.
I think this one is the type you would use if you used one.

SEE THIS schematic.

Yes, ferrite bead feeding the VCC line in the App Note. The datasheet shows 10uH feeding the AVCC line.
I've only used caps myself, I think that's sufficient when providing power from switching regulator/wallwarts.
(vs full wave bridge rectifiers)

firashelou:
thank you CrossRoads, so for Aref, just caps to GND or nothing
i do not see any section 24 or 2.4
i think you are referring to 1.2 titled Analog Supply ?

He's talking about section 24 of the Atmega328p datasheet.