# LM393 comparator how to use?

Update:

All I want is, when the signal is higher than reference voltage, LEDs to light up(brightly).

For this, I was planning to use an op-amp as comparator (left circuit) but everybody told me to use a comparator instead. However there is some differences between operating of these two devices which confused me. I have drawn(on the right) the way I think it should be with a comparator after my readings. But I am not sure.

If you think I can use an op-amp comparator (left circuit), then I noticed that with GND connected to -Vcc terminal of this op-amp, the current flows through LEDs even the signal is lower than Vref.

I would expect the output to be 0 V and so no current flows through the LEDs. However this is not the case. You can also to explain this to me.

LM741 is not a must component, I know it is a very ancient op-amp but I am so stuck in these concepts that not able to choose another one. simulate this circuit – Schematic created using CircuitLab

Original question:

I am a little bit confused about the usage of LM393.

Is this comparator IC somehow different than opAmp comparators? For them, I was able to understand easily because the load was directly connected to output. So when V+ > V-, the output goes high and when V- > V+ output goes low. Just like below, But for this LM393, it looks different. I have read some:

If the voltage at the inverting terminal is greater than the voltage at the noninverting terminal, then the output of the op amp will be drawn down to ground, allowing electricity to flow from VCC to ground, turning on the output device. If the voltage at the inverting terminal is less than at the noninverting terminal, then the output of the op amp stays at VCC allowing no electricity to flow, since there is no electric potential difference across the output device.

This means that when the inverting terminal voltage is greater, the load connected to output can be powered on. When the noninverting terminal voltage is greater, the load connected to output will be powered off. So if an LED is connected to output, it will turn on when the inverting voltage is greater and turn off when the noninverting voltage falls below the inverting voltage.

I think I am confused about the pull-up part in LM393. In my design, I want to feed 2 leds in parallel from the output of the comparator, so I guess I will need 20+20 = 40mA in total from this output. Does LM393 give the opportunity to have this much current flow?

If so, where the reference voltage(which I want to compare with a signal and when signal is above that reference voltage the load gets current) be connected?

• Haven't you studied transistors yet? If not why not? read the datasheet i.stack.imgur.com/Jaqiv.png This Comparator has PNP inputs and NPN open collector output. Otherwise the difference logic is the same as an Op Amp.= with a low side switch but it can sense to Vee=0V with PNP inputs. Also learn how to draw schematics like datasheets – Tony Stewart Sunnyskyguy EE75 Dec 13 '19 at 18:02
• An opamp used as a comparator is not a comparator and a 741 running on a 9 volt rail makes an unreliable comparator circuit. – Andy aka Dec 13 '19 at 18:14
• I've taken the text out of your schematic and put it in your post where it can be read easily and copied into answers as quotes. – Transistor Dec 13 '19 at 19:42
• Boty ccts are Ok BUT use LM324 / LM358 - almost as ancient but single supply - more avalable and low cost. Nite that LM393 has an "open collctor" output – Russell McMahon Dec 14 '19 at 8:17
• @RussellMcMahon I have been trying LM324 but it gives me around 7 volts either in case its inverting input or non-inverting input is greater. I supply it via +9v and GND. I don't expect all the way to 0 V but at leas 1 V would be nice. I use LTspice and a model for LM324. – muyustan Dec 14 '19 at 8:29

Is this comparator IC somehow different than op-amp comparators?

They are similar in some ways. Comparators usually have the following advantages:

• They should have low input offsets so you get precise switching.
• Many work down the the negative rail on the inputs.
• They don't latch up. Op-amps can take some time to come out of saturation so this introduces a time delay.
• Many comparators have open-collector outputs so you can parallel them. This is useful in window-comparator applications.

This means that when the inverting terminal voltage is greater, the load connected to output can be powered on.

If V- > V+ then the output pulls low. A load connected between VCC and the output will turn on.

When the noninverting terminal voltage is greater, the load connected to output will be powered off.

For an open-collector comparator the output transistor will be turn off allowing the output to be pulled high.

So if an LED is connected to output, it will turn on when the inverting voltage is greater and turn off when the noninverting voltage falls below the inverting voltage.

No circuit schematic so we can't comment.

I think I am confused about the pull-up part in LM393. In my design, I want to feed 2 leds in parallel from the output of the comparator, so I guess I will need 20 + 20 = 40 mA in total from this output.

Why not put them in series and halve the current?

Does LM393 give the opportunity to have this much current flow?

Check the datasheet.

If so, where the reference voltage (which I want to compare with a signal and when signal is above that reference voltage the load gets current) be connected?

Use the inverting input for your reference. Usually a pair of resistors configured as a voltage divider will give you the reference voltage required.

• Use a comparitor for comparison.
• Use an op-amp for amplification. (But don't use a 741.)