Need some help with atmega16

Thread Starter

peck68

Joined Nov 27, 2009
73
Well i haven't posted here in a long time, so, hey :)

Basically i'm stumped, I have never used AVR before up until this very day.. So i'm still getting to grips with it

I want to mess around with the ADC with a pot and output it on some leds on a port (d)

But though, how the <snip> do i wire this <snip> thing up?!

I've been reading everywhere, i just want a simple explanation on what AVcc, Aref and GND does (obviously about the GND, but there are two of them on there) and what I do with them...

The datasheet goes into too much detail about the things i don't need to know, which confuses me rediculously.. So if someone can explain the basics of interfacing, thanks :D

Don't worry about code, i'm an insanely quick learner when it comes to programming
 
Last edited by a moderator:

hgmjr

Joined Jan 28, 2005
9,027
Ok peck68 here is my take on the AVCC, AREF, AGND

AVCC - This pin on the AVR is the power to the ADC section of the AVR. It must be connected to a power source that is within 0.3V of the AVR's VCC pin. The safest hookup is to connect AVCC to the chips VCC pin.

AREF - This pin can be connected in one of three ways.

The AREF pin sets the voltage that corresponds to all 10 bits of the a-to-d convertor set to 1. In other words it sets the maximum voltage that should be applied to the ADC input being converted. There is no harm to the A-to-D converter if you exceed this voltage but any voltage above AREF will be represented by 0x3ff (all ones out of the converter) as long as it does not exceed the chips VCC voltage.. That means you will get an erroneous output value for applied input voltages in excess of the AREF.

The AVR can be programmed through its internal register bits to connect this pin to AVCC or an internal 2.56V reference. In either of these cases it is probably a good idea to provide a bypass cap to the chips ground pin to filter the AREF voltage.

In the third instance, you set the internal register bit to use the voltage applied to AREF externally. This gives you the designer full control over the voltage that equates to the ADC output value of 0x3FF. This makes it possible to scale the 10-bit ADC so that you get the maximum resolution from the converter. For example, if the analog signal you wish to convert swings from 0V to 2.5V then you are better off setting AREF to 2.5V than to connect AREF to AVCC and then add a gain of 2 amplifier just to get your input signal to swing between 0 and 5V so that you can use the full range of the ADC. Adding the extra gain stage has the potential of increasing the noise in the signal being converted.

AGND can be tied to an analog ground but his ground must be as close as possible to the ground connected to the GND pin on the chip.

hgmjr
 

eblc1388

Joined Nov 28, 2008
1,542
Should one choose to use an external reference voltage, its value should be within the range 2V ~ AVCC as required by the manufacturer.
 

Thread Starter

peck68

Joined Nov 27, 2009
73
Okay thank you so much for that :)

One other thing then, can they all come from the same source (Vdd) - and could i just simply use a voltage divider from Vdd for the anologue circuit thing, and use the voltage coming from that into AREF?

The picture is a bit makeshift but that's what i mean :)
 

Attachments

Last edited:

hgmjr

Joined Jan 28, 2005
9,027
You can use a voltage for AREF that is derived from the main power supply (Vdd) using a resistor voltage divider. Be sure to use a hefty bypass capacitor to keep the reference as free of noise as possible.

hgmjr
 

hgmjr

Joined Jan 28, 2005
9,027
Typically for this case I would use a quality capacitor that was 10 microfarads or higher. In addition I would add a 0.1 microfarad capacitor in parallel with the 10 microfarad to handle the high frequency noise. Both of these caps would be connected between the AREF pin and AGND.

hgmjr
 
Top