Capacitor on AREF of ATmega328.

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

The datasheet mentions that for noise immunity you should place a cap on AREF. But it doesn't mention a proper value. I chose 100nF, as my design already has those. Less different components to keep stock of is good.

Now just one "ADC" can be useful, but you can also switch the MUX and sample multiple channels. As long as you don't need a higher bandwidth.

So, the code would do:
* change mux, start ADC
* if ADC done, store result back to square one.

This is not good: The first result after a mux change is unreliable. So it becomes:
* change mux, start ADC
* if ADC done, discard result start ADC
* if ADC done, store result back to square one.

Now as the "reference selection" is also in the ADMUX register, you can simultaneously change the reference for the different channels. Great!!!

Turns out this doesn't work. The "internal 1.1V reference" signal will be coupled to the AREF pin when it is selected, as documented. Less prominently documented is that AVCC is also coupled to AREF when it is selected.

As far as I can tell, not documented at all is that the internal 1.1V reference will take up to ten sample times before it has been able to discharge the 100nF from 5V to 1.1V....

Does anybody know of any Atmel documentation that proves me wrong:
* A hint from Atmel for a recommended value for the AREF capacitor
* Documentation about the expected current from the 1.1V reference?
* Documentation about the time to wait after a reference change?

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

In practice, 100nF is a suitable capacitor.

In practice, you often change the ADMUX 'channel'.
You normally discard the first reading after changing channel.
You seldom change the reference source.

However, you will obviously need to allow for the capacitance on AREF if you change reference source.

Yes, if you connect an external voltage to AREF pin, you must not choose any internal reference.
This is why you have the AREF jumper on the STK500.

David.

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

From Atmega48-328 datasheet (page 248, par.24.5.2) Aref, when equals 1.1v is "a high impedance source" (but they do not specify the impedance).
If it is resistive, time to settle is like a RC circuit (and successive approximations conversions are wrong until , say it is stabilized with 0.1% accuracy)....

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

Data sheet says AREF input resistance is 32K ohms.

RC time constant with 100 nF cap is 3.2 milliseconds.

Since it takes ~4 time constants to reach 99% of final value, a ~13 mSec delay after changing references would be appropriate if you want the best result.

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

But as the output impedance is missing you can't calculate anything.

And if 10-bit results are wanted, it needs to settle to about 99.9% which is about 7 time constants.

Most likely when internal references are connected to AREF pin for bypassing with external capacitance, it is not even a resistive output.

So basically, if there is a need to switch between references, don't put so much capacitance, if at all, to make it switch as fast as it can. Or then don't use the internal references, just use two different external references.

The other options are (since it is a single-ended ADC instead of differential ADC) to avoid switching a reference are amplifying the weaker voltage to match higher reference, or dividing higher voltage down to use lower reference.

I understand the part about discarding first conversions when the ADC is turned on or waiting until reference settles after change, but I do not recall that first conversion after changing the MUX channel needs to be discarded. That would be a waste.

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

Quote:

...but I do not recall that first conversion after changing the MUX channel needs to be discarded. That would be a waste.

Pretty much all of the issues raised have been discussed quite thoroughly here in the past. The trick will be digging out the pertinent threads.

About "double converting" after a mux change: I wrote AVR apps for years with multiple channels converted in round-robin fashion. ADC-complete ISR; grab result; change mux; start next conversion. Acceptable results.

But there were extensive thread(s) on channel "bleed through" with that method. And numbers to demonstrate it.

I was skeptical, but I'm now a partial believer. As is true in most cases, "it depends". It depends on the drive of the input signal. It depends on whether there is a cap at the input pin for the ADC to "sip" from. I'll try to dig out some of the pertinent thread.

About changing to the internal reference: Indeed, it takes some time to "bleed down" the higher reference voltage. The one thread has "does it badly" in the title; searching...
https://www.avrfreaks.net/index.p...

Start there, and the links. (That thread is more about reading the BG as a channel; still interesting and kind of related to the issues here)

There are a lot of somewhat-related links here:
https://www.avrfreaks.net/index.p...

I can't find the thread where I was [finally, somewhat] convinced that double-converting each channel gives better results--under certain conditions.

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

Quote:
Data sheet says AREF input resistance is 32K ohms.

Yes, the input resistance of AREF is specified. Now the output resistance of the 1.1V reference signal....

@david.prentice, My AVR is a "slave". It will do whatever you tell it to do. So... in practise there is an MCP9700 temperature sensor on ADC6. That rarely goes above 1.1V, so AREF=1.1V is very suitable. Then there is an external input on ADC7. This could easily be a pot between 0 and 5V. So measuring that relative to the 5V is very relevant.

To provide the illusion of two simultaneous channels I hop between the two channels and ref selections.

What bothers me is that I can't find any specs on this issue.

If the AREF input resistance is 32k, for the 1.1V reference to be useful, you'd expect an output resistance of less than about 3.2 ohms, right? It's way, way more than that.

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

Hey :) 

 

From Atmel WebDoc:

http://www.atmel.com/webdoc/stk6...

 

AREF decoupling capacitor

..... A capacitor can be soldered to achieve better noise performance. A typical value is 10nF. The footprint for the capacitor is SMD size 0603.

of all the things i've lost - i miss my mind the most.

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

In programs that I have done that were similar, i.e. using the internal temp sensor, and measuring an external adc input using 5v as ref,  I would select the 1.1v ref first, read adc two or more times to get a good value, then switch to the 5v ref, and repeat the adc reads.  I found the cap charged up pretty fast, so switching from low volts to high volts was faster then the other way around.  After using the 5V ref, reset ref back to 1.1v, and time for main loop to sleep, giving plenty of time for the ref cap to discharge before the next trip through the loop.     

 

Can you re-order your adc reads?

 

Jim

 

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
https://www.onegold.com/join/7134f67c2b814c5ca8144a458eccfd61