I need to incorporate a battery monitor using a 10 led bar graph. I am powering the arduino with a 7.4(though it reads 7.67) V lithium polymer battery through the arduino`s power jack. The goal is to monitor that battery. How would I go about doing this? I have a LM3914 driver to use if I want but I am clueless as to what to do.
A two cell lithium battery will vary between 8.4V (fully charged) and 6.8V.
If you have an LM3914 then you don't need anything else. Are you just trying to create the LED bar graph or are you trying to do something more than that?
Chagrin:
A two cell lithium battery will vary between 8.4V (fully charged) and 6.8V.If you have an LM3914 then you don't need anything else. Are you just trying to create the LED bar graph or are you trying to do something more than that?
Just trying to create the led bar graph, which lights up the approriate amount of leds for the corresponding charge of the battery. How would I go about doing this? I have tried google and have seen many many varying solutions. If you can point me to the right way and explain to me in the simplest terms possible, id be very grateful. This is part of my first co-op and I really don't want to disappoint.
Also I have just been imagining the circuit in my head:
Even if I made the circuit, how would I connect it to my battery? THe battery is connected to the power jack in the arduino. Would I use a splitter(if such athing exists)? Please pardon my noob language.
bump
You need another connection to the battery and a voltage divider with a resistor since Arduino is capable of measure max 5v.
Please find the wiring attached: you use two resistors to reduce the voltage within 5V, in this case I divided the battery voltage by 2 so you will measure 3.7V when the battery is at its maximum (btw, fully charged two cells battery is 7.4V at maximum, not 8.4 as reported above) and 3.1 when fully discharged: discharging below that will damage the battery.
You can now use an analog pin (A0 in the wiring I made) to measure the halved battery voltage by using analogRead and then use the map function to remap the value to the proper led bar scale.
rlogiacco:
(btw, fully charged two cells battery is 7.4V at maximum, not 8.4 as reported above)
3.7V is the nominal, per-cell voltage. Fully charged is 4.2V.
zoomx:
You need another connection to the battery and a voltage divider with a resistor since Arduino is capable of measure max 5v.
would such a thing work? What I am really confused about is whether the voltage is the same across both of them (7.4) or whether it splits to 3.7? Also if the voltage is the same across both of them, when the voltage drops to lets say 7, will there be 7V running through both jacks? Sorry if the wording is a bit confusing.
rlogiacco:
Please find the wiring attached: you use two resistors to reduce the voltage within 5V, in this case I divided the battery voltage by 2 so you will measure 3.7V when the battery is at its maximum (btw, fully charged two cells battery is 7.4V at maximum, not 8.4 as reported above) and 3.1 when fully discharged: discharging below that will damage the battery.You can now use an analog pin (A0 in the wiring I made) to measure the halved battery voltage by using analogRead and then use the map function to remap the value to the proper led bar scale.
Yes, I realized just today that voltage division might be the perfect thing.
A couple questions of about that:
Does it matter what value of resistor I use? I mean if according to the formula, if R1 and R2 are equal, the voltage will divide by 2. Is it any safer to lets say use a 10k resistor compared to a 1k?
Also, in your drawing, what is that thing in between the two resistors? Is that voltage dividor? I thought that voltage division was just a principle and that if i used a wire between the two resistors, the wire would carry the voltage thats been divided into whatever?
It is pretty simple either way.
For the LM3914, you want to wire it up as something called an expanded scale voltmeter. It has an internal 1.25V regulator, not unlike an LM317, with the extra complication that current through this also determines the LED current.
In short, you want pin 4, RLO, to be connected to a source of 3.1V. And pin 6, RHI, to be connected to a 4.2V source.
It is a relatively simple matter to connect the internal 1.25V regulator to supply 4.2V, with one pot to adjust that, and another pot to pick off 3.1V. They will interact, because the internal circuitry has resistance of 10k.
Look at page 8 of the PDF, things will be much clearer.
Quick and dirty. First is relatively optimized values but requiring not as standard 750 ohm resistor and 250 ohm trimpot.
Second version using 1k resistors, 2.2k, 330 ohm, and only 1k pots. Adjust for 4.2V at pins 6 and 7, and 3.1V (or whatever your chosen fully discharged level is) on pin 4. The adjustments will overlap, I suggest setting the top trimpot to 50%, then adjust the lower for 4.2V at pins 6 and 7. Then adjust the upper trimpot for 3.1V, repeat until you have it where you want it.
To cover 2 Lithium Ion in series, simply add a 10k-10k resistive voltage divider to the input on pin 5.
LED current is approximately equal to 10x the current out of pin 7, Vref out. In this instance, about 1mA, therefore about 10mA LED current.
Chagrin:
rlogiacco:
(btw, fully charged two cells battery is 7.4V at maximum, not 8.4 as reported above)BU-409: Charging Lithium-ion - Battery University
3.7V is the nominal, per-cell voltage. Fully charged is 4.2V.
Right, my bad.
That link return 403 FORBIDDEN error: I believe you must be logged in to see it.
mananp:
would such a thing work? What I am really confused about is whether the voltage is the same across both of them (7.4) or whether it splits to 3.7? Also if the voltage is the same across both of them, when the voltage drops to lets say 7, will there be 7V running through both jacks? Sorry if the wording is a bit confusing.
Voltage is always the same along a wire or directly connected wires. What might be different is current: in your case the current going into the A0 pin will be ridiculously small compared to the one flowing into the Arduino power connector.
mananp:
Yes, I realized just today that voltage division might be the perfect thing.
Far from being perfect, but still very simple to implement. The biggest drawback of the voltage divider solution is the current which flows into the two resistors which will contribute to drain energy out of your battery.
mananp:
A couple questions of about that:Does it matter what value of resistor I use? I mean if according to the formula, if R1 and R2 are equal, the voltage will divide by 2. Is it any safer to lets say use a 10k resistor compared to a 1k?
Bigger resistors mean less current drawn from the battery. Smaller resistors mean less ripple in your readings. You should find a compromise between the two. Both 10k and 1k are decent values: don't go less than 100 Ohm though or you will damage your Arduino analog pin! Two resistors 100 Ohm each mean an equivalent resistance of 200 Ohm: with a fully charged 2 cells li-ion or li-poly battery you have 8.4V (I was wrong and that was the right voltage) which means 42mA which is already above the maximum rating of 40mA per pin!
mananp:
Also, in your drawing, what is that thing in between the two resistors? Is that voltage dividor? I thought that voltage division was just a principle and that if i used a wire between the two resistors, the wire would carry the voltage thats been divided into whatever?
If you refer to the little blue thing that's a capacitor: it's goal is to reduce the ripple in your readings providing a small charge buffer. It's not critical and it is a small ceramic capacitor: anything between 100pF and 1nF would do.
You call "voltage divider" the two resistor in series and the wire between those two: whatever is attached there will be at a voltage equal to the initial voltage multiplied by (R1/R1+R2), in our example (10k/20k) which is one half.
Please note that batteries do not discharge linearly: at 100% they will have 8.4V, at 90% probably down to 7.4V, at 50% may be at 7.2V, at 20% may be 7.0V and at 0% at 6.2V...
Have a look at the image: the curve rally depends on the battery type (li-ion, li-poly) and manufacturer and remember you are talking about a 2 cells battery.
rlogiacco:
That link return 403 FORBIDDEN error: I believe you must be logged in to see it.
I believe that he mean this one
I solved this concern when I attached a 7.2V LIPO to my LC meter project...
For reference: LC Meter – Working… | pwillard.com
I incorporated a Kingmax 500mA 7.2V Lipo with the Polulu power switch to power my portable bench meter. Adding a resistor divider network in front of the Analog input pin I was able to measure battery voltage. When it gets too low, the Arduino will send a shutdown command to the Polulu switch.
Using lower resistance in the voltage divider will -not- damage an analog input, because that current is not flowing through the analog input.
Perhaps you meant that lower resistances provide less -protection- of the analog input in case of malfunction. That is true.
polymorph:
Using lower resistance in the voltage divider will -not- damage an analog input, because that current is not flowing through the analog input.Perhaps you meant that lower resistances provide less -protection- of the analog input in case of malfunction. That is true.
Yup, that is what I meant. For my purposes, I will be using this (10k-10k divider): http://www.vishaypg.com/docs/63045/30014445.pdf
polymorph:
Using lower resistance in the voltage divider will -not- damage an analog input, because that current is not flowing through the analog input.Perhaps you meant that lower resistances provide less -protection- of the analog input in case of malfunction. That is true.
Doh! By bad again!
What I was trying to do was to warn mananp about the current limitations of the Arduino (actually the Atmega328 MCU), but I definitely messed that up: thanks for the correction, I didn't mean to introduce confusion.