Fork me on GitHub

Project Notes

#803 LM339 Inverting Comparator

Testing the LM339 when used as an inverting comparator, and the effect of positive feedback (hysteresis) to prevent oscillations at the crossing point.

Build

Notes

In LEAP#802 I covered the LM339 non-inverting comparator configuration. Let’s now cover the inverting configuration. It is trivial to use in its basic comparator role:

lm339-basic-comparator-schematic

In this project however, I’m going to test the effect of adding positive feedback (hysteresis) to prevent oscillations at the crossing point.

lm339-inverting-schematic

See LEAP#802 LM339 Non-inverting Comparator for more details and general design recommendations concerning the LM339.

Circuit Design - Without Feedback

First let’s try this without feedback/hysteresis:

  • input is a sine wave from a signal generator, 4V peak-peak, 2.5V offset
  • inverting comparator configuration
    • i.e. input signal goes to IN-, reference to IN+
  • input clamps to prevent negative voltage excursions
  • all unused pins tied to ground
  • adjustable Vref

Designed with Fritzing: see InvertingComparator.fzz.

bb

schematic

Setup on a breadboard:

bb_build

This is actually working quite well. Looking at some oscilloscope traces where:

  • CH1 (Yellow) - input signal
  • CH2 (Blue) - output signal
  • CH3 (Red) - input signal at IN1-, after input attenuation resistor (Rin)
  • CH4 (Green) - Vref

At 10Hz, things look good at the macro scale:

test1-10hz

But if we zoom in on the falling edge, we see ringing:

test1-10hz-falling

Same for the rising edge:

test1-10hz-rising

Bumping up the input frequency to 50kHz, we no longer have output oscillation, although the slew is starting to show in the output:

test1-50khz

Zooming in on the falling edge, still looking good:

test1-50khz-falling

Circuit Design - With Feedback

Adding feedback:

  • circuit as before
  • adding adjustable positive feedback (hysteresis) with a 500kΩ pot

Designed with Fritzing: see InvertingComparatorWithFeedback.fzz.

bb

schematic

Setup on a breadboard:

bb_build

Let’s take a look at the results.

With minimum feedback (Rfb = 500kΩ) at 10Hz, things still look good at macro scale, although I could probably do with a much larger Rfb compared to Vref voltage divider in order to minimise the hysteresis.

test2-10hz-fbmin

Zooming in on the rising and falling edges, we can see the ringing is no longer present:

test2-10hz-fbmin-rising

test2-10hz-fbmin-falling

At 50kHz, things are still good without ringing:

test2-50khz-fbmin

As we crank up the feedback (reducing Vfb), we shift the output trigger point, effectively introducing a phase shift.

test2-50khz-fbmax

Conclusion

With an inverting comparator configuration, ringing is seen on rising and falling edges especially at low frequencies. At higher frequencies, the problem can disappear.

Adding a little positive feedback (hysteresis) fixes the problem. If too much feedback is introduced, there can be significant hysteresis in the output, effectively a phase shift.

Credits and References

About LEAP#803 LM339Comparator

This page is a web-friendly rendering of my project notes shared in the LEAP GitHub repository.

Project Source on GitHub Return to the LEAP Catalog
About LEAP

LEAP is my personal collection of electronics projects - usually involving an Arduino or other microprocessor in one way or another. Some are full-blown projects, while many are trivial breadboard experiments, intended to learn and explore something interesting.

Projects are often inspired by things found wild on the net, or ideas from the many great electronics podcasts and YouTube channels. Feel free to borrow liberally, and if you spot any issues do let me know or send a pull-request.

NOTE: For a while I included various scale modelling projects here too, but I've now split them off into a new repository: check out LittleModelArt if you are looking for these projects.

Project Gallery view the projects as an image gallery Notebook reference materials and other notes Follow the Blog follow projects and notes as they are published in your favourite feed reader