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.

Hi Welcome to the Eev blog an Electronics Engineering video blog of interest to anyone involved in electronics design. I'm your host Dave Jones Hi I've been working on a project that's uh, powered from a couple of well, two uh, lithium ion cells in series and I thought I'd add like a little uh battery gauge type thing to it, just a little LED bar graph or something you know that shows the level of how much uh battery life is left in the product and there's quite a few ways to do this. But anyway I thought I'd build something up and uh, try and get something working so it's breadboard time. Now as I said, there's a couple of ways to do this.

Uh, one is to go real high tech and modern. use one of these uh, battery gauge ic's um, they're basically uh, they basically measure the charge going into the battery and the charge coming out and you can read them out with. you know, they got adcs in them and a little uh, memory and micro and stuff. You can read the data out via serial bus to a micro and all that sort of stuff and it's all pretty fancy.

and well, I don't need something that fancy I just need a simple basic bar graph that you know when the battery is full, when it's fully charged because this will be rechargeable, right? So as the thing charges up, the bar graph goes up and when it gets to full, it shows that it's full. When you're using the product, the bar graph will start out at full and it'll drop down to zero and maybe 10 leads a do you know, one of those little uh 10 Led bar graph modules you can get for 50. They're very cheap, readily available. use something like that now.

I could use a micro controller to do this. You know it's got an ADC builtin, a little pick, or an AVR or something. Uh, but that's you know that's the obvious uh solution these days. Just put a micro in it I don't want that I thought I'd go a bit old school and it bought back memories.

Well how do I drive a little 10 Led Bar Graph of course, course the Lm3914 Absolute Classic IC It's been around for decades and decades. I used it extensively when I was a kid. It's a little uh, special purpose analog chip from our National Semiconductor who's now been bought out by TI Bloody hell, go figure. Anyway, uh, Lm3914 classy chip.

It's right up there with, like the triple 5 timer in my opinion in terms of nostalgia and just one of those special purpose chips that just does its job really quite well. So I thought I'd Uh, get out my old Parts pin, get an Lm3914 and prototype it up. Let's give it a go now. of course we can't just jump into breadboarding something without knowing our specs.

Now for this project, I'm going to be using two um, uh, standard uh, 18650 lithium ion uh cells you're probably familiar with these they used in a ton of stuff these days. not only to make up uh, bigger packs, but individually as as well. And uh, by the way, um, as it says down here, uh, this is a Panasonic data sheet. Okay, I've just you know, a good brand, one a good uh data sheet I Almost certainly won't end up using a Panasonic battery, but they're all going to be uh, similar characteristics.
So I'm just using this as a representative example. Now there's a safety note down here. I'll just mention uh, basically, uh, Panasonic will not sell the individual cells because they're unprotected. And as I've mentioned before, we've talked about lithium ions cells.

They can be dangerous, so you should only use the lithium ion cells that are integrated with the appropriate safety circuitry built in. So um, there probably the majority of ones you can buy on the market. but make sure you get the ones with the protection. Surfer You'll have a little PCB in there and so it'll be slightly longer and it will have a PCB in there that actually protects the battery and stops.

Um, overcharge and over discharge. And and and you know, a safety Factor Stop them exploding Anyway, Uh, that doesn't change any characteristics. that's just a side thing. Now we will look at the Uh characteristic discharge curves of this battery and see what we need in terms of specs for a battery level gauge and you may recognize this: This is the characteristic discharge curve of in this case, the 18650 uh lithium ion cell, which we're looking at here now because my project actually doesn't use one cell.

It uses two cells. uh, in series or A or a battery pack. Uh, the voltage on the y axis. Here, this is only for one cell.

So um, if we're talking say in terms of 4 volts. we have to double that for all of our calculations and all of our thinking, uh, because we've got a battery pack of two cells and if we, if it's 3 volts, we'll be talking in terms of 6vs. Uh, so you should be familiar with this. We talked about it in previous Uh blogs.

It's a standard characteristic discharge curve of the cell voltage versus time. In this case, they actually call call it the discharge capacity. They've done an extra calculation, but it's effectively uh, time. Here, we don't have to worry about the Milli capacity.

really. Now they've got three characteristic Uh curves here for different load currents. In this case, it's constant Uh current and they're assuming a 3v uh, cut off. Which is there it is.

It's 3 Vol So uh, pretty much you're only using the capacity between, say there and there. So you're not using all of the capacity of the battery, but you're using most of it and that's good enough. So my product will have a battery. uh, cut off or a battery low voltage I'll call it 3 volts.

or because I'm using two, it'll be 6 volts. So we know that we want a uh, let's call it uh V low equal to 6 Vols Okay, that'll be our low voltage for our bar graph and uh, and of course this is a 4.2 Vol lithium ion um cell. It uh has a constant Um voltage, constant current um constant voltage, charge, current, charge voltage of 4.2 volt. So when you, uh, disconnect it, it's going to start out at 4.2 So we need a V high.
Let's call it of 8.4 or Vols or 2 times that. So we've determined uh, what our upper and lower threshold voltages of our bar graph will be. So if we've got our bar graph like this that goes all the way down and you've got 10 LEDs like that, then this one will represent. You know, a maximum of 8.4 and that one will represent a low of 6 Vols like that Now, uh, the if you really want to be accurate with a bar graph uh, lead battery gauge like this, then you should take into account the fact that this curve is not perfectly linear.

It doesn't just go straight down like that, but as you can see see, it's not too far off. Um, it's It's uh, more linear when you get to the higher current levels. In this case, uh uh. 4.3 amps.

but at Uh 2 amps which is basically 1 C. Um, it. You know it tapers off at the end here. so you've got some gross nonlinearity at the end of the curve.

But really, that's good enough for my purposes. I'm not going to fuss over that. I Don't want some intelligent, uh control, you know, microcontroller? uh thing. that sort of, you know, compensates for the graph and all that sort of stuff.

It's good enough. It's fairly linear, you know, it's not too bad at all, and you can just mentally, uh, know that when it gets down the bottom, it's a bit nonlinear, so that's okay. But as the product's being used, you will see the bar graph drop down like that and that's good enough so we have our upper and lower threshold voltages. Excellent! Let's go design a circuit and here we go: The data sheet for the Classic Lm3914 and wow, this brings back some memories.

It really does. as a kid a a classic project you do is using an LM 391 Ford as a, you know, a audio level meter or something. Uh, this is actually a linear version. You can actually get a logarithmic version specifically.

uh for audio uh, V meters and things like that. but it's a very versatile device that can be used a lot more than just a it's bar display driver. So um, basically it can actually uh, be a dual mode, a bar or a dot display mode which is great. You can choose which one in the case of this particular project because it's battery powered.

You might use the Uh dot mode because you don't want um, the all of the leads lit up uh on your bar graph because that might chew extra power. and really, it doesn't give you any more um information. It's just visually a bit nicer. the uh bar graph.

So it's great that we've got that Choice There it can uh, operate um leads LCDs vacuum tubes. Um, it's expandable to more than uh 10. It's a 10 uh digit um or a 10 Led bar graph uh driver. It's got an internal reference voltage which we'll make use of.

Um, it operates down to single supplies of 3 volts up to up to about 15 volts I Think it is so up to quite high voltages so it'll operate directly from the battery pack we're uh, we're going to use and um, the inputs operate down to ground and you can and it's got programmable LED current so you don't actually need any dropper resistors in this thing. It's great. You actually save uh, component count with this thing. You can program it from 2 milliamps up to 30.
Fantastic! We'll use uh 2 milliamps down around that level today because uh we want you know this is a this takes power from the battery so we you know we don't want to waste too much power. so we want our LEDs We don't want to operate them at 30 milliamps. That's crazy. We'll operate them down at 2 or 3 milliamps or so.

Um, it can withstand overloads. All sorts of things. anyway. I Love this chip and uh, we're going to use it.

It's simple. Um, well, it's not that simple actually. Uh, you've got to tweak it a bit as we'll uh, no doubt. uh, find out.

but it's a very versatile chip. I Highly recommend you. Uh, check it out if you're after a um, an LED bar graph of some form. Now here's the chipping.

It's uh, standard configuration of a 0 to 5V uh. bar graph Me: now. um, this is we don't want this. Okay, cuz we want to, uh, have our range.

You remember, we said we would have a range from Uh 6 volts to Uh 8.4 Vols So that is what's called an expanded scale Because you're not going from zero to 5. you're actually expanding the scale I I I Know you're actually shortening it. It's actually the span is actually lower than, say, a typical 0 to 5. But you're expanding because you're expanding above the ground reference level, which is the uh, basic configuration of this thing.

Now they will have an application circuit for the expanded scale meter. Let's take a look at that. and here's the application circuit for the expanded scale meter in dot or bar mode. So there's actually a single uh pin switch on here, which you actually can select between Dot and B mod.

It's really quite easy. Don't worry about this. um AC Transformer and rectifier up here that's got nothing to do with it. Then they tell you that down here, it's just to show that it needs no hardly any filtering at all and the thing still works.

But basically, our expanded scale meter, we can get away with just a couple of resistors down here. Now they're showing a couple of uh trim pots down here to sort of, you know, get in there and tweak the thing. but I don't want to do that? We we want to learn a bit more about this chip and how it works, uh, internally and see if we can actually calculate uh, the values instead of just um, throwing in some pots and just tweaking it until we get our upper and lower voltage threshold s that we need. And here's some more info on uh, a greatly expanded scale bar mode only they're talking about.

Look at all this, you know that looks that looks quite messy I Don't like there's the two trim pots in there, but there's other little uh, stopper resistors. There's another one here. Ah, it's all a bit messy I Don't like it. We're going to find a simpler solution than that and at the same time try and understand how this chip Works internally.
Now here's the Uh internal block diagram of the device and it does look uh, pretty simple, but it's actually a bit more advanced than this. This is quite a uh, simplified Um block diagram, but it'll It's uh, quite functional and allows us to, uh, work out what's going on here. Now as you'll see, this is our voltage. uh, signal input as they call it.

It's got a diode clamp here for over voltage and stuff like that. It's got a buffer and it just drives a bunch of comparators um which are driven by this resistor. This an internal resistor ladder here. each one of these resistors is one K and it gives you a typical Uh value.

Further on Um in the Uh specs for the device and they drive the LEDs over here. so it's a very basic Um, very basic, just a window comparator, um or a bar graph uh DOT comparator type thing and it's got an internal voltage reference which will take a look at Um It's Got The Power Pin ground pin and not much else. just the upper and lower threshold voltages which go directly across Um, the Um directly across the divider resistors here, which determine the individual voltage thresholds for each of those comparators and then in turn each of those LEDs. It's very basic, Uh.

stuff. You can build up uh, something like this just using um, just using a bunch of comparators yourself and and the resistors and things like that. but it's all built on one chip. It's beautiful.

Now one of the keys here is this: uh, internal voltage reference source of 1.25 volts. Now one of the important things to note about this is that uh, it is not ground reference internally. it goes out to a separate pin which they call ref adjust um Which in the basic application it is showing that it's actually grounded here, but you don't have to ground it, you can actually offset that by a certain voltage. um, if you like um and you can do various uh things with it.

And likewise, the lower uh, the lower what they call R low. Here the pin R low is not tied to ground, but in the standard circuit it is Um, it is tied to ground. So the basic voltage range is from0 volts upwards like that at each tap, so you know if it's 0 to 5 volts, it might be 0, half a volt, 1, etc etc. But because that pin is effectively floating as so as this voltage reference, it's quite versatile TI in what you can do with it and allows you to do um, expanded scale displays by offsetting various voltages which is what we're going to do here today and they've been very clever with this device as well.

This resistor, which is the uh load uh for the voltage reference here, actually determines the LED brightness. so it's sort of um, that's it's quite clever, but can actually be a pain in the butt because then that um uh interacts with your uh voltage offset uh, uh, voltage offset resistors as you'll see and things like that. But um, it is quite clever I like it So that resistor effectively or or the load on there on the voltage reference effectively determines the LED brightness and that'll be based on a formula, which we'll find it further on in the data sheet. Now they've got a nice little section here on the internal voltage reference and how it works.
and uh, it's it basically works. The voltage reference is internal like that V positive negative. It's inside like that and it always generates 1.25 Uh volts pretty much regardless of how you've got it configured externally. But uh, it will generate 1.25 Vols So uh, if you hook, um, let's call them well, they're called R1 and R2 here and that's what we'll call them in our circuit as well.

Don't worry about it now, we'll go into it, uh, later. but uh, that will generate 1.25 volts across that resistor there if you've got it wired. if R1's wide directly across those pins so that you can use Ohms law 1.25 Vols / R1 generates a current which goes down there and hence flows into here. but there is also a Um and what they call call an error term.

There's a leakage current for the Um for the Uh voltage reference itself and that will be an additional current there and they call it I adjust. So that means this current here. the total current I through here will be equal to I1 plus I adjust like that and uh, that's quite important. We might have to take that into account later when we build up our circuit, right.

So let's start designing this thing and see what we can come up with. Now as we uh, determined before, we basically want our voltage reference range for our window. Uh, here we looked at before we wanted 8.4 Vols up here. So this um R uh High pin which they call it uh needs to be at 8.4 Vols and we wanted Uh 6 Vols down here on our R low pin.

If you do the math, if you subtract 8.4 Vols from 6.4 Vols what do you get? you get 2.4 volts. Okay, now what happens if if you divide that by two? what do you get I'm glad you asked. you get 1.2 Vols Now 1.2 Vols is pretty darn close to the 1.25 volt voltage reference here. so I think we can use that? We can be clever and just use that as our Uh voltage range for here.

So all we need to do is multiply that by two to give us our range on these our voltage range on these two pins. So we need a circuit external to here that sets these two pins at um, basically half these values or for a single cell. Uh, we need to be 4.2 Vols on this particular pin and we need to be down here. We need to be 3 volts on this pin down here and then and in in our signal.

Here we can actually our input. We can use a voltage divider. Let's say that's 10K and that one's 10K as well our input signal if we connect that to our plus V battery. if we connect it.
oh sorry, that was off the screen. If we connect it down to our V battery down here, we can use a voltage divider to, uh, chop the battery voltage in half. Now this I think is important because these inputs here to this chip won't go all the way to the voltage rail. Now this is our voltage here and if we connect this to plus the bat as well cuz we want to power this entire circuit from the battery under test, we don't want to have to, you know, power it from a separate Supply That's just silly.

So um, these inputs won't operate all the way right up to this Uh level of the battery. So, but if we have the battery voltage with the voltage divider here, we have it. then uh, it should be with within the workable range of the comparators and the rest of the circuitry inside. And if you have that as we said up here, it's we want a range of 1.2 Vols over which our LEDs light up or 1.25 is near enough for my purposes.

So um, ideally all we want to do is connect the Um voltage reference directly onto these pins here. and if we did that if we actually, uh, did it as per the circuit that's shown here, if we grounded this grounded this and this connects to the VF output there, then this would. The chip is designed to work over a range of 0 to 1.25 Vol. So these LEDs will light up at zero.

Um, you know the first Led will light up and then all the way up to 1.25 Vol. That's a standard circuit, but as we've mentioned before, we want an expanded scale one. so we have to off offset this pin. Here, we have to offset our low by the minimum range we want.

So we have to add 3 volts to this pin down here. and that's what we need to accomplish somehow externally to here. So how do we do that? Well, I'm glad you ask. First of all, let's get rid of that ground point there.

We don't want that. Let's just get rid of that resistor because it's in the way. We'll replace it with our own resistor and let's draw in another resistor here. We want a resistor there and let's tie it onto the ref adjust pin.

We'll call that R1 and we want another resistor down here which will call R2 and we will ground that now. Uh, this R low down here. We want to get rid of that ground and we want to connect our low up here to the bottom of that because we know our range is 1.25 Vols or exactly the same as this voltage reference and we can leave this also connected up to here. Okay, so our R high up here is connected to the positive side of the voltage reference.

Uh R Low down here is connected to the negative side of the voltage reference and all we want to do is choose these resistors so that we get 3 volts, superimpose 3 volts across there and that will raise our voltage up by the 3 volts we need. Easy. And if you remember this circuit over here, there's actually a formula for the Uh LED current. Now this is something we need to consider up front and it'll become obviously obvious why.
Now the formula is uh, the LED current is approximately equal to 12.5 on R1. So R1 We need to be um, basically uh, 12.5 divided by our lead current. Uh, which in this case I said I'd like about 2 milliamps. I'd like to be as as low as possible so it doesn't draw excess current from my battery.

So 12.5 Ided by 2 milliamps. You whack that into the calculator 12.5 / 2 milliamps and you get roughly uh 6,250 ohms and You can see the realization of that formula on this Uh characteristic curve here of lead current versus the reference Uh load current. And and if you uh, have a reference loow current of 1 milliamp, you get an LED current of there it is 12.5 So that's where that factor of 12.5 comes from. and it's fairly linear.

not absolutely perfect, but uh, close enough. So so we're actually going to have a current through Um R through R1 of 1.25 volts, which is our voltage reference on our 6,250 Ohms, which is equal to Uh 200 m microamps. And if you have a look at the Uh, translate that to the graph over here. Of course it all works out.

So all the math is nice. It all works out. and 200 microamps? this is up 500 microamps here. So 200 just puts us on the bottom of that Uh curve there, which is around about the 2 mamp figure that we want.

The curve doesn't actually extend that far, but it's near enough. So there you go. It all works out. So over here.

we want a current there there of 200 microamps which will give us our Um LED current of you know, uh, near enough to Uh 2 Milliamps. Basically, that's our Target but R1 here curiously right, which we calculated the figure here of 6,250 Ohms. That's great if nothing else was attached, but what do we have here? Check it out. Look up here we have this resistor divider Network directly in parallel with R1.

We've got these resistors in here we have to take into account so we have to add these in parallel with our Um wealth in parallel with R1. We haven't actually calculated the true value of R1 yet. We want R1 Sure, we want R1 to be 6,250 but we're not going to use a 6.25k resistor in there because we've got all these other resistors in parallel. So we need to calculate the true value of R1 Uh, when you include these ones in parallel.

So we need to find a Target value of R1 here for that 6,250 ohms which we calculated before. but based on uh, this resistor, this resistor divider here in parallel. So we need to know what value of R1 will give us the total resistance of 6,250 ohms here. and I've done it down here.

If you look at your standard uh parallel resistor formula R total equal 1 1 R1 + 1 / R2 that gives you total parallel resistance. But we need to find we know what value we want. We want, um, 6,250 ohms as a total. So we've got an unknown term in here.
Uh, one of these terms is unknown and we know the other one which is the resistor divider. So we just, uh, sort of rewrite that formula. so we're trying to calculate R1 here, which is our value. Uh, and if you rearrange The formula.

you'll actually get um one on Uh R1 which we calculated which is the 6,250 uh, ohms minus instead of plus, it's now minus one on, um, the voltage, the resistance divider, the value of the resistor divider. and if you plug the numbers into the formula, it's one on one on 6,250 - 1 on 12K. Where did we get 12K from I Hear you ask? Well, if if you look at the Uh resistor ladder up here, there's only 10. There's only 10 resistors there, and they're all marked 1K So you might think it might be 12K but I don't know.

You got to double check these things. Don't go by those block diagrams. only go by the true electrical characteristics. And sure enough, if you look elsewhere in the data sheet.

um, the voltage divider. there it is. The divider resistance total of pin 6 to pin 4 is a typical value of 12K. so it's 10K as you'd get from the block diagram.

just be careful of that sort of thing. It can range anywhere from 8 to 17, but is it 12? I Don't know. Let's plug Uh 12K into our formula and try it out. I Don't think it's going to be up near the maximum.

It might be down near the minimum. Um, there's quite a large upside there on that, but we'll take a value of 12K which is what we've done here. Plug that in and R1 is just over 13k. There it is.

So we want to use a 13.04 K 13 k04 there for R1 doesn't need to be that precise. Why? Because it's only for the lead dropper resistor. That's it's. basically this resistor here is only calculating the lead Uh current so it's not that vital really.

Now we have a value of the resistor we can use for R1 Our current down here hasn't changed. Uh, we calculated that four at 200 microamp cuz it's 13k in parallel with uh, the resistor divider 6,250 ohms. Uh, divided by 1 1.25 Vols divided by 6,250 ohms is 200 microamps. So we know we've got 200 microamps flowing down R1 And this is where we need to now calculate R2 which actually increases um, our ex.

Well, it generates our voltage drop across it to raise up our low input voltage and create to 3 volts and create our expanded scale voltmeter. So we need to calculate R2 for a 3vt drop based on current down here. But it's not just 200 microamps. Remember before, it's 200 microamps plus the error term here and there you go.

If you remember, back to this diagram here. We talked about that R1 and we talked about that error term uh being the Uh leakage Uh current of the Um voltage reference itself. So we need to find that value in the data sheet to find out what this value actually is. And if you have a look here, it actually tells you since the 120 microamp current maximum from the adjust terminal.
Well that's it Once again, don't take any of this application stuff for granted. Go over to your Um Electrical characteristics table cuz this is the only one that matters. So if you look for our voltage reference here, we can find out there it is adjust pin current. There it is is 75 microamps typical and sure enough it is.

they were correct. It is 120 microamps maximum so they weren lying over there like they were with the resistor divider up here. Um, so we'll take us typical value. We'll take the typical value CU I Don't think it will be near to the Um upper maximum.

it could be uh, if you want to design worst case as we've explained in previous blogs, you might have you might use the maximum, but I'm going to use the typical value and see what we get to see how far it is out. So we will take this 70 that as I adjust equals 75 microamps. So the total going down here through R2 is 200 microamps plus 75 microamps or 275 microamps total. So if we now calculate R2 here, R2 is very simple.

It's going to be our offset voltage we want on this pin of 3 Vols Okay cuz it's connected through there 3 Vols Divid Ohms Law 275 microamps Total current flowing through there gives us a value of 2,99 Ohms Bingo We now have our two values there and there for our circuit. So if we build up the circuit, hopefully we should get a working uh, expanded scale voltmeter that operates from 3 volts up to 4.2 Vol threshold voltage. But because we've got the voltage Divid down here, it'll be from a 6V battery up to 8.4 Vol Let's build it up and try it. And here's our final circuit, which we're going to build up on the breadboard using the Lm3914 It's a two Cell lithium ion battery gauge.

Will it work? Let's try it. And uh, here's R1 and R2 which we spent so much time around calculating and we came out with around about 13k for R1 which will give us roughly Uh 2 2 milliamps or so per LED and R2 was uh, 10.91 K or 10.99 And it just so happens that that's exactly Um, you can make that up precisely using a 12K and a 120k in parallel. So that's what I've built up here. and uh, our input voltage divider here to 10ks.

They can be, um, pretty much any, um, odd value you like. 10K is not a bad value. It's all powered. You'll notice the whole thing is powered from the battery under test.

So here it is Taada. Let's see if it works all right. What we've got here is we've got the Fluke 87 measuring the input voltage here. which uh, it would come from our battery, but in this case it's coming from a variable bench power supply.

I've got my 10 LEDs buil uh uh lined up here. They should actually light up in this direction. So this is the uh, low, um end of the voltage range. This is the high end.

So so we expect this one to turn on at around about Uh 6 Vol and this one up here to uh, turn on at around about 8.4 I've got a bypass uh cap as well, which we, uh, didn't talk about I've got a it's just a half microfarad uh, bypass capping. there anything will do fine. You'll notice that it doesn't need the lead dropper resistors. really.
uh, nice uh aspect to this. So um, there's my two input divider resistors. Uh, there's my 13k there and there's my um, uh, 10K uh, 909 there and well, let's give it a go. Let's wind up the wick.

So the Um power supply shows the exact uh battery voltage. Let's see what happens. Of course, it's not designed to operate this low. Oh, look, they're they're all coming on.

There you go. There's a weird side effect, which uh, you wouldn't know about unless you actually built this up and breadboarded at a very at a 2v uh battery battery voltage. They're all going to light up. so you may actually think that's an error.

That's actually an error condition because um, it shows that you've got full battery voltage. but you've only got two volts. It's crazy, but uh, you, um, your circuit should have cut out under that, so it's not a big deal. but there you go.

That's just an interesting little side fact. It's designed to work from 3 volts onwards the chip so it looks like it is. No problems at all. Let's wind up the wick and we shouldn't see any LEDs on at all until that 6V Mark which is our battery low? Here we go.

Oops, we're on what we smack on six Vol volts. It hasn't lit up yet. Obviously, we got a bit of oh, there we go. 6.06 volts Bingo And then as you go, you can wind up the wick like that and it looks like it's doing a pretty good job.

We should get around 8 point, just it should turn on about 8.2 It does. There you go. So the Bingo it works. I'm actually quite, uh, surprised that.

um, well, not surprised. We did the calculations, but uh, I expected some error in there with the error. uh, adjust term. we'll have to measure that so I didn't expect it to be uh, spot on, but it is.

It's pretty darn close. I'm I'm happy with that. I wouldn't have to tweak those values at all. I'm I'm quite impressed with that and let's wind the voltage up even more just to check that it still works and it should work up to Uh 15 volts as the maximum operating voltage of this chip.

So just make sure it work works Up to that, We won't take it any further and I like it. It's a winner now. of course that was set to bar graph display mode which actually is going to draw a lot of current. If all those LEDs are on, it'll draw at least Uh 2 milliamp per LED plus the quiescent uh current the operating current of the chip.

So uh, let's convert that to Bar mode, uh to dot mode. To do that, you just leave uh pin 9 down there floating. So we'll leave it floating and let's check that. Um.

dot mode works as well. it's just over 6. Vols There we go. Bang, it's on and Bingo dot mode works.

It's nice now. One of the nice features of the LM 3194 is that it doesn't have any dead spots. You'll notice there is no way that I can make I can make both leads on, but I can't get an error condition where no LED will come on. So where the voltage threshold is Right Between the LEDs because it's got um, the data sheet I think claims a one M volt Uh, threshold between or overlap between the LEDs.
So 1 molt overlap means that you will never get an error condition where an LED is not actually switched on. So dot mode you you can trust that you're not going to have any dead spots within there that's built into the design of the Lm3914 and you'll notice it's just it. Beautifully toggles. You know you might have two leads lit up, but that's just fine because you've got noise on there and bingo it's there you go.

8.3 and Dot mode works just great and once again, we can take it up to 15. no problems at all. I Declare that to be a winner both Dot and bar mode and of course, if there's no LEDs on, you know it's 6 Vols All right, let's check our lead current. So we expected around about 2 milliamp, but it wouldn't surprise me if um, it's uh, not.

You know if it's over or under that because uh, that's determined by that 13k resistor which we had in this circuit which remember, is dependent upon that very wide variable range of the resistor divider inside the chip. So let's wind it up to 6 Vols till our lead turns on Bingo It does does uh, 2.8 milliamps. There you go. Um, it's a bit over, so it's not exactly the 2 milliamps we expected, so you could actually tweak that uh 13k value there if you wanted to.

Um, just to adjust the uh LED current that you wanted. But as you can see, um, that Led is still uh, reasonably bright enough. Um, even at 2 milliamps and these are 20y old LEDs I Just had in my junk bin. So if you use a modern, uh, high efficiency LED bar graph, they should be more than bright enough at 2.8 milliamps.

So I'm happy with that. I don't need to tweak that at all. And what's the quiescent current of our circuit? Well, um, I've just under five, uh, six? Vols there, so no LEDs are on. It's around about 5 milliamps or so and if we wind it down, you'll notice that uh yeah, no problems.

So that's um, so it's going to consume at least 5 milliamps and when you switching LED on, let go up to 6 Vols get one on There we go. Bingo, It jumps up to Uh 8 milliamps and it doesn't matter. it's going to take around about 8 and2 milliamps maximum. Regardless of um, which Led, you'll notice that it is slowly actually increasing um as we go up in dot mode.

So there you go. it looks like up to 9 milliamps maximum I would um I'd safely say round that to about 10 milliamps maximum current draw in dot mode and in bar graph mode. Of course, it's going to take uh, considerably more than that. There we go.

all the LEDs lit up and 35 milliamp. So as you can see, you pay a fairly Hefty uh price premium there for uh using the uh bar display mode. And if this is, uh, measuring the consumption of your battery, um, then you know if you're only uh, drawing low currents from your battery and 35 milliamps could be quite significant. But if you're drawing, you know, if if your product draws a couple of amps or something like that, then you may not worry about that.
And you may like the Um effect of the bar graph display mode and checking our reference voltage, there is 1.246 Vols pretty close to the nominal 1.25 Vols claimed. And if you remember this error term here of 75 microamps that we included in our calculation for the offset voltage here, how accurate is that? Because you remember it was a nominal value of 75 microamps, could it could have been a maximum of 120 microamps? Well, let's measure the thing there it is I've uh, broken pin, uh, eight there. so I've and I'm actually using my microcurrent adapter here just so that, uh, the meter doesn't introduce, um, anything funny And there it is. uh, 56.5 microamps so it's lower.

So technically our calculations would be slightly out there. Um, because we assume 75 microamps, but well, it's 56.5 microamps for this particular chip at this this current temperature. How about we change the chip and see if it makes a difference? There you go: I Actually changed the chip. It's exactly the same uh, batch and uh date code.

So I sorry I didn't have any uh, different ones um in my set. but there you go, it's almost the same. It's only out by half a microamp and if you're interested in uh, what type of Chip I'm it is a genuine National as well. I'm not aware of Second Source uh ones for this, but uh, you? you probably can get gray Market ones or there possibly is Second Source somewhere I Don't know, but uh, it's um, 1990 vintage.

There you go the 52nd week in uh, 1990. So this is over 20 years old, but you'll notice of course that this uh new chip doesn't hasn't switched on at 6 Vols like the other one did. So there you go. it's it's You know the tolerances are slightly different because each chip so is going to be slightly different in terms of Uh temperature.

Co Proficient absolute accuracy of the internal 1.25 volt voltage reference and other stuff. So really, you know? Um, that's why they have the Uh trim pots in the circuit because ultimately you may have to uh, trim this thing if you want to get accurate. but I I reckon you could you know for a rough battery gauge for Um for for my application anyway I think um I'm not going to worry about with the Uh trim pods I think I can get reasonably close with the fixed value resistors I'm not going to fuss over whether it's you know it's 6.1 or 6.0 Vols it's near enough and if you're really key in the data sheet, does uh mention in the application notes area ways to uh, keep your resistor values low so that the Uh temperature coefficient effects of the internal divider and things like that don't uh, swamp your values and and stuff like that. So you know if you're doing really serious critical design with an Lm3914, you've got to take that sort of stuff into account, especially over the Uh temperature range now.
I've adjusted my input voltage so that first Led is just switched on fully and I'm using my microcurrent to measure that um, uh reference Uh current leakage value. But let's try it without the Uh microcurrent meter and see what happens. We use the Uh shunt inside the meter itself so we won't change anything. We'll just switch over to current mode here so we're no longer using the microcurrent, we're using the internal shunt in that meter and look: the LED It's the same 56 microamps.

The reading's exactly the same, but this shunt the uh higher value shunt resistor inside the meter. The burden voltage is slightly higher than what the microcurrent is, so it's caused that Led to turn off and if we switch it back to our microcurrent like that Bingo it switches on. see So if we go like that and that is a demonstration of Burden voltage in action. and if you in.

granted it's not that critical in a case like this, but if you got some serious circuitry you're trying to measure that can ruin your day now just as a bit of a little aside here, a little uh, tip for you: when you're breadboarding stuff: beware of using resistor, just pulling resistors straight off these uh, bandier things and putting them straight into your breadboard. It can be a real pain in the neck and I'll show you why Watch this. If you pull one of them out like that, you can end up with a whole bunch of glue on stuck on the end of your PIN So if you've got that glue stuck on the end of your PIN like that and then you just go try and uh, shove it into your bread. P You can end up with a bad contact or no contact at all and that can really ruin your day.

Uh, especially if you're trying to put two resistors in parallel. like like you're trying to twst weaker value or something. If you put two of them in parallel and one's not making contact and it happens to be the higher value one, then uh, you're lower value, one could be slightly out and H can ruin your day. trust me.

So it's actually, uh, sometimes beneficial to actually put resistors in series cuz then you'll have a gross failure because you know that the single resistor has failed anyway. The way to cure that is simple. when you peel them off the bandal ear, just make sure you snip off the end piece of cake. So there you go.

That's a nice little practical two. Cell Lithium ion Battery gauge I Like it. it works quite well. we measured its performance, does pretty much exactly what I want.

Spot on beautiful, but uh, and it is uh, adjustable for um, other uh, types of battery chemistry, not just lithium ion. You can adjust it. You can do all sorts of things with the Lm3914 I Love it! It's a great chip. It's very flexible.
Someone should do a contest for it. but if you want to adjust the circuit for other uh, battery chemistry, other voltages, different number of cells, you can. Not a problem, just follow through the steps we went through to calculate the values. There's different configurations you use.

The one we use is quite simplistic. Uh, because we just so happened to have that 1.25 Volt range is exactly what we wanted. If you want something lower than that, then R1 in the circuit here. If you've got R1 there, you have to actually, uh, put a voltage divider in there there to get it smaller and then you've got to tweak the voltage divider input and you can do all sorts of things and you can offset and you can ah till the cows come home.

So it's a very flexible circuit, but this implemented quite well. I'm quite happy with it. uses four resistors, one capacitor lm3914 and it works as a complete two Cell lithium ion battery gaug. So there you go I Hope that was fun and useful.

Catch you next time and don't forget to subscribe. There's a button somewhere. Leave comments, whatever. Give it a thumbs up Beauty.


Avatar photo

By YTB

24 thoughts on “Designing a li-ion battery gauge with the lm3914 – eevblog #204”
  1. Avataaar/Circle Created with python_avatars 69 Bronco says:

    I know that it is 11 years on, but this was extremely helpful AND entertaining. Who knew that Randy Feltface was an electronics engineer?

  2. Avataaar/Circle Created with python_avatars matthieu imbert says:

    Hi Dave, nice tutorial as usual, thanks a lot.
    One thing though: you estimate 200uA out of REF OUT pin in order to have 2mA led current. So you need 6250 ohm to fit the formula. But then, total current out of REF OUT pin still is 200uA, but only (say, roughly) 90uA passing through R1=13043 ohm and (say, roughly) 110uA passing through the 12k ohm resistor sum of internal divider.
    Total current flowing through R2 is thus not 275uA, but more likely 165uA (roughly, still).
    Does that make sense?
    Thank you, anyway, very good explanation.
    Regards.
    Matt

  3. Avataaar/Circle Created with python_avatars JohnSmithZen says:

    What is "Exclamation Point" mode for the LM3914?

  4. Avataaar/Circle Created with python_avatars Sid Harth says:

    I really miss these design videos Dave, the power supply series is also great! When'll the next 1 b out?!

  5. Avataaar/Circle Created with python_avatars jstro-hobbytech says:

    I love those old red leds

  6. Avataaar/Circle Created with python_avatars Bart de Boisblanc says:

    I am thinking you could add a push button like they use on a rechargeable drill battery packs to turn on the bar graph.

  7. Avataaar/Circle Created with python_avatars 3D LAYERS says:

    When measuring the 1.25V with your meter, how accurate is the meter as a note? I remember taking that into account when calibrating meters.

  8. Avataaar/Circle Created with python_avatars Brett Kom says:

    Instead of just monitoring voltage level, could you please add a charger circuit? thanks!

  9. Avataaar/Circle Created with python_avatars sam1 am says:

    Hi. first of all i wanted to thank you for this grate circuit and your teach. i noob in electronic and i want to build a circuit with lm3914 to show the range of 4.2 to 3.2 lipo battery. i used this video to build that and it worked in proteus with voltage divider resistors 100ohm and 700ohm but when i build in reality, the range is in 1.5v to 3 volt. can you pls help me to correct this? thanks

  10. Avataaar/Circle Created with python_avatars HanZie82 says:

    Oh man my brain hurts.
    Im trying to figure out the numbers for a 1Cell 18650. But i cant wrap my head around what i need to calculate, so much numbers in the video my number-dyslexia ran away with it. 🙁
    Thanks for this amazing in-depth video tho. I will try again.

  11. Avataaar/Circle Created with python_avatars Hola! Prathamesh Parit says:

    i am going to make it(in my mind first).

  12. Avataaar/Circle Created with python_avatars Karri Koivusalo says:

    I was thinking of using some PIC12f or ATTiny microcontroller for a simple bar graph display, and then found out that these are actually cheaper and easier to use, which is not an usual way of things these days! I knew to look because I had a device which made some clever use of this chip. It was a fuel injector controller for aftermarket turbo applications, late eighties tech. The company had ground off the chip numbers, for extra cost and zero benefit; when I showed the board to a guy who knew his stuff, it was as if he read out the BOM printout. Immediately he recognized the ignition signal F to V conversion part which used an LM555 circuit, then he pointed out the big chip was an LM3914 in dot mode which turned on one of ten PNP at a time which in turn would feed a trimmer resistor adjusted voltage into another LM555 to create a PWM signal for the injector driver FET. He didn't even pause once describing what each component of the circuit did.

  13. Avataaar/Circle Created with python_avatars JohnSmithZen says:

    I cut the resistor legs off while they are still in the bandolier (that way you don't have to look and see where the glue starts).

  14. Avataaar/Circle Created with python_avatars Peter Sage says:

    I remember the LM3914 was already considered "obsolete" and supposed to be out of production before this video was made. Nearly ten years later they're still common as mud and twice as cheap. Guess the second source manufacturers never got the memo.

  15. Avataaar/Circle Created with python_avatars Leo1355 says:

    When the battery voltage was below the cutoff voltage all LEDs were turned on in bar mode: what happens in dot mode?

  16. Avataaar/Circle Created with python_avatars Capposteve says:

    im really struggling to get this to work with a single cell lithium battery. brain frazzled

  17. Avataaar/Circle Created with python_avatars Walter Cristian Eduardo Lasek says:

    Hello Dave!!! I need your help!!!

    Do you have mail contact you?

    Best regards from Argentina!

    You are a genius!

  18. Avataaar/Circle Created with python_avatars Zachary Carbon says:

    I've been trying to extrapolate from this example for Rlo(10V) – Rhi(12V) but am having some trouble. Can anyone recommend resistor values to achieve this exact circuit but for 10V-12V rather than 6V-8.4V ?

  19. Avataaar/Circle Created with python_avatars George Thomas says:

    Any possibility of having several LM3914s to indicate li-ion cells in a 7s configuration ? 1s is ok but how does it work on a 7s ?

  20. Avataaar/Circle Created with python_avatars fsr says:

    Interesting IC. A pity they didn't buffered RHI and RLO, however. Also, taking a look at the block diagram, no led turns on at the RLO voltage, because there is no comparator attached there, so the first led will turn on at Vrlo + (Vrhi – Vrlo) / 10. Quite a mess there. It seems to me like it needs another comparator, or to remove that internal resistor between Rlo and the lowest comparator.

  21. Avataaar/Circle Created with python_avatars zan marinic says:

    Hi Dave. Did the same schematic but for 4×18650 in series. Did the calculation but was not that lucky had to put potenciameters in and fine tune them till a got the right values… but at the end I did it so no worries! tnx great video!

  22. Avataaar/Circle Created with python_avatars Das Partyhut says:

    Or, you could just snip them off rightaway…

  23. Avataaar/Circle Created with python_avatars CrAzYDr1veR says:

    Hi i need to monitor 20 cells using a similar circuit and bar graph, is the lm3914 the simplest way to do it?

  24. Avataaar/Circle Created with python_avatars A Micklich says:

    Cool, practical project!

Leave a Reply

Your email address will not be published. Required fields are marked *