# Question regarding internal voltage reference

Hello everyone

I’ve started a little summer project with building a quadcopter using an Arduino Uno R3 (original, eh?).
Anyway, seeing as the whole thing will be running on a lipo battery I want to monitor the battery voltage. I’ve done some research and the current plan is to make a voltage divider to bring the 12V down to around 1.1V and feeding it into an analog input. And as you may have guessed I’ll read the analog input using the internal 1.1V reference voltage (which I have already measured to be 1.082V).
Now, to the question, what happens if I apply a voltage above 1.1V to an analog input? The reason I ask is that I’ll be running an I2C device on the A4 and A5 pins, which will be running at 5V. I am new to electronics and I’m unsure whether using the internal reference of 1.1V will cause a reverse current when you apply 5V on the pins and whether or not it will be damaging.

Don't let the voltage to the analog input exceed the analog reference.

Instead of changing the reference, why not scale the 12V down to 5V?

[quote author=Runaway Pancake link=topic=172242.msg1279712#msg1279712 date=1371330916] Don't let the voltage to the analog input exceed the analog reference. [/quote] Right, thanks.

[quote author=Runaway Pancake link=topic=172242.msg1279712#msg1279712 date=1371330916] Instead of changing the reference, why not scale the 12V down to 5V? [/quote] During my research I found an article on making precise voltage measurements using the Arduino. In the article they stress that one should use the internal reference as it is much more stable. On the other hand the 5V produced by the Arduino is an unstable reference that can vary over time or as the battery voltage drops. Here's a link to the article: http://provideyourown.com/2012/secret-arduino-voltmeter-measure-battery-voltage/

I am new to electronics and I'm unsure whether using the internal reference of 1.1V will cause a reverse current when you apply 5V on the pins and whether or not it will be damaging.

Nothing will be damaged as long as you stay below the power supply voltage (5V). If you go above the 1.1V reverence you will simply clip (max-out) the A/D, and you'll get a reading of 1023.

DVDdoug: Nothing will be damaged as long as you stay below the power supply voltage (5V). If you go above the 1.1V reverence you will simply clip (max-out) the A/D, and you'll get a reading of 1023.

Alright, that was the other possibility that I considered. Now the question remains, which one of you has it right :D I am too much of a newb to call a winner though, so perhaps someone else can supply further information.

Thanks for the answers though, both of you :)

danclandotdk: I've done some research and the current plan is to make a voltage divider to bring the 12V down to around 1.1V and feeding it into an analog input. And as you may have guessed I'll read the analog input using the internal 1.1V reference voltage (which I have already measured to be 1.082V).

Another approach is to measure the internal 1.1V reference with respect to AVCC/VCC. Since you already know the internal reference (1.082V), you just turn the equation around and solve for VCC. Further still you can now use your calculated VCC as a reliable reference for your other ADC inputs irrespective of battery voltage. For AtMega328, the 1.1V reference can be selected as analog channel 14.

I thought there was some reluctance to use 5V devices with the reference < 5V or something.

http://arduino.cc/en/Reference/AnalogReference

danclandotdk:

DVDdoug:
Nothing will be damaged as long as you stay below the power supply voltage (5V). If you go above the 1.1V reverence you will simply clip (max-out) the A/D, and you’ll get a reading of 1023.

Alright, that was the other possibility that I considered. Now the question remains, which one of you has it right I am too much of a newb to call a winner though, so perhaps someone else can supply further information.

Thanks for the answers though, both of you

All pins have to stay within the supply rails - that’s all.

The 1.1V reference (scaled by a DAC) is sent to a comparator alongside the voltage to be measured, the comparator
doesn’t care what the voltages are if they are within supply rails, it would be just as stressed if seeing a 1.1V signal
on an analog input when AREF is 5V as it is seeing a 5V analog input when AREF = 1.1V… See figure 23-1 in the
datasheet “sample and hold comparator”…

MarkT: All pins have to stay within the supply rails - that's all.

The 1.1V reference (scaled by a DAC) is sent to a comparator alongside the voltage to be measured, the comparator doesn't care what the voltages are if they are within supply rails, it would be just as stressed if seeing a 1.1V signal on an analog input when AREF is 5V as it is seeing a 5V analog input when AREF = 1.1V.. See figure 23-1 in the datasheet "sample and hold comparator"...

Great, thanks! :)

danclandotdk:
Now, to the question, what happens if I apply a voltage above 1.1V to an analog input? The reason I ask is that I’ll be running an I2C device on the A4 and A5 pins, which will be running at 5V. I am new to electronics and I’m unsure whether using the internal reference of 1.1V will cause a reverse current when you apply 5V on the pins and whether or not it will be damaging.

There is only a single ADC on the AtMega and its protected behind a 16 channel multiplexor. Unless you program the ADC to actually read from A4/A5, the ADC subsystem will never be exposed to any voltage on these pins irrespective of reference. For measuring VCC, you should consider using channel 14 (1.1V reference as input to ADC).

BenF:
There is only a single ADC on the AtMega and its protected behind a 16 channel multiplexor. Unless you program the ADC to actually read from A4/A5, the ADC subsystem will never be exposed to any voltage on these pins irrespective of reference.

Cool, that makes sense

BenF:
For measuring VCC, you should consider using channel 14 (1.1V reference as input to ADC).

Not sure what you mean by this
I plan to use the arduino function analogReference(INTERNAL) in conjunction with the attached circuit.

Make the 10K resistor a series 5K pot and a 7K5 or 8K2 resistor and calibrate it for best accuracy, turn the pot until the measured A/D is equal to a known accurate meter.. Simple but low tech, sometimes is best.

Doc

Docedison: Make the 10K resistor a series 5K pot and a 7K5 or 8K2 resistor and calibrate it for best accuracy, turn the pot until the measured A/D is equal to a known accurate meter.. Simple but low tech, sometimes is best.

Doc

I could just calibrate in the software too, right? :) Since I've already measured the internal reference to be 1.082 V and the resistors have 1% tolerence I think it should be pretty accurate, am I wrong? :)

Calibration in software is fine. Also consider taking multiple readings to get a closer approximation to the true value. Bear in mind that the 1.082V will probably change with age and other factors and also ensure that any calibration values stored are checked for degradation in the E2.

cjcj1949: Calibration in software is fine. Also consider taking multiple readings to get a closer approximation to the true value. Bear in mind that the 1.082V will probably change with age and other factors and also ensure that any calibration values stored are checked for degradation in the E2.

Indeed, I was thinking something in the lines of:

``````double vinVoltage;

{
vinVoltage = 0.8 * vinVoltage + 0.2 * ((analogRead(0) / 1023) * 1.082 * VINFACTOR);
return vinVoltage;
}
``````

With the VINFACTOR depending on the resistors in the voltage divider. I realise that this function won't work as intended to start off with as it would take many readings for the approximation to reach a value anywhere near the true value, but I'll probably start out with some raw readings before using readVin().

One question though, what do you mean by "E2" ? :)

Thanks to all who replied, it's been a great help!

danclandotdk: Not sure what you mean by this :/ I plan to use the arduino function analogReference(INTERNAL) in conjunction with the attached circuit.

For a project powered directly from a battery, you can measure VCC without a resistor divider using the following formula (read from channel 14, reference is VCC):

VCC =1.1V * 1024 / ADC

If you power your board through a regulator (as in your case), this approach can not be used to determine battery voltage.

If you power your board through a regulator (as in your case), this approach can not be used to determine battery voltage.

"The solution is to use an internal voltage reference that is built into the Arduino chip. Th*is provides a 1.1 volt reference that is stable for any voltage that is sufficient to power the Arduino chip*. Because the reference is 1.1 volts, the voltage being measured must not exceed this value, so a voltage divider to drop battery voltage down to an acceptable range is required (Figure D-1)."

from: Make an Arduino Controlled Robot.

MarkT: Alright, that was the other possibility that I considered. Now the question remains, which one of you has it right :D I am too much of a newb to call a winner though, so perhaps someone else can supply further information.

Thanks for the answers though, both of you :)

All pins have to stay within the supply rails - that's all.

The 1.1V reference (scaled by a DAC) is sent to a comparator alongside the voltage to be measured, the comparator doesn't care what the voltages are if they are within supply rails, it would be just as stressed if seeing a 1.1V signal on an analog input when AREF is 5V as it is seeing a 5V analog input when AREF = 1.1V.. See figure 23-1 in the datasheet "sample and hold comparator"...

I think this might have moved, if I'm right, checking Figure 28-1. Analog to Digital Converter Block Schematic Operation may have been what is referred to here. If I understand that diagram right, the implication is that there is a comparator that has 2 values input to it, where one is either VCC or the internal 1.1V, and the other is the input from the analogue pin(s).

It doesn't "sound" (bare in mind I'm here with the same Q as the OP, so not an expert) like anything "bad" will happen if the input exceeds what it is being compared to (but please bring an expert to this to confirm)

I'd hazard a guess that any warnings in books against exceeding it are more about pointing out you won't get accurate (or even slightly correct) readings over 1.1v, if you use that as a reference instead of VCC.

Not cool to revive dead posts.

Simple answer: Pin input voltage limitation has nothing to do with Aref. The limits are "GND -0.5volt" and "VCC +0.5volt" If VCC happens to be 5volt, then the limits are -0.5volt and +5.5volt.

If you connect a higher voltage than the Aref to the pin, then the A/D is just pegged at 1023. That happens with >5volt on default Aref, and >~1.1volt if Aref is set to internal. Leo..