LM339 Voltage indicator

Thread Starter

iONic

Joined Nov 16, 2007
1,662
I am trying to design an LED voltage indicator using a LM339 Quad voltage comparator.
There will be 4 LED's(General Purpose), Yellow, Green, Red, and multi-color flashing. The voltage range would be two leveled in that there could be two ranges possible. The first range would be 22V - 27V, the second would be 22V - 34V. The second range would be implemented infrequently.

With that said I wish to accomplish the following:

Turbo LED - Yellow: 28.0V and higher
Good LED - Green: 26.0V - 27.9V
Low LED - Red: 24.1V - 25.9V
Charge LED - Flasher: up to 24V

I thought the attachment, below would be a good reference although I'm not sure I want to connect the LED's to the source. I think I'd Isolate them and use 5V.

Any ideas on how I would tweak this circuit...resistor values...etc.??
 

Attachments

Last edited:

SgtWookie

Joined Jul 17, 2007
22,230
You really need four voltage window comparators.

Check out Rob Paisley's page:
http://home.cogeco.ca/~rpaisley4/Comparators.html
A voltage comparator window is about halfway down. Make sure to check out the hysteresis circuit, too - if you don't include one, when your voltages are on a boundary, the LEDs will flicker back and fourth.

I suggest you consider using a voltage regulator to power the LM339's. You're going to need a constant voltage reference anyway. You might consider powering the circuit from just one of the batteries (lower side), at around 7v or so.
 

Thread Starter

iONic

Joined Nov 16, 2007
1,662
You really need four voltage window comparators.

Check out Rob Paisley's page:
http://home.cogeco.ca/~rpaisley4/Comparators.html
A voltage comparator window is about halfway down. Make sure to check out the hysteresis circuit, too - if you don't include one, when your voltages are on a boundary, the LEDs will flicker back and fourth.

I suggest you consider using a voltage regulator to power the LM339's. You're going to need a constant voltage reference anyway. You might consider powering the circuit from just one of the batteries (lower side), at around 7v or so.
SGT,
The Source power suggestion sounds like the right thing to do, however, given the nature of the lower and higher extreme comparators I would'nt think I'd need a "window comparator'". As in the Charge LED comparator all it has to do is detect when the voltage goes below 24V and with the Turbo LED, all the comparator needs to detect is when it goes above 27V. Am I right? Or all Wet?
 

Audioguru

Joined Dec 20, 2007
11,248
An LM3914 bar graph LED driver has all the comparators (10 of them) and all the resistors built-in. It also has an accurate adjustable voltage reference.
 

Thread Starter

iONic

Joined Nov 16, 2007
1,662
An LM3914 bar graph LED driver has all the comparators (10 of them) and all the resistors built-in. It also has an accurate adjustable voltage reference.
I don't think it will compare this range of voltages though. If it can I would be at a loss on how to obtain the specific voltage ranges I am after. If you know how, enlighten me!

Thanks
 

SgtWookie

Joined Jul 17, 2007
22,230
given the nature of the lower and higher extreme comparators I would'nt think I'd need a "window comparator'". As in the Charge LED comparator all it has to do is detect when the voltage goes below 24V and with the Turbo LED, all the comparator needs to detect is when it goes above 27V.
OK, I'll give you that one ;)

Rather than going across BOTH batteries, you should consider monitoring each individually. Otherwise, if you're developing a fault (such as a weak or shorted cell) you'll need to break out your voltmeter to determine which of the two batteries are having a problem.

You could switch the power & grounds all at once if you used a DPDT center off toggle switch.

Something else you might consider is the temperature of the batteries. The internal battery temperature generally takes quite a while to change due to the mass involved. The voltages for your thresholds will change depending upon the battery core temperature. One way to measure the core temperature is by using something like an LM35 that's physically attached to the positive terminal; you can then read 10mV/°C from 2°C to around 150°C.

Battery voltage vs proper charge level has a negative coefficient, about -3mV/°C if I remember correctly. I'll have to look at my notes when I get home. If you don't account for the variation in temperature, you can either overcharge the batteries, or allow them to enter sulphation; either one will shorten their lifespan.
 

Thread Starter

iONic

Joined Nov 16, 2007
1,662
OK, I'll give you that one ;)

Rather than going across BOTH batteries, you should consider monitoring each individually. Otherwise, if you're developing a fault (such as a weak or shorted cell) you'll need to break out your voltmeter to determine which of the two batteries are having a problem.

You could switch the power & grounds all at once if you used a DPDT center off toggle switch.

Something else you might consider is the temperature of the batteries. The internal battery temperature generally takes quite a while to change due to the mass involved. The voltages for your thresholds will change depending upon the battery core temperature. One way to measure the core temperature is by using something like an LM35 that's physically attached to the positive terminal; you can then read 10mV/°C from 2°C to around 150°C.

Battery voltage vs proper charge level has a negative coefficient, about -3mV/°C if I remember correctly. I'll have to look at my notes when I get home. If you don't account for the variation in temperature, you can either overcharge the batteries, or allow them to enter sulphation; either one will shorten their lifespan.
SGT,
This might be overkill for my situation. Generally, and I use that word loosely, after each use I charge the batteries. It is with pairs of batteries that are not
"up-to-snuff" that I am concerned with and the general potential available usage remaining I and interested in. If either battery drops below about 11.5V I would suspect to be informed that either both batteries are similar and have fallen below 12V each, or that one battery has fallen below 11.5V or so. This is where a third 6V battery comes in and helps me get to a "gas station" ... battery charger. It is also where I get the 34V from. This third battery would be switchable for such a situation. I guess the way I look at it, it's good enough for Government!, ...well maybe not the one we have at the moment.
 

Wendy

Joined Mar 24, 2008
23,429
You can drop the voltage of all the components, and leave your range intact. Just add an extra voltage reference tree resistor to drop the voltage ranges on the comparitors, they will still be proportional. Same for the measurement side. Your LM3909s never see above 5 volts, even though they are measuring 27+V.
 

Thread Starter

iONic

Joined Nov 16, 2007
1,662
How about this circuit? Is Might this work? I haven't added a hysteresis resistor in yet.
I figured, why mix parts so I just used 4 window comparators as you suggested, two LM339's.

I take it that I would adjust theVin Pot so that 9V is on the comparator inputs??? ...or precisely the same as Vcc(output of 7809). Do you think I should a 7805 as apposed to the 7809. Probably doesn't matter much.
 

Attachments

Last edited:

SgtWookie

Joined Jul 17, 2007
22,230
OK, so re-visiting your original numbers:
Rich (BB code):
       2 in series   Single 
Yel    >=28v         >=14v
Grn    26v-27.9v     13v-13.95v
Red  24.1v-25.9v  12.05v-12.95v
Flash    0-24v         0-12v
I assumed that you typo'ed 25.1 instead of 24.1.

At 77°F (25°C) the median float charge for a lead-acid battery should be 13.56v. SLA/gel cel may vary; check your battery manufacturer's datasheet.
After the float charge is removed either by momentary discharge or by simply standing for a number of hours, a healthy 12v battery may measure anywhere between 12.6v and 12.8v at 25°C, depending upon chemistry. At that same temperature, battery sulphation begins at somewhere around 12.4v.

But, those voltage levels change depending upon the battery internal temperature.

Here's a link to a helpful technical note on maintaining SLA batteries used in UPS systems:
http://rep.mgeups.com/edg/edg/technote/battch.pdf

If you really want to just go with a fixed voltage level reading, it would be a much more accurate indicator if you knew what your average battery temperatures were before you built the circuit.

A battery's internal temperature changes pretty slowly, unless it's being charged or discharged heavily. Without taking the battery apart, the best way to measure the internal temperature is by monitoring the temperature of the positive terminal.
 

Thread Starter

iONic

Joined Nov 16, 2007
1,662
OK, so re-visiting your original numbers:
Rich (BB code):
       2 in series   Single 
Yel    >=28v         >=14v
Grn    26v-27.9v     13v-13.95v
Red  24.1v-25.9v  12.05v-12.95v
Flash    0-24v         0-12v
I assumed that you typo'ed 25.1 instead of 24.1.
Yes..

At 77°F (25°C) the median float charge for a lead-acid battery should be 13.56v. SLA/gel cel may vary; check your battery manufacturer's datasheet.
After the float charge is removed either by momentary discharge or by simply standing for a number of hours, a healthy 12v battery may measure anywhere between 12.6v and 12.8v at 25°C, depending upon chemistry. At that same temperature, battery sulphation begins at somewhere around 12.4v.

But, those voltage levels change depending upon the battery internal temperature.

Here's a link to a helpful technical note on maintaining SLA batteries used in UPS systems:
http://rep.mgeups.com/edg/edg/technote/battch.pdf

If you really want to just go with a fixed voltage level reading, it would be a much more accurate indicator if you knew what your average battery temperatures were before you built the circuit.

A battery's internal temperature changes pretty slowly, unless it's being charged or discharged heavily. Without taking the battery apart, the best way to measure the internal temperature is by monitoring the temperature of the positive terminal.
The battery temperature will vary wildly as I live in the NorthEast US. If the batteries are in the garage they my be about 32 deg F, or if in the house, maybe 68 deg. F. I try to bring them in after each use, but they are heavy. I really think trying to deal with temperature will be a loosing battle unless I use temperature sensing and microprocessor compensation...
 

SgtWookie

Joined Jul 17, 2007
22,230
How about this circuit? Is Might this work? I haven't added a hysteresis resistor in yet.
I figured, why mix parts so I just used 4 window comparators as you suggested, two LM339's.
Well, your construction would be simplified by just using single comparators for the top and bottom. As your circuit is now, it could be simplified a good bit.

I take it that I would adjust theVin Pot so that 9V is on the comparator inputs??? ...or precisely the same as Vcc(output of 7809). Do you think I should a 7805 as apposed to the 7809. Probably doesn't matter much.
Well, the 78xx series voltage regulators have a fixed 2v dropout. If your battery voltage dropped below 11v, an LM7809 would cease to have a regulated output, and your voltage reference would no longer be reliable.

Note that the 78xx series has a fixed 5mA current draw due to the internal voltage divider network, and it requires another 5mA load (total 10mA) to ensure regulation. Since you will always have at least one LED on, the minimum load won't be a problem.

However, you could instead use an LM317T or LM317L adjustable positive regulator. These regulators have a 1.7v dropout instead of 2v. Their line/load regulation is also much better than the 78xx series. Additionally, since you have a known constant load (the LED's, which you'll probably run at 10mA to 20mA) you can use much larger values of R1/R2 to minimize the current use in the voltage adjust circuit. (R1 goes between the OUT and ADJ terminals, R2 goes from ADJ to GND.)

For example, if you used a 2k resistor for R1 and a 10k pot set to about 8.4k (which would be about right for a LM317 that had a Vref of 1.25v) you'd have a 7v output with only 0.6mA current in the voltage adjust portion; or 1/8 that wasted by a 7807.

Oh, just FYI - if you're considering stocking up on 78xx series regulators, the 7805's are the most useful. You can always increase their output voltage by adding resistance between their ground terminal and GND. Under normal operation, there is a 5mA current flowing from the ground terminal.
Since R=E/I, every 100 Ohms of resistance between the ground terminal and GND will result in a nominal 0.5v increase in the output voltage.
 

SgtWookie

Joined Jul 17, 2007
22,230
The battery temperature will vary wildly as I live in the NorthEast US. If the batteries are in the garage they my be about 32 deg F, or if in the house, maybe 68 deg. F. I try to bring them in after each use, but they are heavy. I really think trying to deal with temperature will be a loosing battle unless I use temperature sensing and microprocessor compensation...
It doesn't have to be that complicated.

I think that an LM35 temp sensor epoxied to one of the battery + terminal clamp (and insulated, of course) could be used with an opamp to give the -3mV/°C compensation required.

Otherwise,
at 0°C (32°F), the proper float voltage is about 14.01v
at 20°C (68°F), the proper float voltage is about 13.65v
at 25°C (77°F), the proper float voltage is about 13.56v
at 35°C (95°F), the proper float voltage is about 13.38v.
Over just the 0-35°C range, the voltage changes by 630mV.

This agrees with the negative tempco I posted earlier; I neglected to mention that the -3mV/°C was per cell. Since your batteries each have 6 cells, the correct formula for one of them is -18mV/°C; for both in series it's -36mV/°C
 

Thread Starter

iONic

Joined Nov 16, 2007
1,662
Well, your construction would be simplified by just using single comparators for the top and bottom. As your circuit is now, it could be simplified a good bit.
I sappose it could. I have about a dozen LM339 Quads, 8 LM311's and 1 LM393 Dual comparator.I could use the LM393 for the upper and lower limit and one LM339 for the two window comparators.


Well, the 78xx series voltage regulators have a fixed 2v dropout. If your battery voltage dropped below 11v, an LM7809 would cease to have a regulated output, and your voltage reference would no longer be reliable.

Note that the 78xx series has a fixed 5mA current draw due to the internal voltage divider network, and it requires another 5mA load (total 10mA) to ensure regulation. Since you will always have at least one LED on, the minimum load won't be a problem.

However, you could instead use an LM317T or LM317L adjustable positive regulator. These regulators have a 1.7v dropout instead of 2v. Their line/load regulation is also much better than the 78xx series. Additionally, since you have a known constant load (the LED's, which you'll probably run at 10mA to 20mA) you can use much larger values of R1/R2 to minimize the current use in the voltage adjust circuit. (R1 goes between the OUT and ADJ terminals, R2 goes from ADJ to GND.)

For example, if you used a 2k resistor for R1 and a 10k pot set to about 8.4k (which would be about right for a LM317 that had a Vref of 1.25v) you'd have a 7v output with only 0.6mA current in the voltage adjust portion; or 1/8 that wasted by a 7807.

Oh, just FYI - if you're considering stocking up on 78xx series regulators, the 7805's are the most useful. You can always increase their output voltage by adding resistance between their ground terminal and GND. Under normal operation, there is a 5mA current flowing from the ground terminal.
Since R=E/I, every 100 Ohms of resistance between the ground terminal and GND will result in a nominal 0.5v increase in the output voltage.
I didn't know the 78XX series had a higher dropout voltage than the 317's. I have both. I think going with the 317 and working with 7V will keep me safe.

It doesn't have to be that complicated.

I think that an LM35 temp sensor epoxied to one of the battery + terminal clamp (and insulated, of course) could be used with an opamp to give the -3mV/°C compensation required.

Otherwise,
at 0°C (32°F), the proper float voltage is about 14.01v
at 20°C (68°F), the proper float voltage is about 13.65v
at 25°C (77°F), the proper float voltage is about 13.56v
at 35°C (95°F), the proper float voltage is about 13.38v.
Over just the 0-35°C range, the voltage changes by 630mV.

This agrees with the negative tempco I posted earlier; I neglected to mention that the -3mV/°C was per cell. Since your batteries each have 6 cells, the correct formula for one of them is -18mV/°C; for both in series it's -36mV/°C
Do you think I really have to worry about the extreme variations for 0.63V?
I appreciate your help, truly, but a simple and general indicator will be sufficient.
 

SgtWookie

Joined Jul 17, 2007
22,230
I suppose it could. I have about a dozen LM339 Quads, 8 LM311's and 1 LM393 Dual comparator.I could use the LM393 for the upper and lower limit and one LM339 for the two window comparators.
That would work.

I didn't know the 78XX series had a higher dropout voltage than the 317's. I have both. I think going with the 317 and working with 7V will keep me safe.
The LM317 certainly provides more versatility and stability, along with reducing current requirements.

Do you think I really have to worry about the extreme variations for 0.63V?
I appreciate your help, truly, but a simple and general indicator will be sufficient.
It's up to you. Since you have two batteries in series, over the 35°C range previously mentioned, the total difference will be 1.26v for the float charge voltage.
 

Thread Starter

iONic

Joined Nov 16, 2007
1,662
The attached image is a redraw using the LM393N and the LM339N IC's.
But I am beginning to wonder about the third battery, the 6V one that I would use in series with the two 12V Bat's when the batteries are real low or if I need a boost up a hill. This would change the voltage divider scale and all the LED's would not be telling me the true voltages. Am I right here?

Also, a difference of 1.26V with respect to temperature is actually a lot considering some of the windows I have established for the LED's, although I still do not understand how the correct float voltage will affect the operation of the LED's while the batteries are in operation, or does that change the voltage divider scale just as adding another battery to the system.

I think we will have to make some general assumptions.
1) The battery temperature will almost always be between 65F and 85F(keeping them indoors in the cooler months.)

Is the circuit below right for a window comparator with historesis??
 

Attachments

Last edited:

SgtWookie

Joined Jul 17, 2007
22,230
No, the hysteresis feedback needs to go to the noninverting (+) input, otherwise you'll have an oscillator.

The diodes on your comparator outputs don't make sense. You don't need them. LM339's can't source current; only sink it. They have open-collector outputs.

Have a look at the attached. No hysteresis, but the voltage levels are about right.

I only had an LM339 in the library, so I used it for all of them instead of your other comparator; but they'll work about the same.

Note that the LM339 has somewhat limited current sink capability; minimum is 6mA, typical is 15. To ease the load on the LM339's output transistors, I used 2N3904's for LED drivers.
 

Attachments

Thread Starter

iONic

Joined Nov 16, 2007
1,662
Your right about the resistors for the hysteresis. I goofed there. And the diodes on the output I got from some site, evidently wrong.

Question: The 4.7K resistors, R9 - R12, what are these for?
 

SgtWookie

Joined Jul 17, 2007
22,230
Question: The 4.7K resistors, R9 - R12, what are these for?
As I mentioned in my last reply, the LM339 (LM393 also) have open-collector outputs; they cannot source current, only sink it. R9-R12 are the source of current.

When the LM339/LM393's output is sinking current, the LED driver transistor (Qn) will be turned off, therefore the LED will not be lit.

When the LM339/LM393's output is not sinking current, the 4.7k resistor will supply about 1.3mA current to the Qn transistor's base, turning it on.

My schematic is much more cluttered than I would've liked; but the circuit simulator I'm using is limited to 50 components, so instead of using symbols I had to run wire everywhere.

Oh, current consumption when operating is between 23.7mA and 25.2mA, depending on total battery voltage. 16mA is used in the LED that's on, about 4.5mA is being sunk by the 339 outputs that are on, 0mA-1.3mA is used in the R5 & R6 voltage divider, and the rest is consumed by the LM339's themselves. There's another 0.69mA used in the LM317 circuit.
 
Last edited:

SgtWookie

Joined Jul 17, 2007
22,230
OK, a few changes; mainly R1 through R6 values. I somehow managed to ham-finger a formula, so the levels weren't quite right. Also, the current in the voltage divider circuit needed to be increased a bit.

You should use 10-turn or more pots for R8 (Vcc adjust) and R6.

R8's value may have to be anywhere between 8k and 8.8k inclusive, depending upon your individual regulator's Vref; that can vary anywhere from 1.2v to 1.3v. If Vcc isn't set accurately to 7v, your LED's will light up at the wrong voltage levels.

Whatever voltage you place on the high side of R6, divide that number by 5.143, and adjust R6 so that the voltage at the R6/R5 junction is equal to the result. For example:
25.2v / 5.143 = 4.9v
If this divider isn't set correctly, your LEDs will not come on at the right voltage levels.

Use 1% tolerance metal film resistors for R1 thru R5; they will be much more stable and have less noise than carbon film resistors. DigiKey is a good source.
 

Attachments

Top