9
\$\begingroup\$

From the ATMega328 datasheet, section 24.9.1:

The internal voltage reference options may not be used if an external reference voltage is being applied to the AREF pin.

From the Arduino reference pages:

Alternatively, you can connect the external reference voltage to the AREF pin through a 5K resistor, allowing you to switch between external and internal reference voltages. Note that the resistor will alter the voltage that gets used as the reference because there is an internal 32K resistor on the AREF pin. The two act as a voltage divider, so, for example, 2.5V applied through the resistor will yield 2.5 * 32 / (32 + 5) = ~2.2V at the AREF pin.

The ATMega328 datasheet confirms the "internal 32k resistor" reference in table 29.16 ADC Characteristics with: Reference Input Resistance = 32 kOhm.

That being said, the above two statements seem to be somewhat in opposition to one another. I've got an application with some sensors outputting 0-5V full scale and others outputting 0-1.8V full scale. The application would benefit from the increased resolution of switching to 1.8V AREF when sampling the 1.8V sensors and switching to the internal AVCC reference for the 5V sensors.

The Arduino reference pages suggest that's an OK thing to do given you've coupled to the 1.8V AREF through a 5kOhm series resistor and accounted for the implied voltage divider with the internal 32kOhm resistance. Is this just bad advice from the Arduino reference, or is it in fact a common practice to do this sort of thing? Is Atmel's statement restricted to external voltages applied to AREF without an external current limiting resistor (and if so why, given the internal 32k resistance)?

As an aside, obviously, one could achieve a similar result with a properly constructed op-amp to scale the 1.8V signals up to 5V, but the added complexity and parts seems wasteful if it can be handled by the on board ADC just as well by taking advantage of the change-able voltage reference. Likewise if you could convince yourself that the sensed signal would not exceed 1.1V you could take advantage of the internal voltage reference. Again, it just seems more elegant to me to use the 1.8V regulator I'm powering my low voltage sensors with to set the reference.

\$\endgroup\$
  • \$\begingroup\$ Also, can you reword "Is Atmel's statement restricted to unimpeded external voltages applied to AREF?" I don't understand "restricted to unimpeded". Thanks. \$\endgroup\$ – Telaclavo Apr 23 '12 at 19:07
  • \$\begingroup\$ @Telaclavo I've made the statement clearer (hopefully) \$\endgroup\$ – vicatcu Apr 23 '12 at 19:17
  • \$\begingroup\$ I think I just saw where your confusion might come from, but can you post a link to the schematic of the specific Arduino that you are using? \$\endgroup\$ – Telaclavo Apr 23 '12 at 20:04
  • \$\begingroup\$ @Telaclavo no specific Arduino in mind, the Uno would suffice as an example. On the base board, AREF is not connected to any voltage source, but simply decoupled to GND through a 100nF capacitor. If I had a 1.8V regulator, on a shield for example, I could in principle connect it to AREF through the shield headers by way of a 5kOhm resistor to reference the ATMega328 ADC to 1.8V, then switch to the internal AVCC reference (which is wired to 5V on the Uno) in software to reference the ATMega328 ADC to 5V. \$\endgroup\$ – vicatcu Apr 23 '12 at 20:35
  • \$\begingroup\$ Ok, first I thought that the 5 kohm resistor is included in the Arduinos, but it is not. I just updated my answer. And I think that your confusion came from not acknowledging that the 32 kohm resistor goes from AREF to ground. Otherwise I wouldn't understand your "and if so why, given the internal 32k resistance?" \$\endgroup\$ – Telaclavo Apr 23 '12 at 20:53
8
\$\begingroup\$

I don't see any problem with applying an external voltage, through a 5 kohm resistor, to the Arduino reference input. Or better, with using a resistor divider, so that you turn 5 V into your desired AREF voltage, while at the same time exhibiting a source resistance of approximately 5 kohm. This second requirement does not have to be accurate. That is just to limit the current that will flow from AVCC to ground, through the external circuitry.

schematic

If you want to end up with 1.8 V at the AREF input of the MCU, just choose R1 and R2 so that \$ V_{AREF} = 5·\frac{R2||32000}{R1+(R2||32000)} =\$ 1.8 V and \$ R_{source} = R1||R2 \approx\$ 5 kohm.

When you need to work with the [0, 1.8] V range, disable the references internal to the ATMega, and when you need to work with the [0, 5] V, enable the internal AVCC reference (if that is 5 V). If the MOSFET shown in Fig. 24-1 (that connects the internal references to the AREF line) has an on resistance much lower than 5 kohm (which I suppose it has), the internal circuitry will see AVCC. In this second situation, the current drain from the internal AVCC (assumed 5 V) to your external resistor divider will be \$\leqslant\$ 1 mA, but that is not a problem.

In summary: it would be bad advice if something could get damaged, but 1 mA won't damage anything.

\$\endgroup\$
  • \$\begingroup\$ +1 for calling out figure 24-1... which suggests to me (as well) that a current limiting resistor on AREF is a safe bet. \$\endgroup\$ – vicatcu Apr 23 '12 at 19:23
  • 1
    \$\begingroup\$ I think I'd rather accept a small voltage drop at AREF and use a single external 5kOhm resistor to source 1.8V from a regulator though... but I find your answer to be worthy of acceptance \$\endgroup\$ – vicatcu Apr 24 '12 at 2:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.