ADC 1.1V Bandgap Reference Issues

Go To Last Post
7 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello everyone,

I am making some temperature measurements with temperature sensor and an ATMEGA48P using the internal 1.1V bandgap voltage as a reference. I was just using an external 5V supply as the reference until I realized I could get more precision by using 1.1V (the temp sensor's range is only about 0.1V-1.75V, but I'm just measuring ambient temperature so more like 0.6V-0.9V).

Here's the procedure I'm using to make the ADC measurements:

  • ADC is initially disabled
  • When the temperature button is pressed, the display is turned off, the ADC is enabled, and I enter ADC Noise Reduction sleep mode (which automatically starts a conversion).
  • When the conversion is finished, my interrupt grabs the result and puts it into a variable which is then read by the main program
Based on a measurement I made with a dmm, the temperature sensor is outputting about 20 Celsius, which was about the result I got when using the 5V reference. With the 1.1V reference though, I get a result like 13 C, and after taking a couple of measurements it seems to rise to around 27 C and levels off. If I leave it alone for 20-30 seconds and take another reading it goes back down. I'm guessing the 1.1V reference is dropping for some reason after every conversion, then slowly rising back up to 1.1V.

I have a 1uF cap between the AREF pin and ground, and another cap between the ADC voltage supply and also a 10uF cap on the main voltage supply to the AVR.

Anyone know what's going on?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

after taking a couple of measurements it seems to rise to around 27 C and levels off.

There are a few threads on this--when using the bandgap especially when changing references, it takes some time and/or "dummy" conversions to settle down.

If you have a 'scope or even a good meter, you might try looking at the voltage on the AREF pin.

Try to search out those threads.

I can't explain why it would change after a while, though.

(Is your ADC clock slow enough?)

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ahh cool.

I found the problem with the weird fluctuations. Disabling the ADC also turns off the bandgap voltage. If you don't give the ADC enough time to start back up, the bandgap voltage will not be stabilized.

Found this in the datasheet:
"When the bandgap reference voltage is used as input to the ADC, it will take a certain time for the voltage to stabilize. If not stabilized, the first value read after the first conversion may be wrong."

So if I keep the ADC on all the time (or add a delay after enabling the ADC, I get a steady 1.1V voltage reference!

However, the ADC is still giving me an inaccurate answer. With a dmm, i measure a voltage of about 730mV, the ADC result is giving me about 790mV.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

With a dmm, i measure a voltage of about 730mV, the ADC result is giving me about 790mV.

Tell more about what you mean, "the ADC is giving me nnnV"? ADC results are in ADC counts, as a proportion to the reference voltage.

So show some code on how you are setting up the ADC. And how you are doing your calculations. Tell your AVR clock speed. How close is the 1.1V when you measured it at the AREF pin? Remember it can be about +/- 10%.

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

My ADC clock speed is 62.5Khz (8Mhz prescaled by 128).

When I measured the 1.1V reference with a dmm, it read 1.103 V, so it's pretty close.

I'm pretty sure I'm calculating the voltage correctly, but here's some code.

int32_t temp;
temp = ADCL; // read the low bits of the result
temp |= (int32_t)ADCH << 8; // read the high bits of the result

voltage = (int16_t)(temp * 1100 / 1024); // voltage in millivolts

I tried a quick test now connecting the ADC to ground. The ADC result gave me 80, which is about 86mV, when it's supposed to be more like 8mV. The result seems like it's consistently offset by about 80mV.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hmmm--Gnd should mean Gnd. If you take many, many readings does it settle down? (I've never seen a significant offset in any Mega8/88 family apps. In no AVR apps, for that matter, and I've done a lot of production apps that use the ADC.)

A good AGND connection? No ripple on AVcc/AGND/signal? Try a 'scope instead of a meter?

Perhaps just report ADC counts as a sanity check?

There is always a discussion about /1024 or /1023.

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

D'OH!
So I had an internal pullup resistor enabled on this pin! Turning it off fixed the problem.
Stupid me.

Thanks for the help.