Help with 30 LED Expanded Scale Project - Page 1
Forum section: electronics / beginners

author: TheUltraNoob
author_rank: Newbie
timestamp: October 27, 2012, 05:15:39 pm
content: Greetings,I'm trying to take Dave's LM3914 battery meter and expand it to 30 LEDs and am getting nowhere and would really appreciate some help. I need a range of 10.5V - 12.8V and like Dave, power the entire thing from the monitored battery.Building it out with one LM3914 was easy. Adding two more has been... hard. I thought I could string them after the first LM3914 (stop laughing) but that obviously doesn't work.Attached is my schematic.

author: TheUltraNoob
author_rank: Newbie
timestamp: October 27, 2012, 06:59:57 pm
content: I have looked at that. It's powered from a seperate 9V power supply and I need everything powered from the monitored battery. That means it'll mess with the reference voltage?

author: TheUltraNoob
author_rank: Newbie
timestamp: October 27, 2012, 08:19:51 pm
content: #204The schematic is at 31.37. Here is a screen grab.

author: mariush
author_rank: Super Contributor
timestamp: October 27, 2012, 08:55:59 pm
content: I don't know, it seems such a pain and somewhat innacurate way of doing it (you have to split that 10.85 to 12.8 interval into 3 ranges and keep in consideration that each lm chip might not be 100% exact and the resistors and whatever you use have themselves 1-5% error - you might get spots where no leds light up.I'd probably use a PIC or Arduino ... a 2$ chip fed from a 7805 which makes sure your battery or whatever you use won't have some surges and burn the chip - or your lm chips.Use a couple of resistors to divide the voltage by 3 because you want the maximum voltage on the pin to be 5v .. send it to and adc pin and you get the voltage in the picSo the pic will detect this way anything between 0 and 15v as a number between 0 and 1023... and 10.8v would be about 735, 12.8 will be 873 .... the difference is 138.If you divide this by 30 it gives you how many leds you have to light up.... 4.6... let's say 5 and then you have exactly 28 leds. So if the voltage is between 735 and 740 you have one led turned on, between 740 and 745 you turn the second led on and so onYou can use the rest of the pins to multiplex up to 64 leds with just 16 pins.. for 30 leds you'd only need about 12 pins. A 20 pin pic16f would probably be enough.Plenty of multiplexing video tutorials on Youtube just google "multiplex leds"Actually you wouldn't even need to multiplex, you can just get a 3$ 40pin dip PIC and be done with it ... just pwm the leds a bit because the maximum current is 15mA on outputs ...ex:http://uk.farnell.com/microchip/pic16f59-i-p/ic-8bit-flash-mcu-16f59-dip40/dp/9942866

author: SeanB
author_rank: Super Contributor
timestamp: October 27, 2012, 08:57:32 pm
content: I think the appnotes from Natsemi showed how to cascade them for longer displays. That though was in a paper data book, tryhttp://www.ti.com/lit/ds/symlink/lm3914.pdffor help, it explains how to cascade them.

author: TheUltraNoob
author_rank: Newbie
timestamp: October 27, 2012, 09:07:35 pm
content: SeanB - I've almost memorized that data sheet but I'm still to much of a noob to make heads or tails of the cascading part.Mariush - I thought about using a PIC for this little project. It's a little to advanced for me at this point, I think. I had planned on doing this the "hard way" then switching over to a PIC design so I can learn that.

author: SeanB
author_rank: Super Contributor
timestamp: October 28, 2012, 05:20:36 am
content: Look at the TI website for associated appnotes as well, they do show them cascaded as well.

author: krish2487
author_rank: Frequent Contributor
timestamp: October 28, 2012, 05:42:57 am
content: A cursory glance shows that you have applied the same "expanded scale" limits as defined by the Rlo, Rhi, Ref out and Ref adj to U1 and U2.What you need for your application is a 3 step cascaded, greatly expanded scale 10 step meter.Your requirement is to display the voltage ranges from 10.5-12.8, for ease of math lets make that 12.9. Now you need to display 2.4 (12.9 - 10.5) volts in 3 ten segment steps, which gives us 0.8V per ten step segment.which meansU1 -> 10.5 - 11.3VU2 -> 11.3 - 12.1VU3 -> 12.1 - 12.9VNow this is possible only is the individual expanded scale limits as set by the R lo and R hi represent the above calculated boundaries and then cascade the leds.You dont even have to use the on board 1.25V reference. Just use a couple of 1% resistances with a TL431 to get above voltages. then feed them as the upper and lower limits for U1, U2, U3.Change the votages on pins 4 and 6 and your meter should work.Secondly, you are vague when you say it doesnt work. It would help us help you if you mentioned what you did, what you expected and what happened/did not happen.How did you expect the leds to light up and how did they actually light up???

author: hlavac
author_rank: Frequent Contributor
timestamp: October 28, 2012, 10:35:41 am
content: If you look in the internal schematic in the datasheet, you will find a big 10 1k resistor divider ladder between Rlo and Rhi, with comparators on each tap.To cascade 3 of these ICs you need to connect these ladders in series to form a bigger 30 resistor ladder, and connect measured voltage to all 3 inputs.Connect upper voltage reference to Rhi of the first IC, Rlo of the first to Rhi of the second, Rlo of the second to Rhi of the third and Rlo of the third to the lower voltage reference.

author: krish2487
author_rank: Frequent Contributor
timestamp: October 28, 2012, 10:57:18 am
content: @hlavacYou are right..it is much much simpler that way..no more independant reference voltages for the three casscaded chips...one reference will do...

author: TheUltraNoob
author_rank: Newbie
timestamp: October 29, 2012, 04:06:29 am
content: Greetings,OK... I've been slogging away at this for a bit and have tried another method. Attached is a PDF of my latest attempt that has been an utter failure. What happens is, well, nothing. I put voltage to it, turn it up from 0V - 15V and not a single LED comes on. I can say something interesting happens: When I put R2 to ground Vbat on any pin drops from 5.5V to 0.8V and I have no idea why.Pins 3 and 5 on all 3 chips are fed by a 10k/10k voltage divider. Pin 2 on all chips go to ground.Best regards,The Ultra Noob

author: 6502nop
author_rank: Regular Contributor
timestamp: October 29, 2012, 11:23:50 pm
content: Did someone say LM3914?!I, too, was very puzzled when I first played around with this chip. Like the veritable 555, once I looked at the block diagram, things fell into place. It also clued me into how to adapt this thing for my nefarious purposes.The first thing that'll help you is to view the 3914 as three (or four, if you want to include the MODE operation) sections: some LM339s, an LM334, and a driver output (like the ULN2003). It makes sense, as all of these are National Semi designs - they just shoved all of it onto one substrate.Section 1: Comparators(LM339s)All we have here is a simple ten-segment resistor divider ladder between one input of each of the LM339s, and the reference (buffered) from the SigIn tied to the others. This gives us, in the case of the LM3914, a ten-step linear divider, using 1K per step, for a total of 10K (<--remember that!). In fact, you can build one from 3 LM339s, but it'll take up more space. The LM3915 has deciBel stepping (about 22K total), and the 3916 has VU steps (~10K).Section 2: Voltage Reference(LM334)Well, if we want to measure against a stable reference, why not shove one of those in there, too? The nice thing is they didn't connect the LM334 section (REF Out/Adj) to the ladder (Rhi/Rlo) internally (^--remember that, too!).Note that the LM334 provides for the LED driver current too, so it serves double-duty in this chip.Section 3: Driver OutputSimple 2N2222-type open collector outputs, with current limiting provided by the LM334. One resistor sets the current for the whole string of LEDs, and is why the LEDs don't need any dropping resistors.Operation: The goofy game for eccentric EEs!Now, the problem I had, and I suspect you're having, is that pesky REF Out/Adj. All the circuits in the datasheet all seem to use it, but playing around with it doesn't give you the desired results (or range of values you need). This is because it's only 1.25V nominal. If you feed the REF Adj pin about 4.3V, then tie the REF Out to Rhi, that'll give you a 4.3-5.2V scale. Great for TTL logic, but sucks for car batteries, huh?It was after looking at the block diagram for the umpteenth time that the epiphany hit me: Fsck the REF! Just tie the ladder (Rhi/Rlo) between a couple of pots, give it some stable Vcc, and you can set the ladder where you need it, and even adjust for how much each step takes. The folks that designed this thing probably thought that, too, and is why they brought out the pins instead of tying them internally.Brilliant!So, all you need to do is take that 10K ladder, offset it from ground to get the desired Lo turn-on value (Ohm's Law), then set the High value based on whatever value your Vcc is. You'll see this in the attached schematic I whipped up. It scales perfectly, too, as all you need to do is wedge in the additional 10K ladders of however many LM3914s you want to use.Problem is, we can't just forget about the LM334 section entirely, as it provides the LED current. So, tie the REF Adj to ground, which makes the REF Out 1.25V. Throw a suitable resistor from REF Out to Ground, and the current pulled will set the LED current thus: ((1.25/Rled)x10)=Iled. So, a 1.25K resistor will limit LED current to 10mA. With modern efficient LEDs, I just use a 1.8K (~7mA).We now come to how to measure the voltage of a device that powers the tester we use to measure it. Your original schematic had this part right: just divide the measurement voltage with a simple resistor divider. The LM3914 SigIn only needs a few uAmps, so current draw won't be a problem. So, we use a Vreg that'll give us more than half the expected low battery voltage, and tie that to our Vcc and modified ladder. If voltage seems to dip too much for our test, then we can just use a divide-by-three (or four) on SigIn. Another beauty to this is that the whole shebang (using Bargraph Mode) will draw about 50-400mA, which gives us a pretty good load to put on the battery. If you wire this up for Dot Mode, each chip will draw about 10mA, and allow 20mA for the LEDs (the LM3914 will keep the previous LED on when switching to the next, so current draw can be two LED's worth). So, using 3 LM3914s in Dot Mode should draw about 50mA. Still not too bad.Hope all this helps you out. I can't test this circuit, as I only have one LM3914 left, but the single-mode version I made works well (with a 555 driving it).nopTL;DR - Offset and daisy-chain comparators - skip the REFs, but set the current - use Vreg - measure half Vin.

author: TheUltraNoob
author_rank: Newbie
timestamp: October 30, 2012, 03:09:10 pm
content: Wow!!! What an explination! THANK YOU SOOOO MUCH!!! I've been pounding my head against the desk for days fighting the internal Vref. When I saw your explination I had a "Duh" moment then pounded my head against the desk some more for being so stupid. Now, I've not had a chance to build the circuit but I can't see a reason it won't work. That'll happen tonight when I get home.I do have one question to the group :How do I smooth out dips in battery voltage? When I put the battery under load with a motor or something, the voltage will drop about 0.5V or so. How would I average, smooth or whatever, this dip so the LED display isn't constantly fluctuating?Short of a giant cap on the +Vbat signal is there better way? Can someone point me in the right direction?

author: ptricks
author_rank: Frequent Contributor
timestamp: October 30, 2012, 06:14:33 pm
content: The input to your measuring circuit doesn't use much current so place a resistor in series with IN to limit the current and connect a capacitor , the resistor will keep the capacitor from trying to store power for the entire battery supply. The capacitor can then be just large enough to smooth out the transients.

author: krish2487
author_rank: Frequent Contributor
timestamp: October 30, 2012, 08:01:27 pm
content: Personally i d rather the led vu meter display the dips in the battery voltage under load.It is actually a rather true measure of the battery under load.but then, it is a personal preference.Having said that it is not much of a issue with a 10 step display, with a 30 step display it might be rather a significant drop in the 'steps'.I d go with ptricks suggestion a put a RC filter at the input to smooth out the transients.I dont really see the need to smooth out the transients unless it is a switching load.Even a motor load will load the battery with constant power. Unless the load is changing at a significantly low (< 25~30 Hz) the flicker is usually aliased by the human eye. Maybe they appear to be a little less bright, thats all

author: Rerouter
author_rank: Super Contributor
timestamp: October 31, 2012, 01:41:06 am
content: fit some capacitance to the input, following the voltage divider,also if your driving motors, it would be wise to have a zener to clamp spikes across the battery,

author: 6502nop
author_rank: Regular Contributor
timestamp: October 31, 2012, 10:51:30 am
content: Update:It seems that Ididhave 3 LM391Xs around. I came upon some older NSM3916 VU modules that I forgot about. These are CoB type pre-built modules ready to mount on a panel (back when Rat Shack sold closeouts).Anyway, I was able to breadboard these. I just popped a 100K resistor on the Rlo, and a 50K on the Rhi, skipping the pots, and hooked it up to an SLA battery...Damn thing actually worked the first time.So, I put a pot to sub for the SigIn, and it tracked up and down like a dream (the divider was holding at a steady Vbatt, of course). Looks like this circuit is a good one - I won't need a Rev. B.Notes:1) That 7809 gets warm, even at the measly 243mA I was measuring at full LED draw. I'm thinking that using the 78L09 and the 3914s in Dot Mode wouldn't be such a good idea after all. (For those wondering, each 3914 did draw about 10mA, so that's 30mA, plus the 7mA drawn by each LED -set by the 1K8 resistor- times 30 adds another 210mA, plus the draw of the 7809 and divider all added up to 243mA in bargraph mode. The SLA was at 12.8V, so that's a 3.8V drop at .243A, or about 924mW dissipated by the 7809. In the limited testing, about ten minutes or so, the 7809 never went into thermal shutdown while operating without a heatsink on the breadboard.)2) I'd, therefore, recommend dropping to a 7-8V level and recalculating the ladder dividers if the battery voltage tends to go below 11V (the 7809 output plus 2V overhead). Or, use an LDO type regulator. In any event, if you plan on using this much, put a heatsink on that Vreg, even a clip-on will work, as it's only burning up about a watt.QuoteAs mentioned above, just throw a resistor/cap on there. The SigIn of the 391x has a built-in buffer with input limiting. I tells ya, the designers of this chip are freakin'awesome! If you really want to be fancy, just use the "Peak Detector" add-on given in the datasheets.Now that we have a working design, may I ask just what the hell you're using this for? Like Krish, I'm puzzled by why you would need a 30-segment display when a single 10-segment will do (or even a four-segment using just an LM339).nop

author: TheUltraNoob
author_rank: Newbie
timestamp: October 31, 2012, 03:26:27 pm
content: Why 30 segments for a battery monitor? Well.... there's a story behind it.My daughter has one of those battery powered Barbie Jeeps that I've already souped up with 2 x 18 Ah in parrallel, two speeds, and some more stuff. She freaking LOVES driving it around the yard because it's fast and will run forever on the battery. Now, she wants to know how long will it run and if it needs charging. So, I thought now would be a good time to put on a "gas gauge" so she can see when the batteries are "full" and "empty."Yes, I could just use a 10 segment LM3914 with red, yellow and greed LEDs but that's just not the same. I want a real gas gauge. Well, gas gauges connect to a sending unit in the tank. The sending unit is nothing more than a great big POT that pulls part of the gas gauge coil to ground and causes the needle to move. (See where I'm going with this?)So, the best way to pull that off is to use a string of LM3914 to pull parts of a resister ladder to ground. Ummm.... Take a string of resisters and connect the 1 - 10 pins of the LM3914 between them. When the "LED" turns on for a voltage it pulls the ladder to ground at that point and changes the resistance to the connected gas gauge and the needle moves.Bad explination I know. I'm not at home at the moment and don't have a way to draw and upload a schematic.Why do I need 3 LM3914 with a total of 30 segments? The gauge I have is a full sweep gauge that moves about 270 degrees instead of the usual 90 or so degrees found in your typical car gas gauge. Hence, the more segments will give more resolution to the gauge and I won't get big jumps with the needle as the charge goes down.Ah, here's a picture of the gauge in question:Once I get the circuit working with LEDs I'll play around with the number of segments to adjust the resolution of the gauge. I may chop off a few segments at the bottom of the scale to trigger relays to turn off the batteries to prevent low discharge damage, start a blinking warning light or mayby something else.Sorry... this is getting a little long winded...Could I have done all this with a PIC or something else? Is this the "hard way" to do it? Hell yes it is but, look at my screen name and the group this is in and you'll understand why I've taken this approach.Once I get this finished I'll make a version 2 that uses a PIC. I'd better start reading up on how to program those things.Now to answer the $64,000 question - "Why am I going through all of this trouble?"That has 2 answers:1) To learn basic electronics.2) The more practice she has at 5 with her Barbie Jeep the better she'll be when she turns 16.Best regardsThe Ultra Noob

author: hlavac
author_rank: Frequent Contributor
timestamp: November 16, 2012, 08:53:37 pm
content: Stick an RC filter somewhere between battery and input.