5
\$\begingroup\$

I'm trying to test a comparator circuit with LM393P. It works as expected until the input values are close to each other. In that case, the output strangely oscillates. I searched about it and it was recommended to put a high impedance positive feedback, so I put a 1M ohm resistor.

It's my first time working with comparators, so maybe I'm overlooking something.

Below are the schematics and the output signal in Picoscope.

schematic

simulate this circuit – Schematic created using CircuitLab

enter image description here

\$\endgroup\$
5
  • \$\begingroup\$ What is the purpose of R4? Also, shouldn't one of R1 pins be in GND instead of the input of your comparator? \$\endgroup\$ Apr 12, 2023 at 14:54
  • \$\begingroup\$ Adding resistor creates positive feedback and adds some hysteresis. You should look at positive feedback of operational amplifier and search formulas for hysteresis window. Also i suggest you to look at input signal (power). Maybe it's noisy. And be aware if you using comparator to drive highly capacitive load. And this R4 here looks questionable. Is TL081 the part you are really using? \$\endgroup\$ Apr 12, 2023 at 14:56
  • \$\begingroup\$ yeah, I have doubts regarding that schematic: If there's really a 10 kΩ pull up on the output (why?), that basically renders R5 functionless, unless R1 is very large. \$\endgroup\$ Apr 12, 2023 at 14:56
  • 2
    \$\begingroup\$ It's a LM393 comparator, not a TL081 op-amp. Comparators have open collector output, hence R4 is required. \$\endgroup\$
    – Justme
    Apr 12, 2023 at 14:58
  • \$\begingroup\$ You are right, it was my mistake. Already corrected it. I forgot to change the model in the schematics from the default. I apologize! \$\endgroup\$
    – ludicrous
    Apr 12, 2023 at 15:29

3 Answers 3

10
\$\begingroup\$

From the data sheet you can see what range of voltages are acceptable for your inputs: -

enter image description here

And, the mistake you have made is connecting the non-inverting input to the positive rail via R1: -

enter image description here

And usually, when this happens on older comparators or op-amps, you get strange phase shift effects that can cause the device to turn into an oscillator when you also have a positive feedback connection (as you do).

It's called unwanted op-amp signal inversion or OP AMP OUTPUT VOLTAGE PHASE-REVERSAL.

You should keep two volts clear of the top rail for both inputs. With your circuit as it is currently drawn (and ignoring the incorrect chip reference), you are at the absolute maximum limit on the non-inverting input and all bets are off when this happens.

\$\endgroup\$
3
  • 1
    \$\begingroup\$ Your answers are always so clear and understandable! It makes sense now. So there is no way to improve the precision to the best of what the LM393 can do. I should just find a more precise comparator if I want the comparison to be reliable within the realm of mV \$\endgroup\$
    – ludicrous
    Apr 12, 2023 at 15:36
  • 6
    \$\begingroup\$ It's not the precision that's the problem; it's the voltage input range that the device can handle. Your circuit, even with an ideal op-amp will provide asymmetrical hysteresis and is that what you want? If you are looking for a precise comparator then, inevitably, as the inputs get close you will get output perturbations without hysteresis. With hysteresis you get accuracy but only as the signal rises. \$\endgroup\$
    – Andy aka
    Apr 12, 2023 at 15:41
  • 1
    \$\begingroup\$ @Ludicrous, I might also add that a comparator's differential input voltage resolution (not "precision") is limited by its input offset voltage specification, V_IO. See also §3.2 "Input Offset Voltage - V_IO (V_TRIP)" in STMicroelectronics Application Note AN4071 (document ID #022939, Rev 1). (NB: It's possible to have high resolution with poor precision. See also: meettechniek.info/measurement/accuracy.html) \$\endgroup\$ Apr 16, 2023 at 23:06
2
\$\begingroup\$

First of all, do not confuse comparators with operational amplifiers. Comparators only give an output of either VSS(GND) or VCC(6V in your case). They are used to compare their inputs, not to amplify like an operational amplifier does. You have used feedback in your schematic, which is usually used when a op-amp is used.

Other than that, based on your question, from LM393P's datasheet:

input offset voltage

You can see the offset voltage between the inputs has a maximum value of up to 5mV. If your input signals are not clean from ripple (which they usually are not), you might notice that getting your inputs closer to each other even more than 5mV, your output will oscillate more.

Oscillation also might happen if you bias your inputs with voltage(s) that are close to rail voltages (VCC/GND).

\$\endgroup\$
3
  • 4
    \$\begingroup\$ That's positive feedback, which introduces hysteresis to comparator circuits. IOW -- the correct approach. \$\endgroup\$ Apr 12, 2023 at 15:24
  • 4
    \$\begingroup\$ You said: You have used feedback in your schematic, which is usually used when a op-amp is used. <-- many, many comparator circuits use positive resistive feedback and, any op-amp using positive resistive feedback is being asked to behave as a comparator. If you meant negative feedback then you might of misread the circuit. \$\endgroup\$
    – Andy aka
    Apr 12, 2023 at 16:00
  • \$\begingroup\$ @Andyaka I didnt know comparators use feedback! Thank you. Yes I meant positive feedback (R4 resistor). \$\endgroup\$ Apr 12, 2023 at 20:19
1
\$\begingroup\$

Comparators do that. That's why there usually is some positive feedback to have separate high and low going thresholds, so it does not oscillate.

\$\endgroup\$
2
  • 2
    \$\begingroup\$ But am I not doing that in my circuit? \$\endgroup\$
    – ludicrous
    Apr 12, 2023 at 15:24
  • \$\begingroup\$ @ludicrous You are because just added a resistor from output to positive input, so it has a small effect on positive input voltage. \$\endgroup\$
    – Justme
    Apr 12, 2023 at 16:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.