Feeding Aref on an AVR

For Adafruit customers who seek help with microcontrollers

Moderators: adafruit_support_bill, adafruit

Feeding Aref on an AVR

Postby Ran Talbott » Mon Mar 02, 2009 2:11 pm

Needing a precise voltage reference for A/D, I used an LM385, tied it to Vcc with an 820 Ohm resistor, and bypassed it with a .1 mono. Since there will be a lot of times during development when the AVR won't be configured for an external reference source, I followed the suggestion on arduino.cc of connecting the LM385 to Aref with a 5K resistor.

Unfortunately, when I checked the voltage on Aref, I discovered that it's about 2.2V, not 2.5. I expected Aref to be an extremely high-impedance input, but it's obviously drawing about 60 microamps, dropping 300mV across that resistor.

What are folks doing to provide an external reference without blowing up either the AVR or the reference? I've thought about using an op-amp as a buffer, but the prototyping shield is already full of interface circuitry, so I'd have to dead-roach the op-amp, and I want to avoid that if I can.

Thanks,

Ran
Ran Talbott
 
Posts: 57
Joined: Thu Feb 19, 2009 12:32 pm

Re: Feeding Aref on an AVR

Postby adafruit » Mon Mar 02, 2009 10:00 pm

are you sure you're setting vref register?
can you post a diagram/schematic of what you're tring to do?
User avatar
adafruit
 
Posts: 10491
Joined: Thu Apr 06, 2006 3:21 pm
Location: nyc

Re: Feeding Aref on an AVR

Postby Ran Talbott » Mon Mar 02, 2009 10:59 pm

Well, I'm using arduino-0012 on Linux with a call to:

Code: Select all
   analogReference(EXTERNAL);

in the setup() function.

Are there any known bugs in the library?

I could draw a schematic in Eagle and attach the .sch or Postscript output, but the netlist is extremely simple:

820 Ohm resistor from Vcc to Zener cathode.
.1uF cap from Zener cathode to ground.
4K7 resistor from Zener cathode to Arduino AREF.
Zener anode to ground.

I expected this to force about 1mA through the Zener when it's eventually plugged into a 3.3V Arduino Pro (about 3mA while it's on 5V), providing a nice stable 2.50V at the Zener cathode. Which it's doing. The problem seems to be that the AVR sucks more juice into Aref than I expected, so the voltage at the pin is lower than palnned.

Ran
Ran Talbott
 
Posts: 57
Joined: Thu Feb 19, 2009 12:32 pm

Re: Feeding Aref on an AVR

Postby adafruit » Mon Mar 02, 2009 11:59 pm

i think its something else...i mean it should 'just work'
cant think of anything right now tho
User avatar
adafruit
 
Posts: 10491
Joined: Thu Apr 06, 2006 3:21 pm
Location: nyc

Re: Feeding Aref on an AVR

Postby Ran Talbott » Tue Mar 10, 2009 2:59 pm

I've dug into the datasheet and the library code, and here's the story.

The AVR chip's power-on default is to use an external reference. So the library's naming of Avcc as "DEFAULT" is a little misleading, and you don't need to worry that the AVR might try to fry your external reference during system initialization.

analogReference() doesn't actually change any hardware settings: it just sets an internal variable that's used to select the reference as part of the hardware "start conversion" command when you call analogRead(). So, if you call analogReference() before your first call to analogRead(), there won't be a problem with the library catastrophically reconfiguring the hardware on you.

By CMOS standards, Aref is a pretty low-impedance input: the data sheet says it's typically about 30K. So putting a 5K resistor between your external reference and Aref will produce a significantly different voltage at the AVR's reference input.

In summary: feeding Aref through a series resistor may be "a good idea" if you're likely to run software in the Arduino that would select an internal reference, but it's a bad idea if you can avoid that risk and need/want to use a precise external reference.

Ran
Ran Talbott
 
Posts: 57
Joined: Thu Feb 19, 2009 12:32 pm

Re: Feeding Aref on an AVR

Postby adafruit » Tue Mar 10, 2009 6:53 pm

id just call the adc directly, one of the things about the arduino lib is sometimes you gotta go around it
User avatar
adafruit
 
Posts: 10491
Joined: Thu Apr 06, 2006 3:21 pm
Location: nyc


Return to Microcontrollers

Who is online

Users browsing this forum: No registered users and 0 guests

Stuff to buy from the Adafruit store and links to product documentation!


New Products [108]

Raspberry Pi[80]
 
FLORA[23]
 
Bunnie Studios[9]
 
FPGA[1]
 
mbed[11]
Arduino[60]
 
NETduino[14]
 
BeagleBone[24]
 
Android[6]
 
XBee[10]
More Dev Boards[31]


 
BoArduino[8]
 
SpokePOV[4]
 
TV-B-Gone[4]
 
MiniPOV[3]
 
SIM reader[3]
 
Microtouch[5]
 
Clocks & Watches[18]
 
Drawdio[4]
 
Brain Machine[1]
 
Game of Life[2]
 
MintyBoost[2]
More DIY Kits[16]


 
MaKey MaKey[3]
 
Tweet-a-Watt[5]
 
Young Engineers[33]
 
Discover Electronics[2]
 
Snap Circuits[4]
 
littleBits[3]
 
Project packs[8]


 
Breakout Boards[34]
LCDs & Displays[48]
Components & Parts[70]
Batteries & Power[49]
EL Wire/Tape/Panel[52]
LEDs[111]
 
Wireless[14]
Cables[62]
 
Lasers[6]
Sensors/Parts[145]
 
Enclosures/Cases[11]
 
Solar[11]
 
RFID / NFC[13]
Prototyping[70]
 
iDevices[13]
Tools[71]
 
Wearables[39]
 
CNC[37]
 
Robotics[29]
 
3D printing[1]
 
Materials[24]


 
Stickers[41]
 
Skill badges[55]
 
Books[25]
 
Circuit Playground[7]
 
Gift Certificates[4]