Accurate way to switch between External (Aref supplied) and AVcc Reference

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

Hi all

 

I would like to have 3.3V and 5V as the reference for my Atmega 2560.

 

I was thinking of an accurate way to this.

 

I was hoping to find a reference voltage that can produce two different voltages but I failed in finding such a reference voltage.

 

Then I thought of adding a resistor to Aref and hooking it up to a reference voltage which produce above 3.3V and considering that datasheet says Aref is 32K, I can exactly calculate the voltage the I need to generate.

I used a 4.7K and used a regulator (to just test the idea) set at 3.785V to see how close to 3.3V I get on Aref when the ADC is using Aref as the reference. The Aref was off by 50mV. I then calculated the Aref resistance and it ended up being 27.5k. I used the same regulator set up and the Aref resistance was different on the other 2 megas I had around (mega 2560 and mega 328). Mega 328 has the closest result and the other mega was also producing better result. I was thinking if it is reliable to design based on 32K? I think even 50mV can be accepted but I am not sure if on other chips the internal resistance remain around the same.

 

I tried to find similar questions (I honestly think this should be a common problem) but I failed on using the correct terms because I did not find anything that suggest a solution.

Last Edited: Tue. Sep 12, 2017 - 08:49 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

alireza.safadri wrote:
I would like to have 3.3V and 5V as the reference for my Atmega 2560.

Tell what the Vcc level of your AVR is.  If it is e.g. 5V then you can use AVcc as your reference.

 

Tell the application of this feature.  I guess I do have apps that sometimes use the internal/bandgap reference, and other times a different level.

 

A brute force method would be to switch in a voltage divider on the higher level.

 

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

It is for a remote control that is connected to so many different pots, moreover in future we may have analog devices that operate at 5 volts. The AVR is running at 5V, so I was planing to use AVcc for 5V ADC and Aref for 3.3V stuff. However this can not be achieved because the 3.3V will be always applied at Aref and when I switch the reference to AVcc, I will create a short circuit.

 

Aref is not the same as Internal/band gap reference because it is shared between all sources, so once you set a voltage there, the using other sources will create a short circuit.

 

I am not sure what you mean by brute force method, but I do not want to loose too much resolution.

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

AVcc must be connected to a voltage that is very close to Vcc. No choice. You cannot have AVcc = 3.3V and Vcc = 5V.

 

A simple CMOS analog switch should be fine. At zero load current, the voltage drop will be zero.

 

But, then again, why bother? Use the internal switch. Connect your 3.3V reference to Vref. Switch between Vcc as the reference and Vref as the reference under software control.

 

Jim

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

Last Edited: Tue. Sep 12, 2017 - 03:01 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Jim

 

I think you missed this part of Data Sheet 

If the user has a fixed voltage source connected to the AREF pin, the user may not use the other
reference voltage options in the application, as they will be shorted to the external voltage. If no
external voltage is applied to the AREF pin, the user may switch between AVCC, 1.1V and
2.56V as reference selection.

I am not sure about CMOS Analog switches and I need to read about it. 

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

Then external analog switch!

 

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 that model also has a nominal 2.5V internal reference.  Good enough for your ~3V work?

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

I was hoping to find a reference voltage that can produce two different voltages but I failed in finding such a reference voltage

 

 

...just use any decent 3 terminal regulator ...the smallest will work, since no current is needed by the adc ref.   You can use a few resistors to tie a port pin into the reg adj pin  & create plently of levels (min of 2 levels using one  I/o pin) ...sort of a poor man's dac.

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

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

Use external reference only, and an I/O pin to switch between 3.3V and AVCC:

                                AVCC
------------+                    |
            |                    /
            |                    \
            |                R1  /
            |                    \
            |                    /
            |                    |
       GPIO |--------------------+
            |                    |
       AREF |--------------------+
            |                    |
            |                    /
            |                    \
            |                 R2 /
            |                    \
            |                    /
            |                    |
------------+                   GND

With the GPIO as an output high, AREF will see VCC.  With the GPIO as an input without pullup (HiZ), AREF will see the voltage divider.  Select R1 and R2 such that (AVCC * R2) / (R1 + R2) is 3.3V.  If you select a GPIO pin whose output driver is supplied by AVCC, then you'll benefit from any LC filter you have in place on AVCC.  On the 2560, that's all of ports F and K.  You'll want to use 1% resistors or better.

 

Note that a GPIO output driver has an impedance of about 25 ohms when VCC is 5V, so select suitably high values for R1 and R2 such that this impedance doesn't result in a significant voltage drop.  R1 = 127K and R2 = 249K gets you 3.31V +/-1%, and should keep you within about 1 LSB of AVCC when the GPIO is high. 

 

A small cap on AREF to GND will help to stabilise the reference signal.  Say, 100 nF.  Note that whenever you switch the reference you'll need to allow time for it to settle anyway, but adding a cap means you need to wait longer.  To settle within 1/2 LSB, you'll need about 7.62 TC.  With R1=127K and R2=249K, the output impedance of the voltage divider is 1/(1/127+1/249) = 84K, and with C = 100 nF, then the TC = 8.4 ms, and you'll need about 65 ms of settling time when switching from GPIO high to GPIO HiZ.  You can reduce that by using a smaller cap.  10 nF will reduce the settling time to 6.5 ms.  You'll need much less time when switching the other way, about 20 us.

"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]

 

Last Edited: Wed. Sep 13, 2017 - 05:38 PM