20 posts / 0 new
Author
Message

i want to use the AVR to read the level of a 24v battery, and if it gets too low i have it do some function. like show the batt level on an LCD, or w/e.

i know the ADC i would have to build a voltage divider or something to scale the 24v down to 5v or ill blow the AVR.

any ideas?

Use voltage divider resistors 10k and 2k. Feed the 2k resistor drop to ADC input. Connect a 100nF ceramic cap close to ADC input pin and Ground.
Multiply the ADC result with 6 to get Battery voltage.

If you don't have a known processor voltage as the reference voltage (your processor is running on its own battery supply for example from 5V down to 1.8V on the V series uC's.) for the 10k 2k network you can use 20k and 1k and the internal 1.1V reference. At 24V you will get 1.14V (close enough) then multiply by 21. You can also left shift the result for an 8 bit result and since you are looking for just a single point over or under a reading of 19 volts would be .90 volts or give a reading of 204 from the ADC so you don't need to multiply 10 bit numbers.

I have code for the mega48 that uses this to test a solar panel voltage, a different resistor network but still the same circuit and code if you would like to see it, I can post it tonight.

yea i would like to see that code/schematic if you dont mind. im using an Atmega8-16PI.

im going to be using 8 bit resolution, not 10 bit. sp multiplying over 8 bits isnt an issue.

Whats the lo volts threshold for your 24v battery? 22v? 21v? Should be able to detect 3 out of 24 ( 1/8th or so) with 8 bits no prob....

Imagecraft compiler user

the cutoff will be 18 bare minumum. :)

The Atmega8 only has a 2.56V reference so the resistor network would have to be modified, if you are using a regulator for the chip from the 24V supply then just use the VCC as a reference voltage.

its 2 12v 17ah batteries for a RC lawnmower of mine. i dont know what i should make the cuttoff voltage. 18? 20? not sure.

A 12V battery is about 80% discharged at 11V... so I'd set the cutoff about 50% discharge or about 11.5V, so 23V?

Imagecraft compiler user

yea becuase i dont know if these batteries are deep cycle, so running them flat would be a BAD idea. :)

it says on the batteries:

Standby: 13.5 - 13.8v
cyclic use: 14.4 - 15v

Also don't forget that batteries have some internal resistance. So as you pull load, it will appear as if your battery is less charged.

So if your load is significant, you can use a small (0.01 ohm) sense resistor. Then you can tell the "real" charge based on voltage and sense resistor current.

Check out the LM7914 (bar display driver) and HDSP-4820 (LED bar display) for your fuel gauge.

Regards,
Paul

Lead acid accumulators say something like maximum discharge is 10.5V for a 12V batt. Thus the very minimum should be 21V. Since it is better to avoid full discharge, I would suggest 22 to 23V minimum while no load applied (or very low one, let's say 300mA).
As Paul (pkafiq) told, be aware about the load (current drawn from the batteries), since DC motors take a lot of current and that lowers the measured voltage.

On the other side, when charging batteries, you would find that they reach about 14,5V and up to 15 (depending on charge current) when full, thus better you scale your voltage divider to accept about 30V at full scale. Then you would have about 0.11 V /step from the ADC sampling at 8bits resolution. Not too good, but probably enough.

Guillem.

Guillem.
"Common sense is the least common of the senses" Anonymous.

yea maybe. but the reason im going to use the AVR for battery monitoring, is becuase there is a transceiver on board that sends the batt voltage remaining to my remote so i can look down and see. it works well for reporting a test result, but i stgill have to setup the ADC and make the software for it.

another thing is, im not exactly clear on how to read voltage with the ADC. i know that if you increase the input to the ADC, the output value increases, BUT im not exactly sure on how and how much it increases per volt, etc etc

what i mean is lets say i use a 10:1 voltage divider, and if the input voltage is 24, the output should be 2.4v

well if 2.4v is sitting on the ADC, how do i know what the output value is expected to be on the ADCH-L? and how would i be able to take this value and put it on a bargraph on the LCD and say Voltage: 22v or w/e

would i just take the 2.4v reading in the ADC multiply by 10 and convert it to decimal and thats my voltage?

Don't forget any divider will load down your battery. this may not matter with a big battery. If it does use large value resistors for the divider & beffer with a unity gain opamp feeding your ADC. You can also spin the amp to include some filtering to smmoth out any battery rippple.

Hoyt

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

well the circuitry is going to have to have a lot of filtering anyway. becuase the PWM and the noise produced from the drive motors will most likely make my digital circuits perform the jitterbug, or a xmas light show.

Quote:

If you put a small resistor in series with your load, you can measure a small voltage drop (V=IR) to indicate how much current you are using without causing a significant voltage drop to your system. In this case (with a 0.01 ohm resistor), only 0.1V at 10A.

Regards,
Paul