Any examples on using the built-in ADC to monitor a 24V SLA battery?
![RobotWorkshop](https://forums.parallax.com/uploads/userpics/915/nCTRZ4MIBWKDB.jpg)
Hello,
I need to monitor the voltage on a pair of 12V SLA batteries connected in series. At the very least I'd like to use either the built-in ADC of the SX chip or an external ADC chip to get an analog reading of the voltage. An 8-bit ADC reading is fine as I just want to get an idea of what is left in the batteries. I'd like to focus on the range of 21v up to about 27.6V and convert that to a range of 0-5V for the ADC. Anyone have any examples that may work?
There is a 12V line from between the two and using that one as well perhaps get a reading there two so the charge on each battery can be determined.
Robert
I need to monitor the voltage on a pair of 12V SLA batteries connected in series. At the very least I'd like to use either the built-in ADC of the SX chip or an external ADC chip to get an analog reading of the voltage. An 8-bit ADC reading is fine as I just want to get an idea of what is left in the batteries. I'd like to focus on the range of 21v up to about 27.6V and convert that to a range of 0-5V for the ADC. Anyone have any examples that may work?
There is a 12V line from between the two and using that one as well perhaps get a reading there two so the charge on each battery can be determined.
Robert
Comments
Your requirements sound similar to something I did a while ago in this thread: Increasing ADC Stability by Design or Filtering.· The thread is mostly about some trouble I was having but the second to last post includes my working ADC code.· I think this approach can work well for monitoring battery voltage.
- Sparks
Although I missed that excellent thread it isn't exactly what i'm after. It looks like the schematics presented are using the ADC to check the voltage range of 0-5v which may be the same supply as the SX CPU is using. I really want to scale that up a bit so I can take check the voltages of a 24v battery.
I'd be glad if I could use it to get an 8-bit ADC reading from 22v to 27v as I only care about the upper end. I'm not quite sure the best way to proceed. Since the voltage is quite a bit higher than the power to the CPU I also need to ensure that I don't do anything to toast the CPU. Instead of the onboard ADC another option may be to use an ADC0831 8-bit A/D converter DIP. With that I still have the issue as how to work on the analog side to get the upper end of the battery voltage within the 0-5v range of the ADC. I've used this ADC chip before so it would be easy for me to connect to the host.
To re-prhase the issue it is more of an analog one. Instead of trying to get a 0-27v reading to scale down to 0-5v I'd just like to get the 5v range at an offset of 22v so the reading would be 22v-27v. That is where i'm stuck at the moment and looking for suggestions.
Robert
The zener will·act as a constant 22 volt voltage drop, so the resistor·will be the battery voltage minus 22 volts.·Then your 5V ADC can read the·resistor voltage, which·should·vary from 0 to 5. Then in software·take the ADC reading, and add 22 volts...
You may also want to add some protection to to the input of the ADC (A resistor in series with the input, resistor and Zener...)
-Dan
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"A saint-like quantity of patience is a help, if this is unavailable, a salty vocabulary works nearly as well." - A. S. Weaver
Thank You!
Robert
component values. With two additional resistors you
can set the input voltage range.
The calculated value for C is the value that keeps the ripple
at the mcu input pin due to toggled mcu output pin (@Uin = (Uinmax+Uinmin)/2)
below Vdd/(2^N).
regards peter
Here is a first draft of the circuit to scale the value from the 24V battery so the 5V ADC can read it. At the moment I have it on a breadboard connected to a variable power supply. It seems to be generating the right output but perhaps a couple of the resistor values could be tweaked a bit to improve it. The suggestion that dkemppai had about using the 22V Zener was a great help and seems to work well.
As a recap I wanted a way to monitor the voltage of a 24V SLA battery. I was only concerned with the battery range of 22V-27V (which happened to fit into a nice 5V range) instead of scaling the 0-27V value to a 0-5V range.
The system already has a separate circuit to shut down if the voltage gets near 22V so nothing below that matters. Anything over 27V is considered 100%.
The 5.1V Zener was installed as a precaution to limit the voltage to 5V to protect the ADC port. The ADC isn't shown but is an ADC0831 chip.
I'd like to get some feedback on this to make sure it looks ok before I wire it up in my robot. The current schematic is attached.
Robert
· It looks okay to me.
· But realize that if the batteries are at 27 volts, you will be drawing 5mA constantly from the batteries.
· You may want to put a cap at the ADC input to "stiffen" the voltage when the ADC samples.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Did you know that 111,111,111 multiplied by 111,111,111 equals 12345678987654321 ?
www.iElectronicDesigns.com
·
Both excellent points! I suppose changing that 1K to something like 2.2K or more might be better. No sense wasting power! In regards to the cap do you think a .1 from the ADC input to ground would help?
Robert
· Yeah 0.1uF should work fine.
· If you have an extra I/O pin, you could connect it to the 1K (instead of grounding the 1K). Then when the I/O pin is high (+5V), no current will be wasted. And the I/O pin can be made low to take a measurement.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Did you know that 111,111,111 multiplied by 111,111,111 equals 12345678987654321 ?
www.iElectronicDesigns.com
·