Voltage divider

Hi everybody, i need to make a voltage divider.. from 9v to approximately 5v..
I know that if i use two same resistors i will get the half voltage of the input.. For example :
1)If r1=330 ohm and r2=330 ohm then i ill get 4.5V in the output..
2)If i r1=100 ohm and r2=100 ohm then i ill get 4.5V too..
Those two cases give me same output, any differences? What resistors should i use ?
Thanks a lot ...

The smaller the resistors the more then current draw.
Suggest you use 4.7K each.
What are you using the voltage for?

Do you need a voltage divider or a voltage regulator?

What are you trying to do with this?

zaxarias:
Hi everybody, i need to make a voltage divider.. from 9v to approximately 5v..
I know that if i use two same resistors i will get the half voltage of the input.. For example :
1)If r1=330 ohm and r2=330 ohm then i ill get 4.5V in the output..
2)If i r1=100 ohm and r2=100 ohm then i ill get 4.5V too..
Those two cases give me same output, any differences?

What does Ohm's law say?

LarryD:
The smaller the resistors the more then current draw.
Suggest you use 4.7K each.
What are you using the voltage for?

Ok you are right :slight_smile: I want to measure the input voltage of my arduino, so using a voltage divider i will drive it's output to my arduino's analog input. SO when my battery is full charged, 9V, the analog input will be 4.5...
So i will be able to calculate the battery left using : analog input 100 /4.5..
For example when analog input takes 4.5(battery is fully charged,9V) then i have : 4.5
100/4.5=100% battery, and so goes on!!!
if i use 330ohm resistor then I=Vout/Rout=4.5/330=13.6mA, right ? so i am ok according to the limitation of 40mA per input/ouput pin.. Correct?

Well if you are using 2 resistors you can figure out the values you want by using ohm's law. Which will being you to this equation

V2 = (R2/(R1+R2)) * V1

where,

V1 = your input voltage, in this case ~ 9V
V2 = your desired voltage, in this case ~ 5V
R1 = The resistor closer to your power source
R2 = The resistor closer to ground

by closer I mean the order in which current must flow through.

So knowing this you can say

5V = (R2/(R1 + R2)) * 9V

Since we dont want to kill our power source lets use a decent size resistor, unless of course you want to draw a lot of current. Lets set R1 = 4.7kOhms

So then solve for R2 and you should get 5.875kOhms.

Likewise you can see in this equation why having 2 of the same resistor would give you half the voltage, for example two 1 ohm resistors would give

Vout = 1/(1+1) * Vin or Vout = 1/2Vin

zaxarias:
Ok you are right :slight_smile: I want to measure the input voltage of my arduino, so using a voltage divider i will drive it's output to my arduino's analog input.

OK.

zaxarias:
if i use 330ohm resistor then I=Vout/Rout=4.5/330=13.6mA, right ? so i am ok according to the limitation of 40mA per input/ouput pin.. Correct?

An input pin has very high reistance (megaohms) so you don't have to worry about too much current going in.

However, constantly drawing 13.6mA from a battery will drain it faster. TO avoid this, use bigger resistors (about 20 times bigger, so it's less than a milliamp) and put a ceramic capacitor from the analog input pin to GND to help avoid input noise. The capacitor value isn't very important but most people would pick something around 0.1uF.

just to point out a small item.

the voltage divider is a power use device. it will drain your battery.

the higher the resistance, the less it will drain, but it will always drain

not sure what the suggested method is to measure voltage with the least number of components and the minimum power use.

dave-in-nj:
the higher the resistance, the less it will drain, but it will always drain

Yes, but you have to view it relative to overall power consumption (which we don't know).

If it's only 0.5% of total then maybe it's not a problem.

I strongly suggest that you don't try and divide 9V down to exactly 5V. Your battery probably charges to something higher than 9V, and if the battery dies, the charger will almost certainly drive it to a few volts over 9V.

But if you've exactly divided 9V down to 5V, that puts more than 5V, ie, more than Vcc on an analog pin. That is not a good thing to do. It will have the high resistance in series with it, but it is still not a wise idea.

Besides, you don't really need 10 bits of data on the battery voltage, do you? If you divide 9V down to around 2.5V, you've actually only lost one bit of information. You can adjust the numbers in software.

So very simple, using standard values, you want the high resistor (battery to analog pin) to be 2/3 the value of the low resistor (analog pin to ground). 22k and 10k fit the bill, as would 47k and 15k, or 220k and 100k for even lower power draw. The analog pin needs to be fed with an impedance of <=10k, but you can sort of get around that by adding a 0.1uF capacitor from the input pin to ground.

That also helps get rid of noise, as fungus pointed out.

fungus:

zaxarias:
Ok you are right :slight_smile: I want to measure the input voltage of my arduino, so using a voltage divider i will drive it's output to my arduino's analog input.

OK.

zaxarias:
if i use 330ohm resistor then I=Vout/Rout=4.5/330=13.6mA, right ? so i am ok according to the limitation of 40mA per input/ouput pin.. Correct?

An input pin has very high reistance (megaohms) so you don't have to worry about too much current going in.

However, constantly drawing 13.6mA from a battery will drain it faster. TO avoid this, use bigger resistors (about 20 times bigger, so it's less than a milliamp) and put a ceramic capacitor from the analog input pin to GND to help avoid input noise. The capacitor value isn't very important but most people would pick something around 0.1uF.

Ok so if i use 4,7 kohm resistor i get 4.5/4700=0.95mA which is fine right?

polymorph:
I strongly suggest that you don't try and divide 9V down to exactly 5V. Your battery probably charges to something higher than 9V, and if the battery dies, the charger will almost certainly drive it to a few volts over 9V.

But if you've exactly divided 9V down to 5V, that puts more than 5V, ie, more than Vcc on an analog pin. That is not a good thing to do. It will have the high resistance in series with it, but it is still not a wise idea.

Besides, you don't really need 10 bits of data on the battery voltage, do you? If you divide 9V down to around 2.5V, you've actually only lost one bit of information. You can adjust the numbers in software.

So very simple, using standard values, you want the high resistor (battery to analog pin) to be 2/3 the value of the low resistor (analog pin to ground). 22k and 10k fit the bill, as would 47k and 15k, or 220k and 100k for even lower power draw. The analog pin needs to be fed with an impedance of <=10k, but you can sort of get around that by adding a 0.1uF capacitor from the input pin to ground.

That also helps get rid of noise, as fungus pointed out.

I am not trying to divide to exactly 5, but something less than that..
What do you mean by 10 bits of data?

zaxarias:
0.95mA is fine right?

It's your battery so that's entirely up to you....

Any other way to measure input voltage??? Without using voltage divider....

Not if you are using the internal ADC. Input must remain below VCC.
Two 4.7K resistors in series will result in 1/2 the battery level being read as explained earlier:
Vout = Vin * R2/(R1 + R2)
If R1 = R2 = 4700, then Vout = 1/2 Vin.
9V/(4700+ 4700) = 0.95mA with fresh battery
Can use 50K resistors instead cut current down to 0.09mA, or 90uA.
As long as battery is >= ~7.5V so the 5V regulator is working, you will have accurate readings.
Of course, the regulator is making heat from the excess voltage anytime there is current draw too.

polymorph:
I strongly suggest that you don't try and divide 9V down to exactly 5V. Your battery probably charges to something higher than 9V, and if the battery dies, the charger will almost certainly drive it to a few volts over 9V.

But if you've exactly divided 9V down to 5V, that puts more than 5V, ie, more than Vcc on an analog pin. That is not a good thing to do. It will have the high resistance in series with it, but it is still not a wise idea.

.......

what about a 5V zener diode // with R2 ? it will protect the input

If you don't need the check the voltage very often, and you don't want the constant power draw, maybe you could use another pin of the Arduino to turn on/off your voltage checking circuit.

Maybe something like this?

Not like that, you'll merely measure the voltage on the transistor's emitter which is
0.7V below its base, ie at about 4V. A high side switch is needed, with very low Vsat,
and a level shifting driver to activate it...

Or a low Rds P-channel MOSFET. Use the NPN to pull the Gate low to turn it on.
Using high resistance values lowers the current draw, 90uA seems pretty negligible, and with battery voltage changing pretty slowly, fast response from the higher impedance to charge the ADC sample & hold cap is not be needed.

I mean the ADC, analogRead(), gives you 10 bits of data. That means, if you leave the analog reference voltage set to default, you'll get 0 at 0V input, and 1023 at 5V input. Or actually, 1023 when the voltage at an analog pin is equal to Vcc. That is about 5mV per bit, 5mV between measurements. If you scale that up to the input, that is about 10mV of battery voltage change between measurements.

But at 2.5V (Vcc/2), it reads 511. Which is 9 bits. So even if you only read 9V as 2.5V at the Arduino, that is still 9 bits of information. That is about 10mV between measurements, or 20mV at the battery.

And for the purposes of determining the state of the battery, you really don't need more than 1/10th of a volt resolution.

But for all this stress, you could just use a couple of 100k resistors and a 0.1uF ceramic capacitor, and know that 1023 = 10V so the battery voltage is:

Vb = 2 * analogRead(pin)/1023