Analog Electronics

Comparator Circuit

The single-bit ADC — open-loop op-amp picking between two voltages

A comparator outputs HIGH or LOW depending on which of two inputs is larger. It is the analog-to-digital decision element inside every ADC, zero-crossing detector, and threshold circuit on Earth.

  • TopologyOp-amp open-loop or dedicated IC
  • Open-loop gain10^5 to 10^6 (100–120 dB)
  • Output+V_sat when V+ > V-, else -V_sat
  • Slew rate50–300 V/μs typical (LM393 vs LT1016)
  • Propagation delay10 ns (fast) to 1 μs (general-purpose)
  • ApplicationsADCs, zero-crossing, threshold, level detect

Interactive visualization

Press play, or step through manually. The visualization is yours to drive — try it before reading on.

Open visualization fullscreen ↗

Watch the 60-second explainer

A condensed visual walkthrough — narrated, captioned, under a minute.

The simplest analog decision

Every analog system eventually has to answer a binary question. Is the battery above the threshold for the charger to switch off? Is the room temperature above the setpoint? Is the audio signal crossing zero? Every one of those decisions is a comparator at heart — two voltages in, one logic-level decision out.

The comparator is the smallest, simplest, fastest analog-to-digital conversion possible: a one-bit ADC. Take an op-amp with no feedback. Apply V_signal to the non-inverting (+) input. Apply V_ref to the inverting (-) input. The output sits at one of the two supply rails depending on which input is higher:

V_out = +V_sat   if V+ > V-
V_out = −V_sat   if V+ < V-

Open-loop gain A ≈ 100,000
|V+ − V-| > V_sat/A ≈ 50 μV   →   output saturates

For practical inputs, the comparator is a digital decision.

That's the whole comparator. Two inputs, one output, a single bit of answer in nanoseconds-to-microseconds. The rest of this article is variations on the theme.

Inverting vs non-inverting

You can wire a comparator with the signal on either input. The polarity of the output flips accordingly:

   Non-inverting comparator           Inverting comparator
   ──────────────────────              ──────────────────
       ┌──────────                       V_ref ──┐
       │                                          │
   V_sig → + ┐                             ┌── − ┘
              ├── V_out                    │
   V_ref → − ┘                             ├── V_out
                                            │
                                       V_sig → +
                                                │
                                            ────┘

   V_out HIGH when V_sig > V_ref          V_out HIGH when V_ref > V_sig

Use non-inverting when you want "output HIGH means signal exceeded reference" — battery-low warnings, over-temperature trips, over-voltage protection. Use inverting when the convention is reversed — for instance, "alarm output HIGH means signal dropped below threshold" in undervoltage lockout circuits.

Worked example: 9 V battery low warning

A handheld device runs from a 9 V battery and should warn the user when voltage drops below 6.5 V. Design an LED to come on at V_bat < 6.5 V.

Reference. Generate 6.5 V from a 5 V regulated rail plus a divider, or use a precision shunt reference like the LM4040-2.5 (2.5 V reference) and scale. For simplicity, use a Zener: a 6.2 V Zener in series with 1 kΩ to V_bat gives a stable 6.2 V reference (close enough for an indicator).

Comparator. LM393 — two open-collector comparators in an 8-pin DIP, single 3–36 V supply, propagation delay 1.3 μs typical. Wire V_bat through a 100 kΩ : 100 kΩ divider into the (+) input (so the comparator sees V_bat / 2 = 3.25 V at 6.5 V). Apply 3.1 V (from a divider on the 6.2 V Zener) to (-).

Output. Pull-up resistor 10 kΩ from output to V_bat, then output drives an indicator LED through 1 kΩ to ground. When V_bat > 6.5 V, comparator's (+) wins, output is HIGH (released, pulled up by 10 kΩ), LED is OFF. When V_bat dips below 6.5 V, output goes LOW, LED turns ON.

Six components: comparator, two divider pairs, a Zener, a pull-up, an LED. Add a Schmitt-trigger-style positive feedback resistor for hysteresis (otherwise the LED flickers right at threshold). Cost: under a dollar.

Comparator family overview

PartTopologyProp delayOutputNotes
LM393 / LM339Bipolar, open-collector1.3 μsO.C. (needs pull-up)10¢, single-supply 3–36 V, the workhorse
TLV3201CMOS, push-pull40 nsRail-to-railSmall, fast, low-power, runs to 5.5 V
LT1011Bipolar200 nsStrobe + complementPrecision, low-offset, ±15 V supplies
LT1016Bipolar, ECL/TTL10 nsComplementary TTLUHF speed, GHz-bandwidth analog front-ends
MAX9201CMOS, push-pull7 nsRail-to-railSingle-supply 3 V, low-jitter clocking
TLV7011Nano-power CMOS3 μsPush-pull500 nA quiescent, IoT battery monitors

Zero-crossing detection

Connect the inverting input to ground (or a virtual ground in single-supply systems) and the signal to the non-inverting input. The comparator output flips every time the signal crosses zero. Two common uses:

AC mains synchronisation. You want a triac dimmer to fire at a controlled angle relative to the mains zero-crossing. Run the mains through a high-value voltage divider into a comparator referenced to ground, and the comparator emits a 60 Hz (or 50 Hz) digital pulse train that the microcontroller uses as a phase reference. 1 MΩ : 100 kΩ divider gives ±11 V at the comparator from ±120 V mains — comfortably within input range.

Frequency measurement. Want to count the frequency of an audio or RF signal? Run it through a comparator with V_ref = 0, count rising edges per second on the output. For accurate measurement add hysteresis (a Schmitt trigger) to ignore noise around the crossing.

Comparators inside every ADC

Open the silicon of any analog-to-digital converter and you find comparators. The number and arrangement defines the topology:

  • Flash ADC. 2^N − 1 comparators in parallel, each tied to a different reference from a resistor ladder. The thermometer code is encoded to N-bit binary. 8-bit flash = 255 comparators, conversion in one clock cycle, GHz sample rates. Power-hungry but unbeatable for speed (oscilloscopes, RF receivers).
  • SAR ADC. One comparator, one DAC, one binary-search controller. The DAC walks through trial voltages; the comparator decides each bit. N comparisons per N-bit conversion. Microcontroller ADCs and most general-purpose data acquisition.
  • Sigma-delta ADC. One comparator inside a noise-shaping feedback loop oversamples at MHz rates and decimates digitally. 16- to 24-bit resolution at audio bandwidths.
  • Pipeline ADC. A cascade of low-resolution flash stages, each digitising part of the answer and passing the residue forward. 12–16 bits at 100 MSa/s+. Bridges flash speed and SAR resolution.
  • Time-interleaved. N parallel ADCs sampling at offset phases. Multiplies effective rate by N; used in 100+ GSa/s scopes and high-end RF.

Every ADC is, fundamentally, a clever arrangement of comparators feeding a digital reconstruction engine. The comparator is the irreducible building block of the analog-to-digital boundary.

Why not just use an op-amp?

An op-amp run open-loop will behave like a comparator. It is also a bad idea. The differences add up:

  • Speed. Op-amps are compensated for unity-gain stability with negative feedback, which means heavy internal compensation that limits open-loop slew rate. A μA741 op-amp used as a comparator has a 0.5 V/μs slew rate; the same silicon area as a comparator (LM393) gives 50 V/μs.
  • Phase reversal. Many op-amps invert their output when an input exceeds the common-mode range — exactly the wrong behaviour for a comparator under saturation. Comparators specifically guarantee no phase reversal.
  • Recovery time. An op-amp pushed into saturation may take many microseconds to come back. Comparators are designed for cycle-after-cycle saturation operation.
  • Output format. Op-amps are push-pull and clamped within their supply rails. Comparators offer open-collector for level translation, or push-pull rail-to-rail for direct logic driving.
  • Supply current spikes. During op-amp output transitions through the linear region, the output stage draws large quiescent currents — wasted heat and PCB-rail noise. Comparators minimise this.

Common pitfalls

  • Forgetting the pull-up. Open-collector comparators do nothing without an external pull-up. Spec the pull-up for speed: τ = R_pullup × C_load. 10 kΩ × 20 pF = 200 ns rise time. Need faster? Use 1 kΩ — at the cost of more average current.
  • Chatter at threshold. Without hysteresis, a noisy input crossing the threshold flips the output many times. Add positive feedback (a Schmitt configuration) any time the input is slow or noisy.
  • Common-mode range violation. The LM393 inputs must stay between V- and V+ − 1.5 V. Drive an input above that and the output may go the wrong way — phase reversal. Use a rail-to-rail comparator if you need inputs near either supply.
  • Long unterminated traces. A fast comparator output edge on a long PCB trace radiates and rings. Series-terminate (33–100 Ω) to match the trace impedance.
  • Power-supply bypassing. Fast comparators slew large currents through their output stage at every transition. Skipping the 100 nF supply bypass at the IC pins is asking for jitter and false triggers.

Where comparators show up

  • Battery management. Every smartphone, laptop, EV BMS uses comparators for over/under-voltage protection, low-battery warnings, and threshold-based charge termination.
  • Light/dark detectors. Photodiode + comparator + reference triggers outdoor lights at dusk, photographic flash-sync circuits, opto-counters.
  • Power-good and fault detection. Every regulator IC has internal comparators monitoring its own outputs and shutting down on fault.
  • Window detectors. Two comparators with inverted polarity form an "is V_in between V_lo and V_hi" check — fundamental for ATE limit testing, sensor calibration, line-monitoring.
  • Relaxation oscillators. An op-amp comparator with R-C feedback generates a square wave; the heart of the 555 timer, every Schmitt oscillator, and many cheap clock generators.
  • Communications. Optical receivers, USB SerDes, Ethernet PHY decoders — wherever an analog signal must produce a digital bit decision per symbol, a comparator does the work.

Historical context

Comparators predate ICs. Vacuum-tube comparators built from regenerative thyratrons appeared in radar and ballistic-computer designs of the 1940s. The first solid-state monolithic comparator, the μA710, was designed by Bob Widlar at Fairchild in 1965 — a year before his groundbreaking μA709 op-amp. The LM311 (1973) added strobe and emitter-follower outputs; the LM393 dual and LM339 quad versions, debuting in 1980, became the dominant industry-standard comparators and are still produced today essentially unchanged.

Modern parts have pushed every metric: TLV3201 sub-50-ns delay from a single 3 V supply; LT1016 at 10 ns ECL-output speed; precision comparators (LTC1440) with 50 μV offset for instrumentation. The comparator remains one of the oldest, simplest, and most-shipped analog building blocks in electronics.

Frequently asked questions

What's the difference between a comparator and an op-amp?

Mechanically, very little — both are differential amplifiers with very high open-loop gain. The difference is intent and optimisation. An op-amp is designed to be used with negative feedback (linear region matters); a comparator is designed to be used open-loop, slamming between rails (transition speed matters). Comparators add features like open-collector outputs, asymmetric supplies, and fast slew rates that op-amps lack. An op-amp used as a comparator works but is slow (microseconds vs nanoseconds) and may suffer phase reversal or supply spikes when its inputs saturate.

Why is the output always at one of the supply rails?

Open-loop gain A is typically 10^5 to 10^6. Output = A × (V+ − V-) saturates the moment |V+ − V-| exceeds V_supply / A — typically microvolts. Any real-world input difference larger than that pushes the output hard against +V_sat or -V_sat. There is no linear region in normal operation; the comparator is binary by intent.

What is slew rate and why does it matter for comparators?

Slew rate is the maximum rate of change of the output voltage, in V/μs. The LM393 (low-cost general-purpose) hits 50 V/μs typical; the LT1016 (fast precision) reaches 300 V/μs and propagation delays of 10 ns. Slew rate sets how fast the comparator can swing between rails — relevant for clocking ADCs, detecting fast pulses, or driving digital logic. If your decision-rate × output-swing exceeds the slew rate, the comparator misses transitions.

What is an open-collector output and why do comparators use it?

An open-collector (or open-drain) output has a transistor that can only pull the output LOW; the HIGH state requires an external pull-up resistor to whatever rail you want. This lets the comparator output match a different voltage from its own supply — you can run an LM393 from ±12 V supplies and pull its output up to 3.3 V to drive a microcontroller. It also lets you wire-OR multiple comparator outputs together (parallel pull-down, single pull-up): the output is HIGH only if all comparators agree the input is below threshold.

How does a comparator make a zero-crossing detector?

Connect the signal to V+, ground to V-. Whenever the signal is above zero, V_out = +V_sat; whenever below, V_out = -V_sat. The output flips at every zero crossing. Add a transistor or level-shifter to drive your microcontroller's interrupt input, and you have a sub-microsecond detector. Real-world applications: AC mains synchronisation for triac dimmers, frequency measurement of audio signals, beat detection in sonar.

How is a comparator used inside an ADC?

Every ADC topology uses comparators as its fundamental decision element. A flash ADC has 2^N − 1 comparators in parallel, each comparing the input to a different reference; the thermometer code from their outputs is encoded to N-bit binary in one clock cycle (8-bit flash = 255 comparators). A SAR ADC has one comparator and steps through a binary-search of trial voltages from a DAC. A sigma-delta ADC has a comparator inside a noise-shaping feedback loop. Pipeline ADCs cascade many smaller flashes. Regardless of architecture, every analog-to-digital conversion is built on the comparator's single-bit decision.

Should I use a real comparator or a generic op-amp?

Always use a real comparator if speed, power, or output format matters. Op-amps used as comparators can exhibit phase reversal (output briefly goes to the wrong rail when inputs exceed common-mode range), have long recovery times from saturation (microseconds, sometimes), suffer supply-current spikes during transitions, and lack open-collector outputs. The few-cents premium of an LM339 (quad) or TLV3201 (rail-to-rail) over a quad op-amp pays off in robustness alone.