lm339 comparator for battery charger - switching on and off too fast or going half on?

Thread Starter

rudyauction8

Joined Jan 27, 2012
250
So I'm using a lm339 comparator to switch my charger on and off for my 60v battery. Even with hysteresis it switches the relay so fast the relay melts from the arcs. It seems to go to a state where it is half on, instead of being either on or off. Note that the relay is driven by a power transistor. My circuit is near identical to this one:
, vref is 7805 regulator, r8 is 10k plus 10k trimmer in series, r9 1k, r10 100k. What am I missing here? I just need it to slow to no more than one relay cycle per second. I'm guessing a capacitor somewhere would help, but I'm new to comparators.
 

Thread Starter

rudyauction8

Joined Jan 27, 2012
250
The comparator is powered by a 9v 1a supply, and there is an LED in parallel with the relay, thats how I noticed the half on - the LED would be dimly lit while the relay was switching. The relay is part of a digital timer I took apart, it has its own power supply and transistor and only takes a couple ma to activate.
 

GopherT

Joined Nov 23, 2012
8,009
The comparator is powered by a 9v 1a supply, and there is an LED in parallel with the relay, thats how I noticed the half on - the LED would be dimly lit while the relay was switching. The relay is part of a digital timer I took apart, it has its own power supply and transistor and only takes a couple ma to activate.

I think you left off the most important part of your story. Do you understand that the LM339 is an open collector output and you need a pull up resistor to supply current to the NPN output inside the chip?

Also, is your load on your 9V at 1 amp power supply so big that you have some voltage sag when charging vs not charging. If you have sag, that may be causing the oscillation. To remove the effects of sag, you can have the NPN drive a PNP in your output and flip your input signals on the comparitor (that way, the sag will give you desirable hysteresis instead of undesirable oscillation). It was already requested above, please post the WHOLE schematic so we can see if my speculation is true - or if any other obvious error exists.
 

Thread Starter

rudyauction8

Joined Jan 27, 2012
250
I think you left off the most important part of your story. Do you understand that the LM339 is an open collector output and you need a pull up resistor to supply current to the NPN output inside the chip?

I had a pull up resistor, 4.7k ohms

Also, is your load on your 9V at 1 amp power supply so big that you have some voltage sag when charging vs not charging. If you have sag, that may be causing the oscillation. To remove the effects of sag, you can have the NPN drive a PNP in your output and flip your input signals on the comparitor (that way, the sag will give you desirable hysteresis instead of undesirable oscillation). It was already requested above, please post the WHOLE schematic so we can see if my speculation is true - or if any other obvious error exists.

Changed to a 12v 7ah battery capable of at least 10 amps and no difference.



In the end I forgot my charger was not ground isolated, and when I tried to use the 60v battery to power the relay I accidentally pumped about 70 volts through the comparator, 7805 and power transistor, all 3 literally exploded (as expected when overvolting chips to 2x their max voltage with reverse polarity). Since I'm upgrading to lithium this wednesday I decided to just use the timed setup I was using until then. Yes I do have a proper lithium charger coming as well btw so no need to worry about blowing my battery up.
 
Last edited:

GopherT

Joined Nov 23, 2012
8,009
In the end I forgot my charger was not ground isolated, and when I tried to use the 60v battery to power the relay I accidentally pumped about 70 volts through the comparator, 7805 and power transistor, all 3 literally exploded. Since I'm upgrading to lithium this wednesday I decided to just use the timed setup I was using until then. Yes I do have a proper lithium charger coming as well btw so no need to worry about blowing my battery up.
Well, that's another way to solve the problem. It happens to all of us (if it hasn't happened to someone, they are either lucky or not building anything. Thanks for the update.
 

Thread Starter

rudyauction8

Joined Jan 27, 2012
250
Well, that's another way to solve the problem. It happens to all of us (if it hasn't happened to someone, they are either lucky or not building anything. Thanks for the update.
Sure, and I may revisit this with one of my 36 volt scooters at some point. As great as lithium is, SLA batteries will always power something in my garage, and with a non-automatic charger that I use on all of my packs (current limited and can charge 6v to 96v packs) I cook my SLA batteries all the time. That's why I always buy them used from the scrap yard. I can get a dozen batteries for $20, that hold half their charge, and new they'd be $20 each. And of course I get about $10 back when I'm done with them.
 
Top