Maker Pro
Maker Pro

LM393 Comparator

Ben Parker

Sep 21, 2015
3
Joined
Sep 21, 2015
Messages
3
Hi all,

Im trying to use the LM393 Comparator chip. I am using 12vDC on Vcc. However when the circuit switches due to the change in voltages on INV- and INV+ it goes from 0v to 0.5v on the OUT pin? I thought i would get the Vcc voltage out? Is this correct or is there something wrong?

Thanks
 

Old Steve

Jul 23, 2015
734
Joined
Jul 23, 2015
Messages
734
Hi all,

Im trying to use the LM393 Comparator chip. I am using 12vDC on Vcc. However when the circuit switches due to the change in voltages on INV- and INV+ it goes from 0v to 0.5v on the OUT pin? I thought i would get the Vcc voltage out? Is this correct or is there something wrong?

Thanks
Do you have a pullup resistor from the output pin to +V? The LM393, and in fact most other comparators, has an 'open-collector' output.

https://www.fairchildsemi.com/datasheets/LM/LM393.pdf

Edit: See the schematic diagram in the datasheet linked above. Q8 is the output transistor.
 

AnalogKid

Jun 10, 2015
2,884
Joined
Jun 10, 2015
Messages
2,884
The 393 has an open collector output, not a totem pole output. It can pull a load down (sink current), but not up (source current). If you look at the application circuits in the datasheet, you'll see that most of them have a pull up resistor from the output to Vcc. This resistor is path for any output source current needed.

If you do need a true push-pull output stage, change to a LM358 and see if that works for you.

ak
 

Old Steve

Jul 23, 2015
734
Joined
Jul 23, 2015
Messages
734
That's better - now some hysteresis?

..... Just kidding about the hysteresis, and I wasn't having a shot at you earlier, it just looked pointless having a square wave input for a virtually identical output.
LTSpice is a handy tool, isn't it?
 

wingnut

Aug 9, 2012
255
Joined
Aug 9, 2012
Messages
255
Hi Ben and all

First of all welcome to the forum Ben. I think AK's advice to use a LM358 should do what you expect - output a positive voltage. The LM393's output is just like a closed switch to ground or an open switch to ground and that is why a voltmeter reading taken from the output shows negligible change in output voltage. The LM358 will on the other hand give two distinct output voltages, one state positive, and one of 0V. Reminder to self to get some of these babies next time I order.

If you have any more questions please ask. I am a reader of Louis L'Amour not data sheets so that is why I am very grateful to be on a forum where folks who do read data sheets around the breakfast table, are kind enough to explain the minutia of electronics to me.
 

Old Steve

Jul 23, 2015
734
Joined
Jul 23, 2015
Messages
734
Ben, before you go off and buy some LM358s, possibly for no good reason, what are you connecting to the output of the comparator?
Chances are the LM393 is fine, if you add a pullup resistor to the output pin. That's how they're intended to be used.
That will give you a positive voltage when the +ve input pin is higher than the -ve input pin.
 

Ben Parker

Sep 21, 2015
3
Joined
Sep 21, 2015
Messages
3
Hi, thanks for all the replies! I am using the LM393 to compare 2 voltages to then switch on an air compressor (240vAC, 500w). After the initial reply I studied "open collectives" which are new to me. So now I have used a transistor on the output to power a relay. It works, but is this the best way of doing it?
 

Old Steve

Jul 23, 2015
734
Joined
Jul 23, 2015
Messages
734
Hi, thanks for all the replies! I am using the LM393 to compare 2 voltages to then switch on an air compressor (240vAC, 500w). After the initial reply I studied "open collectives" which are new to me. So now I have used a transistor on the output to power a relay. It works, but is this the best way of doing it?
The best way, with your circuit, is like this:-

Comparator.JPG
 

Old Steve

Jul 23, 2015
734
Joined
Jul 23, 2015
Messages
734
Ignore the fact that I used an LM311, pretend it's a 393. (I just copied/pasted it 'as-is' from my components file.) The diode should be a 1N4002 or similar, and the transistor should be chosen for the current needed to power the relay coil. the resistor could be as high as 10K.

Alternatively, if your relay draws less than 50mA, you could invert the polarity of your op-amp, so it goes low rather than high when active, and drive the relay directly from it. (Still put a diode across the relay though.) Forget this, I was thinking of an LM311 - an LM393 is only rated at 16mA. :oops:

If your relay uses comfortably under 100mA, you could use a BC548 transistor.

Edit: I forgot to add, the diode is to protect the transistor from the high voltage spike that's generated when the relay switches off. It could easily damage a transistor.
 
Last edited:
Top