Mega328P ARef Bypass Cap?

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

I've been through the full manual for the Mega48/88/168/328 family and see nothing about recommended value for bypass cap on ARef. 

 

I will be switching the ADC on and off (maybe once an hour) so start up time will be important. I could also not find any information about even the order of magnitude of the source impedance for ARef. It always just says "high". But, does that "high" mean 1K, or 10K or 100K or even higher? It would be really useful to know this in order to determine the time constant that results from the capacitor choice. The spec sheet calls out a maximum bandgap startup of 70uS but I would expect that filtering RC to be several orders of magnitude longer.

 

Thanks

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

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

I've always used a 0.1uf, and threw away the first ADC conversion as suggested in the DS.   Never had a problem with turn on time...

Now changing from 5v AVCC to internal BG would take a while longer then that...

 

 

 

Jim

 

Mission: Improving the readiness of hams world wide : flinthillsradioinc.com

Interests: Ham Radio, Solar power, futures & currency trading - whats yours?

 

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

A bit of a moot discussion, IME -- after you fire up an AVR8 ADC you should toss the results of the first conversion, anyway.  And that first conversion takes longer.  So if indeed you calculate a few hunderd microseconds to get settled, it takes that long to do a useful conversion anyway.

 

 

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

Good points, both of them. In all the AVR programming i have done, have never used the ADC :=(

 

A question about that dummy first conversion. Do you need to actually read ADC before starting the first "real" conversion or can you just charge ahead, once the first (discarded) conversion is complete?

 

Thanks

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

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

I also haven't used the ADC much but:

The analog voltage is sampled near the beginning of a conversion.

It seems unlikely that you have to read the ADC registers.

On the other hand. Who cares about an extra 100us during startup of the AVR (to read the first dummy conversion).

 

Note:

ADC results can also off if you change significant stuff for the ADC converter.

Tings like turning it off temporary or change the source of the voltage reference. (Details are vague).

 

Vref:

Had a peek at 2 datasheets. Only found suggestions that a capacitor on Vref might improve noise performance.

In either case, the external AREF pin is directly connected
to the ADC, and the reference voltage can be made more immune to noise by connecting a capacitor between the
AREF pin and ground. VREF can also be measured at the AREF pin with a high impedance voltmeter. Note that
VREF is a high impedance source, and only a capacitive load should be connected in a system.

The "high impedance" part suggests that the capacitance it mostly irrelevant. Anything > 10pF or so is probably ok.

Won't be surprised if the noise would onle be a few lsb without andy capacitor.

"high impedance" also suggests that you want a low leakage cap.

And because AVR's only have a 10 bit adc it's not going to be very critical anyway.

 

-------

On the other hand:

You can get higher resolution by averaging a bunch of samples.

For this averaging to work properly, a bit of noise is mandatory.

Averaging does not work without noise!

 

For example:

You have a 10 bit ADC. Value will be between 0 and 1023.

Suppose the "real" analog input value is 214.2

If you average 100 samples without noise it is likely that all samples will be 214

If you average 100 samples with a few lsb's of noise then the average will be near 214.2.

Atmel has released a application note about this.

(Microchip also, years ago, before the merge).

Paul van der Hoeven.
Bunch of old projects with AVR's:
http://www.hoevendesign.com

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

The impedance is probably affected by your choice of reference...Bandgap, chip supply, or external.

I'd guess bandgap is probably "weak" (higher z), while an internal connection to a chip supply is probably fairly strong (low z).

Be aware that the bandgap has good temp stability but awful guaranteed accuracy (+/-10%)...typically much better & can be ignored if you don't need absolute readings.

I think some of the newer chip flavors may have improved this tolerance a bit (pun intended).

 

If you want to save more power, be sure to disable the digital decoders on any PCx analog pins, using the DIDRx register(s).

 

There's a bunch of dribble in the datasheet about making low noise conversions (stopping clocks, not changing I/O during conversion, quiet mode, etc)...but I've always had good results without doing any of that (perhaps doing a few averages).

 

When in the dark remember-the future looks brighter than ever.

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

Regarding caps on AREF, I would check app note AVR042:

David (aka frog_jr)

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

ka7ehk wrote:
Do you need to actually read ADC before starting the first "real" conversion or can you just charge ahead, once the first (discarded) conversion is complete?

 

When I init the ADC, I do a conversion at the end of the init, from that point on, you can charge ahead with your ADC readings.

If you power down the ADC, just run through the init again before calling the ADC_read() function......

 

Jim

 

Mission: Improving the readiness of hams world wide : flinthillsradioinc.com

Interests: Ham Radio, Solar power, futures & currency trading - whats yours?

 

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

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"Read a lot.  Write a lot."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

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

I missed that Reference resistance spec. THANKS! Also, did not think to look at App Notes. That also helps. 

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

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

Note that this spec may not apply, as it is the input resistance.  When using an internal reference, the effective impedance at AREF will be more when combined with the internal source's own impedance.  And no, I don't know what that is.

 

You could compute it by placing a high-value capacitor on AREF, turning on an internal reference, and timing how long it takes to rise from 0V to 63.2% of the reference voltage.  Mind you, this will only tell you what the impedance is of >>that<< reference, on >>that<< device, but it's better than a stab in the dark.

 

A 1uF cap should take 32 ms at 32K, or 1 second at 1M.

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"Read a lot.  Write a lot."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

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

Note that this spec may not apply, as it is the input resistance.  When using an internal reference, the effective impedance at AREF will be more when combined with the internal source's own impedance

I wonder if the bandgap is essentially a 1.1V zener in series with a 32K  "resistor"...so below the zener voltage (ramping up) you get 32K output, until the zener starts to activate to gnd. There's probably a weak switch in the mix (few ohms to few hundred), to select bandgap, VCC, or ext as the ref (external mode is probably simply not connecting either bandgap or Vcc to aref) ....it would be interesting to capture the resulting curve(s) on the scope to see them.

 

here are some various viewpoints from an older post:

https://www.avrfreaks.net/forum/aref-internal-reference-and-absolute-max-ratings

When in the dark remember-the future looks brighter than ever.

Last Edited: Tue. Jan 9, 2018 - 10:05 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

To restart this thread with a direct continuation of the starting point:

 

Still M328P...

 

Does anyone have any direct experience with using or not using a cap on ARef when Vcc is the reference? AVcc  is already well bypassed and, logically, it would seem likely that the impedance between AVcc and ARef is probably relatively low.

 

It is a pain to add a cap there, where there is no provision for one, and it would be really helpful NOT to have to install one.

 

Observations appreciated.

 

Thanks,

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

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

Just speculating,

I would think that IFF the ADC is read at a relatively slow rate (I have no idea what that would be), you might be able to get reasonable results without a cap on AREF.

 

However, this is, IMHO, not a good idea...

 

 

David (aka frog_jr)

Last Edited: Mon. Feb 12, 2018 - 02:21 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The only time I have not used a cap on the AREF pin was in apps running on tiny's (25/45/85) where I needed the pin for i/o and could not spare it for AREF use.

It seemed to work fine, but would depend on what else is running at the time the ADC sample is taken, is the vcc stable at that time or does the load change while taking your samples?

 

Jim

 

Mission: Improving the readiness of hams world wide : flinthillsradioinc.com

Interests: Ham Radio, Solar power, futures & currency trading - whats yours?

 

Last Edited: Mon. Feb 12, 2018 - 02:33 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

From some old test (and from memory) I think to remember that it's ok if you only use one ADC.

But if the MUX is involved and/or there are big difference between the two voltages it take a long time to be correct. 

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

Thanks. 

 

I guess that experiments are in order. Other processes ARE running at the same time that the ADC  is, so there might be some interaction. After all, there is "ADC  Noise Reduction" sleep mode,  though it is hard to tell just what noise interaction path that targets.

 

Jim

 

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

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

Taking 10-100 averages is probably enough to quash any noise (assuming it is zero-mean).  If I remember, you need 4X samples to cut the variance in half (square root relation) ..experiments are in order!  Maybe you don't need all 10 bits anyhow, so any noise becomes less obnoxious.  The noise (or at least accuracy) could be affected buy how fast the adc runs (it is known you can overclock if tossing out a few lsb's), so perhaps experiment with the adc clock rate too.

When in the dark remember-the future looks brighter than ever.

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

 it would seem likely that the impedance between AVcc and ARef is probably relatively low.

I don't design Atmel chips...

 

But I'd think it is safe to say that when ARef is selected the impedance between the ARef pin and the ADC module is quite low.

I'm not sure you can make many assumptions about the impedance between the ARef pin and Vcc.

 

JC 

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

But if the MUX is involved and/or there are big difference between the two voltages it take a long time to be correct

Changing MUX doesn't affect the reference, though.  The cap on AREF is meant to filter out switching noise created by the ADC itself, and any noise resulting from switching I/O pins powered by AVCC.  AREF is connected directly (via a passive analog switch) to the comparator at the heart of the SAR ADC peripheral, while AVCC is a power bus, so switching of gates powered by that bus will cause noise on that bus.

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"Read a lot.  Write a lot."

"We see a lot of arses on handlebars around here." - [J Ekdahl]