Go Down

Topic: Cutting ADC input voltage down to size (Read 1 time) previous topic - next topic


Hello forum, I want to measure the voltage of lead-acid batteries (as a quick and dirty state-of-charge calculation) and came across these threads:



Now, battery voltage can't go much higher than a few volts above 24V so I think a simple voltage divider will do the trick just fine although if you believe I should go the opamp route please let me know.

Now, I have two questions:

1) I don't want to drain the battery with the tiny but non zero current drain of the divider. One obvious solution is to use some pretty enormous resistors but of course it is inelegant. So, I was thinking, can I do something clever with a transistor? Can't I dump a transistor in series with my resistors and switch it on with one of the Arduino's pins whenever I need to take a measurement (it won't be that often, we are talking time of the order of minutes or hours between measurements)?

If that is possible, what sort of transistor should I use?

2) Any simple way I can I "zoom" into the interesting bit of the voltage? This means the upper 4-5 Volts of the measurement. One very dirty solution I can think of is to make a voltage some 18, say, volts higher than the batteries' GND and connect the Arduino's ground there. However, this is unbelievably hideous as it will introduce a current drain for this new divider as well as making life a living hell if I want to connect other sensors which require a common ground between Arduino and batteries.

Any and all ideas welcome.


The enormous resistors won't work well by themselves. For the Atmel ADC the datasheet recommends an output impedance of less than 10K for the source
you are measuring.

You could use the enormous resistors on the input to an op-amp buffer. The op-amp
buffer will have an output impedance very close to zero. Using an op-amp segues into
the answer to #2 ;)

For #2 the measurement is called a null and difference measurement. The op-amp
could be configured to perform an analog subtraction. If you can always
subtract the same value it is easy to do with two op-amps. Otherwise you need
to program the value to subtract. This would be a bit more complicated.

How much accuracy and resolution do you really need? With the ADC in 10bit
mode you are probably around a few tenths of a percent. Your divider may add
a little error (but could be calibrated). Do you need more accuracy than that?

(* jcl *)

www: http://www.wiblocks.com
twitter: http://twitter.com/wiblocks
blog: http://luciani.org

www: http://www.wiblocks.com
twitter: http://twitter.com/wiblocks


A voltage divider of, say 22k-8.2k would draw nominally .4ma.  Surely the measuring circuit would dwarf that.

I was running dividers with megohm resistances  just to avoid loading the circuits but I got a lot of spurious noise which went away when I dropped to 22k-10k.  


Wow, thanks guys. According to this website:


I 'll be looking at voltage differences of the order of some tenths of a Volt (section "State-of-charge reading based on terminal voltage").

bill2009, I 'll play around with 22k-8.2k to see what results I get. BTW, do you think the transistor switching is not a good idea?

jluciani, great, thanks for the tip, I now know what to look for in Google. I 'm off to the shops so I 'll see what kind of cheap op-amps I can get hands on.


Hey there, hard to get op-amps so had a go with some transistors with mixed results.

For a start, I tried measuring a DC voltage from a transformer but with a transistor in the way. I got good some results with a PNP transistor (BC640):

Connecting the Emitter to the voltage to be measured (ranging from 3.9V to 17.8V), the Collector to the voltmeter positive terminal and the Base to GND via a 12k resistor, I got a perfect match between measured voltage and voltage at the transformer terminals. A bit suspiciously perfect in fact, not much evidence of a voltage drop. Connecting the Base to the positive transformer terminal completely cut off the voltage.

Now, I tried substituting the transistor Base input with a digital pin from the Arduino and got some weirdness. At the lowest voltages the transformer provides, 3.9V, the pin succesfully switches the transistor on and off (on when it's LOW and vice versa). At the next higher voltage, 5.7V, the voltmetre correctly reads 5.7 when the pin is LOW but when the pin is HIGH, instead of turning it off, the voltmetre reads 5.92V  :o

This behaviour is repeated for all higher voltages, with the measured voltage jumping roughly 0.2V when the pin goes HIGH. I have tried R1 values from 12K down to 1K with no apparent change.

I 'm obviously doing something very wrong but I can't figure out what. Help?

P.S. How do I upload an image? I made an award winning diagram but I can't for the life of me figure out how to upload it.


A transformer won't work for DC voltages.
Using transistors is going to be difficult. You will end up with an op-amp
built out of transistors.

If you keep the resistors in the 10K range you will not have a problem with
the resistor divider.

(* jcl *)
www: http://www.wiblocks.com
twitter: http://twitter.com/wiblocks


Ooops, sorry, I should have said AC-DC adapter (with multiple output voltages) but it got lost in translation in my head.


How do I upload an image?

Put it on an image sharing site like Flicker. Get the URL from it and then paste the URL between the square brackets that pop up when you click on the third icon from the left in the reply box.


At the next higher voltage, 5.7V, the voltmetre correctly reads 5.7 when the pin is LOW but when the pin is HIGH, instead of turning it off, the voltmetre reads 5.92V

Yes that is to be expected. The base can only go up to 5V but you are putting 5.7V on the emitter, therefore you can never turn this transistor off.
You have totally the wrong idea of how transistors work.
Have a look at:-


Aha, thanks a lot for the link, I got it now. For the switching, I 've found a SIL05-1A72-71L that's cheap and does the job. Now I 'll have to do some reading on the null and difference measurement.


One more question regarding protecting the Arduino ADC. Its max voltage is 5 Volts. To be on the supersafe side, I take the line that goes to the ADC pin and branch it off to a zener that ends at GND. Then, by adding a fuse before the branching we can ensure that it will blow once a big current starts flowing (when the zener floodgates open).

Now, two questions. How much voltage can an ADC pin take before something terrible happens? My zeners have a breakdown voltage of slightly above 5V. I take it a little bit of overvoltage for a little while won't be a problem, right?

Second question, what should the fuse rating be? Exactly the size needed to protect the zener given its max power dissipation? Less?

Go Up