Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

LM339 Output control to relay. HELP!!!!!!!!!!!!!!!!!!!!!!!!!!!

772 views
Skip to first unread message

Dan McCauley

unread,
Nov 30, 1998, 3:00:00 AM11/30/98
to
I desperately need some help!

This is what I am trying to accomplish. I want the output from a LM339
voltage comparator to activate a 12 volt relay.
I have tried using a transistor switch off the output, but can't get it to
work.
Here are my current system specs.

Relay 12V, 200 ohm coil.

2N2222 transistor (600mA collector I max)
LM339 Quad voltage comparator.

How can i set this up to use the LM339's output to control the relay? All
help greatly appreciated. Don't care if low or high output turns on relay.

Thanks!

dan
li...@snip.net

Brian E Rhodefer

unread,
Nov 30, 1998, 3:00:00 AM11/30/98
to
In article <73vit8$2eh$1...@news1.fast.net>, Dan McCauley <li...@snip.net> wrote:
>
> I want the output from a LM339 voltage comparator to activate a 12 volt
> relay. I have tried using a transistor switch off the output, but can't
> get it to work. Here are my current system specs.
>
> Relay 12V, 200 ohm coil.
>
> 2N2222 transistor (600mA collector I max)
> LM339 Quad voltage comparator.
>
> How can i set this up to use the LM339's output to control the relay?

Your relay's coil draws 60mA when energized; too much for an LM339 output
to sink directly. The 2N2222 is easily capable of sinking 60mA, and should
be able to do so at a beta of 30 or more, I should think.

Put a 24K pullup resistor between the LM339's output and the +12V supply
(this is assuming the negative terminal of the 12V supply is connected
to your circuit's `ground'). Connect this pulled-up output to the base
of your 2N2222, and ground its emitter. Connect the relay coil between
the +12V supply and the 2N2222's collector, and add a jellybean diode in
parallel with the relay coil (cathode to +12V, anode to 2N2222 collector).

When the voltage at the LM339's noninverting terminal (+) is higher
than voltage at its inverting terminal (-), the LM339's output sink
will be OFF, and not diverting the (approximately) 2mA of current
allowed by the pullup resistor to ground. That current will then
flow through the base-emitter of the 2N2222, which should be enough
to cause its collector to switch pretty much down to ground, thus
energizing the relay's coil.


-Brian Rhodefer
(not officially representing Tektronix, Inc)

Michael Black

unread,
Nov 30, 1998, 3:00:00 AM11/30/98
to
The 339 has an open collector output. In other words, the output pin
connects internally to the collector of a transistor (and the transistor's
emitter goes to ground). When the output is low, it will draw current
from whatever is connected there. But when the output is not-low, it will
not provide a voltage, but will act like there is nothing connected inside
to the output pin.

If the current requirements of the relay is small enough, you could drive
it from the 339 output by putting the relay coil between the output pin
and the positive supply. But even if there is enough current, you'd need
to ensure that the relay would not damage the 339.

If you connect a resistor from the 339 output pin to the positive supply,
then you will see a low when the output stage is low, and a positive
voltage at other times.

If you are driving an NPN transistor, and the 2N2222 is, then you will
need such a pull-up resistor in order to drive the 2N2222. NPN
transistors need a positive voltage to turn on.

Michael

On Mon, 30 Nov 1998, Dan McCauley wrote:

> I desperately need some help!
>

> This is what I am trying to accomplish. I want the output from a LM339


> voltage comparator to activate a 12 volt relay.
> I have tried using a transistor switch off the output, but can't get it to
> work.
> Here are my current system specs.
>
> Relay 12V, 200 ohm coil.
>
> 2N2222 transistor (600mA collector I max)
> LM339 Quad voltage comparator.
>

Richard Steven Walz

unread,
Nov 30, 1998, 3:00:00 AM11/30/98
to Dan McCauley
Dan McCauley wrote:
>
> I desperately need some help!
>
> This is what I am trying to accomplish. I want the output from a LM339
> voltage comparator to activate a 12 volt relay.
> I have tried using a transistor switch off the output, but can't get it to
> work.
> Here are my current system specs.
>
> Relay 12V, 200 ohm coil.
>
> 2N2222 transistor (600mA collector I max)
> LM339 Quad voltage comparator.
>
> How can i set this up to use the LM339's output to control the relay? All
> help greatly appreciated. Don't care if low or high output turns on relay.
>
> Thanks!
>
> dan
> li...@snip.net
---------------------------------------------------
The LM339 is open-collector. Put a pull-up on its output that will
just drive the 2N2222 to saturation and it will pull the base low when
the op-amp output should go low.
-Steve
--
-Steve Walz rst...@armory.com ftp://ftp.armory.com:/pub/user/rstevew
-Electronics Site!! 1000 Files/50 Dirs!! http://www.armory.com/~rstevew
Europe:(Italy) http://ftp.cised.unina.it/pub/electronics/ftp.armory.com

William L. Bahn

unread,
Dec 1, 1998, 3:00:00 AM12/1/98
to
The most common mistake I have seen people make with the 339 is to fail to
recognize that it is an OPEN COLLECTOR device and address the circuit design
implications of this fact. This is quite important if you are using an NPN
transistor such as the 2N2222.

Also, don't forget to limit the base current.

Also, these are very high gain devices - don't leave any unused inputs
floating, even on comparators you are not using.

Dan McCauley wrote in message <73vit8$2eh$1...@news1.fast.net>...

Paul Grohe

unread,
Dec 2, 1998, 3:00:00 AM12/2/98
to
On Mon, 30 Nov 1998 09:14:50 -0500,
in the newsgroup sci.electronics.basics,
"Dan McCauley" <li...@snip.net>
from FASTNET(tm) PA/NJ/DE Internet thoughtfully posted:

> I desperately need some help!
>
> This is what I am trying to accomplish. I want the output from a LM339
> voltage comparator to activate a 12 volt relay.
> I have tried using a transistor switch off the output, but can't get it to
> work.
> Here are my current system specs.
>
> Relay 12V, 200 ohm coil.
>
> 2N2222 transistor (600mA collector I max)
> LM339 Quad voltage comparator.
>
> How can i set this up to use the LM339's output to control the relay? All
> help greatly appreciated. Don't care if low or high output turns on relay.

The output of a LM339 (and many other comparators) is an "open
collector" output - NOT the same as an op-amp output. It cannot
"swing" to V+.

An "open collector" output is simply a transistor with its
collector "open" and the emitter connected to the "gnd" pin. You
can think of the output transistor as a switch that connects the
load to ground when the output is "true". If you want to turn
something "on", you connect it between the output pin and V+.

However, the LM339's output "switch" has a current limit of about
15mA - not enough to drive your relay.

However - you can have it drive your transistor, which will then
drive your relay.

Connect the base of the 2N2222 to the output. Then place a 10K
"pullup" resistor between the output pin and V+. Ground the
2N2222's emitter. Then connect the relay between the 2N2222
collector and V+.

IMPORTANT: You must have a diode across the relay coil to stop
turn-off spikes. WIthout it you will damage the 2N2222 and the
LM339. Connect the diode *directly* across the relay coil
terminals (as close as possible) with the cathode (striped) end
connected to the V+ side of the coil.

You should look at the datasheet for the LM339. There is a
circuit for a "limit comparator" that drives a light bulb. Just
replace the light-bulb with the relay/diode combination. Ignore
the second comparator in the circuit - you only need one.

http://www.national.com/ds/LM/LM139.pdf

Also take a look at AN-74. It is a good tutorial on comparators.

http://www.national.com/an/AN/AN-74.pdf

Good Luck!

Cheers,
Paul Grohe

--
---------------------------------------------------------------
Paul Grohe National Semiconductor Corp.
Assoc. Analog Apps Engineer 2900 Semiconductor Drive
Standard Analog Apps Group Mail Stop C2693
mailto:gr...@galaxy.nsc.com Santa Clara, CA. 95052-8090 USA
Usenet Disclaimer: Any opinions expressed are mine, not NSC's
----------------------------------------------------------------

0 new messages