No Script, No Fear, All Opinion
RSS icon Home icon
  • EEVblog #204 – Designing a Li-Ion Battery Gauge with the LM3914

    Posted on September 29th, 2011 EEVblog 34 comments


    How to design, prototype and test a two cell 18650 Lithium Ion battery pack level gauge using the classic LM3914 dot/bargraph display driver chip.
    A favorite from Dave’s youth!
    Dave gives you all you need to know to implement a simple expanded scale voltmeter with the LM3914, without adjustment pots to tweak.
    This one works from 6V to 8.4V – the usable capacity of a two 2 cell 4.2V Li-Ion batttery pack.

    Be Sociable, Share!
    • http://www.electronicaycomputacion.com Guillermo M

      Hi, I’m from Mexico. Recently I found your Blog an it’s very interesting. congratulations. It is nice to “remenber” old circuits I liked to “play” when I was a teen. Do you know (I’m sure) that it’s posible to make an osciloscope with NS3914 and it has good bandwith.
      Do you know these oscillosocope ?http://www.gabotronics.com/development-boards/xmega-xprotolab.htm

      Thaks Dave and if you come to Mexico (I do not for what :) ) let me know.

      My english is not so good but I hope I can comunicate.

    • Zac Bailey

      Maybe this is a stupid question, but why not take a tap off one cell for your signal instead of using a voltage divider to divide the voltage from both? They should keep even charge between them and you could eliminate two resistors from your circuit. Am I missing some fundamental?

      There are battery packs that will allow you to pull current from either one or two of the cells, aren’t there?

      • http://www.eevblog.com EEVblog

        I see several issues with that.
        1) You’ve got to have a battery pack that has the tap.
        2) Unless you switch it off with a DPDT switch along with the circuit power, you will slowly drain that cell and not both when the unit is switched off. I know the input current is low (I forget the figure), but what does it do when you switch the circuit power off?
        3) If for some reason the top cell fails in some way (one will eventually fail), the display is no longer accurate.

        It’s probably possible, but isn’t best practice.

    • http://wardyprojects.blogspot.com Adam Ward

      I laughed when you mentioned the foolishness of using a microcontroller for this kind of thing.

      I immediately though of how a software engineer might do this if he’s new to analog electonics…

      BOM:
      * 1x Arduino Mega (with dedicated 9v battery)
      * 1x 14 bit ADC
      * 1x opto-coupler
      * 2x 74hc595 shift register
      * 10x Super-mega-insane brightness purple LEDs
      * assorted 0.5% tolerance resistors
      * 1x very large oversize project box

      Hehe :D

      • http://www.eevblog.com EEVblog

        LOL, I’ll pay that!

        • Stephen

          As a foolish software engineer new to analog electronics, I really enjoyed this video.

          It’s great to have these videos that walk me through the though process and how the math applies to reality (which is the largest stumbling block I have as I approach analog EE).

          I think the original comment is a bit off-putting, but it does open an opportunity for me to better understand some trade-offs.

          What would be invalid in using a micro if one was already on hand?

          Would it ‘just’ boil-down to making sure that the current and voltage coming from the battery was safely ‘compressed’ into the range of an ADC pin? (and then pushing the display through a shift register / using pins to drive the LEDs)?

          Plus… what’s the down-side, in general, to using the micro if it’s already central to the circuit your constructing and you have free pins. (As an up-side, I can see tailoring my project/program taking advantage of the battery voltage sense to perform ‘shutdown’ or ‘alert’ behavior.)

          Try to keep in mind: I’m not challenging the approach documented in the video… I just want to understand the issues with the micro approach.

          Also, please make more of these project walk-throughs. I want to better understand the pure analog world. The way Dave went through the resistor selection and the data sheet really helped open my mind to things that aren’t very well understood by me.

          Oh: the bypass capacitor… it’s in the project (across the interface to this batt gauge circuit?) to handle transients/noise?

          Thanks for the video and the comments.

          • pete

            The spec calls for an auto powered battery monitor. Since such a monitor is generally not desired for its own sake, the monitor therefore has to consume as little current from the battery it is monitoring. I bet a most micros use more current just to stay on than when Dave’s design is in bar mode.

            Also, what really is the benefit of micro in this application. If it has a 10 bit ADC then it can light up 1024 LEDs for a ridiculous resolution. No, you are just going to end up throwing away most of that resolution so what is the point of using it.

            • http://www.eevblog.com EEVblog

              A micro would use a LOT less quiescent power. In the order of dozens of uA instead of around 5mA.

            • f4eru

              It makes sense of course :

              using the voltage works with a constant (current or power) load.
              usually, for a device that draws mainly peaks, like a cell phone, it’s much harder to measure or calculate the remaining battery energy.

              And for that you need precise measurements of the energy of these peaks, with a big current dynamic (uA for sleep currents, amps for TX peaks). Then you need a precise ADC :)) If you use only a voltage based gauge on a cell phone, you will have some equivalant of the MS windows wait bar ;)))

    • Marcin

      great episode, more of these, now I know how to design electronic equipment
      greetings from Poland

    • Andrew Vuong

      :o looks like I want to try this

    • John

      Thanks for taking us through the design process from beginning to end. I don’t know of any other site doing this and it has been really helpful to me.

    • Jaakko

      Nice video as always! Have to get some LM3914:s for play.

      Resistors & Breadboard:
      Instead of peeling off and cutting one should cut them off straight from the roll saves the trouble of cleaning the floor/bench afterwards.

    • Andy P

      David,

      Exceptional video.

      Are you still selling your μCurrent adapter?

    • http://wardyprojects.blogspot.com Adam Ward

      Stephen:

      Hi there, my comments were made in a light hearted mood, and I am also a beginner myself (I’m technically a Windows/Linux programmer as my full time job). I was merely using my own “trajectory” into electronics as a way to get a cheap laugh about how sometimes people with a certain background would likely make too much work for themselves – instead of an old-hand at electronics that might make the cost effective design from the outset.

      Actually, contrary to my joke, there’s really nothing “wrong” with using a microcontroller to monitor a battery’s capacity. There are certainly many applications where this would be a valid approach, but the thing about a microcontroller is that it’s a complex part. Microcontrollers tend to be used at the centre of a design instead of at the periphery. In a world where the selection of integrated circuits is so rich, chances are that you’ll be able to find a low-cost part that does exactly what you want without resorting to a microcontroller.

      In most cases it’s not cost effective to use a microcontroller when a targeted IC exists. And lets not forget that microcontrollers need firmware – which means paying someone $$$ per hour to write it!

      But that’s thinking commercially – if you’re hobbyist then there absolutely no reason not to use a microcontroller if you have one handy.

      You’ll always learn something by having a go. But that tends to be expensive too, so it’s “horses for courses” – as a certain blogger might put it.

      • http://www.eevblog.com EEVblog

        Yes, it’s always horses for courses.
        Micros can be used for something like this, and there may be many valid reasons, like cost (a suitable micro can be cheap like < $0.50), package size (small SMD packages, compared to DIP18), power consumption (order of magnitude less than LM3914), and offer various other intelligence. But then, yes it has to be programmed (you can order it pre-programmed from the factory if required) and the code written in the first place, and maybe require extra parts anyway (micros don't work at 8.4V).
        In my case, none of that mattered, I don't want to program chips, 5mA consumption is low enough, and I wanted a DIP package. So the LM3914 was a pretty ideal solution.

        The thing with micros is that they are becoming so cheap, they are very temping as a replacement for all sorts of applications that traditionally used dedicated parts, that due to smaller volume, may actually be a more expensive solution.

    • urb anwriter

      Aye, this is what I signed up for. I like a bunch of the ‘other stuff,’ but the walk-through process is intellectually gratifying, and, of all things, useful. Thanks.

    • Hissyfet

      Thanks much again Dave for some fantastic information!

      I’ve been looking at 18650 Li-Ion’s for a project and these seem to be the way to go for future portable designs.

      I really get the point of your tutorial, and although sadly the design will use more current than a micro which say ‘wakes up’ every minute – (my project will use a micro) – your ideas, calculations and design for this are great!

      BTW, I’ve been given a near-new cordless drill
      with blown nicads (no temp monitoring) and
      was going to power this with Li-Po’s but
      the danger factor makes me think it better to get some ‘protected’ 18650 batteries instead.

    • MaxHeadroom

      I used this chip about 15 years ago. Rather than LEDs, outputs where grouped using OR gates to power on different system components depending on the power levels available.

    • http://ultimationee.blogspot.com Andy

      Hey Dave, Awesome video.
      I am wondering, while you had the issue of the LED turning off with that multimeter, did you have the same issue with the fluke?

    • Rasto

      I’ve measured resistor divider directly between pins 4 and 6 and it is 11k4 or 11k6. This could be probably used in formula instead of nominal value.

      this gauge works well on my 2w incadescent light powered by 2li-ion 3.6Ah pack.

      Thanks Dave

    • http://www.kukkuk.dk Benjamin

      Hi Dave

      I really like the “How to design this product” style and the walkthrough nature of it. Please make more videos like this! Ps. i tried to make a 12v car battery monitor for my father in law using the exact same chip but gave up on the resistor divider stuff. Now i see how i should have been done :-)

      Thank you Dave!

      • http://www.kukkuk.dk Benjamin

        Hmm… I’d better spell check prior to clicking Submit Comment next time.

    • Al Martin

      Awesome! This is what I’m talking about! Instructional and fun. Thanks Dave.

    • Pontus

      Was there a spaghetti monster (FSM) in there?
      Anyway, great show, thanks — Pontus

    • Jay

      Thanks, Dave. This was really good. I too would like to see more tutorials like this one.

    • http://None Holger

      Hi Dave –
      Thanks, nice tutorial! I bet you have driven NS / Mouses sale of LM3914 to new heights! :-)

      /holger

    • Pingback: Open 7400 Logic Competition entry: Accelerometer Controlled Racing Game « ssihla

    • Raff

      A bloody ripper tutorial Dave, keep ‘em coming!
      Raff

    • Don

      The LM3914… oh the memories! (circa 1981 for me). Only addition I would make is a momentary switch to keep the circuit powered down until a reading is desired. Beauty Dave!

    • Joe

      Dave,

      Im am trying to use an LM3914 and 10 segment LED display by kingsbright. I loved the video, however, I think Im gonna need your help on this one.

      My Rhi is 9.44 volts and Rlo is 7.75 volts…however, as you mentioned the LM3914 will never get to the highs on my display, so you have to use a voltage divider off of pin 5. If I do that my new voltage ranges are from 4.72 to 3.875 volts for my Rhi and Rlow respectively…This puts it well outside the 1.25 voltage reference source…I was wondering if it would work to put another voltage divider at pin 8 (Reference Adj) so that the voltage measured across pin 7 and pin 8 would only read .0625 volts as well as continueing to use the voltage divider circuit accross pin 5? If this wont work, how the heck do I do this?

      Joe

    • Anand

      Hi…I made this circuit…But I have come across a problem….only my 9th led, led at pin 11 is glowing and none else….do u know what might be the reason
      R1=15K
      R2=10k
      voltage divider resistors= 15K n 5K…tried both
      C= 10 uf

    • vishal chavan

      excellent!!!!!!!!!!!!!

    • Pingback: AVC – Switching from Arduino to mBed | Mostly Robots