Comparators (more properly voltage comparators) are electronic devices which compare two input voltages and provide a digital output indicating which one is higher. They are one of the most common interface devices between the analog and digital domains.
Comparators share a lot of features with op amps, not least using the same schematic symbol, which makes it easy to overlook the very important differences between the two. I know that under some circumstances an op amp can be pressed into service as a comparator, but I want to use this article to show that they are actually two very different animals and that you should use the appropriate device for the application.
The main differences between op amps and comparators stem from their operating modes. Op amps are designed to be used with negative feedback and operate in the linear region. If the output of an op amp is saturated to one or other of the supply rails there is probably something wrong with your circuit. The inverting and non-inverting inputs of an op amp are normally at the same voltage (or at least within a few millivolts of each other) due to the effect of feedback.
Comparators on the other hand live life at the extremes. The inverting and non-inverting inputs can be at widely different voltages and the output should normally be either fully high or low. In fact we want a comparator output to spend an absolutely minimum amount of time in transition between the two states. Comparators straddle the analog/digital divide while op amps are firmly in the analog camp.
These different use cases push comparator designers to make very different design choices. The first of these is to do with speed. Op amps generally have internal frequency compensation capacitors which introduce a dominant pole that helps keep the op amp stable with feedback. Without this the op amp is liable to oscillate uncontrollably. This compensation introduces a time delay between a change occurring at the input and the resulting change in the output.
Comparators are not usually used with feedback so do not need to have compensation capacitors meaning their outputs can respond to changes at the input much faster than op amps. This is characterised by a response time parameter which is the time taken for a differential signal change at the output to result in a change in the output – including both propagation delay and output slew rate.
For example, the classic low-cost jellybean comparator, the LM311, has a response time of around 165ns as shown in Figure 1. Faster devices are available with many getting down to single digit nanosecond and a few below even that. Compare this with the similarly common LM324 quad op amp; with its slew rate of 0.5V/µs it will take 10µs to move its output from zero to 5V.

These diagrams, extracted from the LM311 data sheet, show the response time of the comparator to a change in differential-mode voltage at the inputs. They show that the output changes state within about 165ns of the input changing. This fast response is possible because comparators do not include compensation capacitors like most op amps.
Another big difference between op amps and comparators can be seen in the output stage. A comparator’s output is intended to interface with digital circuitry, so its output swing is designed to be constrained to the logic levels it is driving. These are likely to be different from the analog input voltage range.
Comparator outputs come in a variety of configurations. Figure 2 shows a few of the more common ones. Some comparators, like the LM311 mentioned above, have a floating output (either BJT or MOSFET). These can be used with an external pull-up to or pull-down resistor to interface to the logic circuitry. Others, usually those designed for single-supply operation, use an open collector or open drain configuration. Yet others have internal CMOS (or more rarely TTL) drivers and a separate power pin(s) for the logic supply.

Comparators are available with a variety of output configurations designed to interface with digital circuitry. The examples at the top are usually used with pull-up or pull-down resistors. The comparators at the bottom have CMOS logic outputs and require a separate logic power supply.
It’s worth pointing out that you don’t have to drive logic with a comparator. Many can drive LEDs or relays directly. The LM311 for example can sink up to 100mA so can drive a wide variety of loads. Don’t forget to add a freewheeling diode if your load is inductive!
Comparator inputs are similar to op amp inputs in that they use a differential pair and therefore have a similarly limited common-mode voltage range. For example, the LM311’s common-mode range extends from 0.5V above V– to 2V below V+. Similarly, comparators have an input offset voltage and input bias current that may be relevant for your application. Like op amps, some comparators have an input offset adjust capability – the LM311 is a case in point.
A differential pair’s input bias currents change slightly as the differential-mode voltage changes. This is not usually an issue with op amps as the differential-mode voltage is usually very close to zero. In the case of comparators this phenomenon can cause small changes in the input voltage when the differential voltage changes polarity. Since this corresponds with the output switching, it can cause multiple transitions when there should be just one. Keeping the input source impedances low can be a big help in eliminating this problem, as can adding a bit of hysteresis to the comparator.
I hope this has helped clarify some of the differences between comparators and op amps and helped you determine when you should use each part.
Bibliography
Horowitz, Paul, and Winfield Hill. The Art of Electronics. Third edition, 11th printing, with Corrections. Cambridge New York, NY: Cambridge University Press, 2017.
Co, Rohm. “Op-Amp/Comparator Application Note,” 2011. https://fscdn.rohm.com/en/products/databook/applinote/ic/amp_linear/common/opamp_comparator_tutorial_appli-e.pdf.
Sponsor this ArticleAndrew Levido (andrew.levido@gmail.com) earned a bachelor’s degree in Electrical Engineering in Sydney, Australia, in 1986. He worked for several years in R&D for power electronics and telecommunication companies before moving into management roles. Andrew has maintained a hands-on interest in electronics, particularly embedded systems, power electronics, and control theory in his free time. Over the years he has written a number of articles for various electronics publications and occasionally provides consulting services as time allows.
