Comparator LED Circuit--Help Plz

Discussion in 'The Projects Forum' started by LetSmokeOut, Oct 9, 2010.

1. LetSmokeOut Thread Starter New Member

Oct 9, 2010
23
0

I'm just a newbie circuit designer, which I'm sure is apparent to those of you who see the above circuit and are not. At any rate, I'm trying to create a simple circuit that compares the voltage being delivered from the solar panel to a reference voltage of 15V to the comparator (provided by the 18v battery supply). If the solar panel is NOT delivering a minimum of 15v, the red LED should illuminate. If the solar panel IS delivering above 15v, the yellow LED should illuminate. Rather than making it over complicated by using two seperate comparators (one for each LED), I was trying to simply use an inverter but I don't know if what I'm trying to accomplish is possible with these components. This probably goes without saying, but we obviously intend to use the 18v battery supply to power the LEDs since it is the solar panel we are interested in comparing. The LEDs are your typical 2v ones.

If someone would be kind, please take a look and let me know what things are wrong with my circuit. If you want to be a saint, please provide a circuit diagram of one that might work or resolve whatever issues exist with my current circuit. We are using an LM339 for the comparator and I don't remember the number of the invertor off the top of my head but it is a cmos if I recall. I'll post again with more details regarding the inverter name once I check (the breadboard and circuit is currently at a buddy's house, so I can't check it right this minute). Also worth noting, we use an NTE956 instead of an LM317.

Last edited: Oct 9, 2010
2. wayneh Expert

Sep 9, 2010
14,945
5,425
Your comparator is comparing 15v to ground, so will always be on, even with a low supply voltage (eg. 10v from the panel, with the battery removed). Do you just want to measure the panel voltage - not under load - and then switch the lights at the reference voltage?

3. Wendy Moderator

Mar 24, 2008
21,407
2,940
Major error noted. A LM339 or LM393 both require a pull up resistor, and LEDs always require a current limiting resistor. If you have power this up the magic smoke has escaped.

Try something like this, which is an excerpt from my article LEDs, 555s, Flashers, and Light Chasers .

.................................................. .Figure 4.3

A comparator has a maximum spec current of 16ma, but you need to use a fraction of that.

4. LetSmokeOut Thread Starter New Member

Oct 9, 2010
23
0
Thank you both for your replies. The inverter in the diagram shown in my initial post is an NTE 4069.

wayneh:
We want to measure the panel voltage most importantly with a load. This circuit is meant to be an accessory portion of a solar panel battery charger circuit. The solar panel battery charger circuit is already built and appears to be functioning correctly. We want to add the "Red-Yellow LED circuit" to tell us when the solar panel is receiving enough light to deliver a minimum of 15v to the charging circuit. To clarify, we are calling the circuit in my original post the "Red-Yellow LED circuit."

Bill_Marsden:
We didn't notice any smoke when we tested the circuit, but nothing lit up so we automatically knew we did something wrong. Thank you for the information.

We will sketch out some new circuits and post them here if anyone is willing to continue helping us with our fun little project. Thanks again.

5. wayneh Expert

Sep 9, 2010
14,945
5,425
Nothing smoked because the comparator can only pull low - sinking up to 16mA, plenty for an LED - or go open. It cannot source current. Given that, both your LEDs are pointing the wrong way to pass current, even if they were powered instead of grounded. If they were turned the other way, something might poof.

6. Wendy Moderator

Mar 24, 2008
21,407
2,940
Running the comparator with much current at all is not a good idea, you want to keep current on the pullup resistor as low as possible. My design minimizes the loading, R8 is designed to turn the transistor off, using almost no current. When the output is low the current is feed through the base of a common collector design, also minimizing current. It draws less than a milliamp for a 20ma LED.

Making the comparators go even near their limits tends to degrade their performance, though not necessarily permanently.

I had missed the LEDs being backwards. It means your parts will live to fry another day.

Last edited: Oct 10, 2010
7. wayneh Expert

Sep 9, 2010
14,945
5,425
No argument. I find that even 5mA can produce a very bright light with modern LEDs. Anything more is just showing off.

8. Wendy Moderator

Mar 24, 2008
21,407
2,940
Actually I was referring to the comparator, it specs degrade when it is pushed to it's limits. It is better to have an amplifier after it if you need to drive it hard.

9. SgtWookie Expert

Jul 17, 2007
22,202
1,793
I'm afraid that you're going to go through 9v batteries pretty quickly. Brand-new alkaline PP3 batteries are rated for around 600mAh; rechargeables are generally rated for much less.

The LM317 regulator requires 10mA <= load <=1.5A on the output for it to provide guaranteed regulation. You will have ~5.7mA current through R1/R2, and the LEDs could be current-limited to draw the remaining minimum current. However, the battery output voltage will begin to decrease after even a short period of time under load.

A datasheet for an Energizer PP3 9v battery is here:
http://data.energizer.com/PDFs/522.pdf
Look under the Industry Standard tests on page 2; the 620 Ohm radio, 2hrs/day.

Note that the battery voltage drops to under 8.5v in less than 5 hours of being in service. Two such batteries in series would then measure 17v. The LM317 has a minimum 1.7v dropout from the IN to the OUT terminal; as soon as your batteries dropped below 8.35v (16.7v total), you would no longer have a voltage regulated output. This would occur in fewer than 10 hours of being in service.

10. wayneh Expert

Sep 9, 2010
14,945
5,425
Me too - I meant that you don't need anywhere near the comparator's 16mA limit to produce a nice bright indicator. If you need a spotlight to find your keys in the dark, well that's different and you'll want an amplifier (eg. transistor). But for merely a visible indicator light, low current is fine. I have some superbright (and super cheap) white LEDs that are plenty bright - actually painful to look at straight on - at just 2mA.

11. SgtWookie Expert

Jul 17, 2007
22,202
1,793
I usually try to keep the 339's sink current in the range of 3mA to 4mA; if you go much more than that, the saturation voltage becomes rather high.

I've had problems running simulations with the '339 if the output is expected to sink more than 6mA.

12. wayneh Expert

Sep 9, 2010
14,945
5,425
Makes sense. I never drive an LED directly with the comparator unless that's the ONLY thing the comparator output is used for.

13. SgtWookie Expert

Jul 17, 2007
22,202
1,793
Here's a revised circuit that does not require the use of batteries.

RGYALED (LED1) represents a green or yellow LED.

I'm using a common 1N4148 switching diode as a voltage reference. With ~0.1mA current flowing through it, it will drop ~0.5v across itself. Adjust R3 to trip at 15v.

The LM2903 is an automotive temp range version of the LM393; a dual comparator. You can use an LM339 if you wish, but you should ground the unused inputs or you will experience problems due to unexpected oscillations.

Since there is no hysteresis, it will be a bit flaky when right at the threshold.

The red LED will continue to glow even when the solar panel voltage output is quite low, unless it drops below the threshold Vf of the LED (not normally specified in datasheets).

File size:
64.3 KB
Views:
44
14. LetSmokeOut Thread Starter New Member

Oct 9, 2010
23
0
Thanks for the replies and especially for the circuit diagrams. Your help is very much appreciated.

I should have mentioned this before but we were planning to use a switch for the Red-Yellow LED circuit so it wouldn't be a continuous load on the batteries. We would just flick the switch to see which LED lit up to help us determine if the solar panel is producing adequate voltage, then flick it again to turn it off. We didn't have them drawn in our circuit because we were still undecided about where to put them.

Do you think the load in your circuit wouldn't be enough to make a noticeable difference in the amount of time required to charge the 12v battery? My biggest concern is taking away voltage from the charging battery thereby making the circuit's primary function less efficient. I'll get back to you with more information about the rest of our circuit once I have access to our paperwork and datasheets.

Last edited: Oct 11, 2010
15. LetSmokeOut Thread Starter New Member

Oct 9, 2010
23
0
Hello. I have a new question regarding our resistors and other components throughout our circuits. I noticed that the resistors we are using are rated for 1/4 watt. However, our solar panel is rated for 18v @ 4.72 amps and our battery is rated for 12v @ 7Ah. We will be using one circuit only connected to the solar panel and another only connected to the battery (both with 2 low current series connected 9v batteries to power LEDs) to measure the respective voltage levels. Anyway, I'm wondering if we should get resistors and components rated for 85watts or if our circuit components will be okay for short durations (minutes, not hours) at a time without failing (both circuits will be activated via switch). Any advice would be appreciated.

16. Wendy Moderator

Mar 24, 2008
21,407
2,940
Heat is waste, if a part gets hot you are wasting the power you spent so much money to get.

You have to look at the application, if the resistor is part of a monitoring circuit then it will likely be overrated for the job, even at ¼W.

Power is P=EI, and ohm's law will provide the rest of the information. If a resistor is in the main current path of the solar cells do the math, but that should almost never happen.

The input currents to comparators are are usually in the nanoamp range, so no problem there.

For a better answer you're going to have to show schematics.

17. SgtWookie Expert

Jul 17, 2007
22,202
1,793
You calculate resistor power rating requirements by E^2/R or I^2R or EI, and then double the result to make certain the resistors stay reasonably cool. As far as the schematic I posted, even 1/10 Watt resistors would be adequate.

I made a revision to the circuit to add a bit of hysteresis. The worst-case current draw is ~6mA@18v, which is a small fraction of your 4.72A charge current. If the battery is down to 12v, the current draw is just under 4mA.

I don't see a need to use two 9v batteries to power the LEDs.

File size:
62.2 KB
Views:
68
18. LetSmokeOut Thread Starter New Member

Oct 9, 2010
23
0
Thank you for the replies. Your circuit looks fantastic, SgtWookie! For educational purposes, though, I went ahead and designed my own circuit from scratch and built and tested it out. The following circuit seems to work almost perfectly. It is accurate to within 0.3v which is less than ideal. I believe if I replace the 2k resistors with a 5k (20 turn) potentiometer I will be able to adjust it to find the precise resistance so that the LEDs switch at exactly 15v (instead of between 14.7v and 14.8v).

I spent a good amount of time testing and learning more about these circuits and am eager to continue learning. If anyone can comment on my circuit and specifically, if you could offer some constructive criticisms and comparisons between your circuit and mine, SgtWookie, it'd be highly appreciated. Note that I just tied all of the negative rail voltages and grounds to the same node. This seems to work in my tangible circuit which was tested. Thank you very much kind gentlemen!

19. LetSmokeOut Thread Starter New Member

Oct 9, 2010
23
0
I forgot to mention the resistors I used to build and test the circuit in the above diagram were rated for only 1/4 watt. The DC supply I used to simulate the solar panel was not capable of putting out 4.72A, so this is one of my concerns regarding the power ratings on the components. When I do use the solar panel as the circuit is intended, will the 1/4 watt resistors be sufficient for short term use?

20. SgtWookie Expert

Jul 17, 2007
22,202
1,793
Since you used a simple voltage divider instead of a reasonably accurate voltage reference (like a Zener diode or even a simple diode like I did) your readings will vary with the state of charge in the 9v batteries.

Since R5 and R6 are 470 Ohms, your LED current will be too high (around 28mA) and they will have relatively short lives.

Increase R5 & R6 to 1k Ohms. You'll get about 14mA current through the LEDs.

You'll need 1/2 Watt resistors for R5 & R6 unless the circuit will only be used for a moment.
If go to 2k Ohms, you can use 1/4 Watt resistors.

Last edited: Oct 17, 2010