What Is a Comparator and How Is It Different From an Op-Amp?
Last updated 26 June 2026 · 8 min read
Direct Answer
A comparator is an analog IC with two inputs (non-inverting + and inverting −) and one output. When the non-inverting input voltage is higher than the inverting input, the output swings high (or releases its open-drain output). When the inverting input is higher, the output swings low (or pulls its open-drain output low). Unlike an op-amp, a comparator is optimised for switching between two output states as quickly as possible — not for linear amplification. Comparators have open-drain or open-collector outputs (requiring an external pull-up resistor), propagation delays in the nanosecond to microsecond range, and no phase margin requirement. Using an op-amp in place of a comparator is generally a poor substitution: op-amps have slow outputs, poor recovery from saturation, and internal compensation that causes them to oscillate when used open-loop.
Detailed Explanation
A comparator performs one function: it outputs a digital high or low depending on which of its two input voltages is greater. This simplicity makes it the right tool for threshold detection, zero-crossing detection, battery protection circuits, and analog-to-digital conversion — but it is not an op-amp, and the two devices must not be used interchangeably.
How a Comparator Works
The comparator has the same two-input, one-output topology as an op-amp: a non-inverting input (V+) and an inverting input (V−). The output state depends on which input is higher:
- V+ > V−: Output is high (or floating for open-drain, pulled high by external resistor).
- V+ < V−: Output is low (or pulled to GND by open-drain transistor).
The reference voltage (the threshold) is usually applied to the inverting input. The signal to be compared is applied to the non-inverting input. When the signal crosses the threshold, the output transitions.
Example: Low-battery indicator Connect V+ to a voltage divider that outputs 3.0V when the battery is fully discharged. Connect V− to a 3.3V reference. When the battery voltage drops below the threshold, V+ < V−, and the output pulls low — triggering an LED or a GPIO interrupt.
Open-Drain Output and Pull-Up Resistors
Unlike op-amps (which typically have push-pull output stages), most comparators use open-drain (or open-collector) outputs. The output stage is a single transistor:
- When the output should be low: the transistor turns on, pulling the output pin to GND.
- When the output should be high: the transistor turns off, leaving the output pin floating (high impedance).
An external pull-up resistor between the output pin and a supply voltage defines the logic-high level. This is crucial:
VCC (3.3V or 5V)
|
[R_pull-up] (typically 1 kΩ–100 kΩ)
|
OUT ────> Logic input / LED / MCU GPIO
|
Comparator output transistor (open-drain)
|
GND
The open-drain architecture has a key advantage: the output can be pulled up to a different voltage from the comparator's supply. A comparator powered from 3.3V can drive a 5V logic input with a 5V pull-up resistor without level translation logic.
Hysteresis (Schmitt Trigger)
A comparator with no hysteresis transitions every time the input crosses the single reference threshold. For slowly moving or noisy input signals, this causes rapid output toggling — chatter — that can latch up downstream logic or falsely trigger interrupts.
Hysteresis adds positive feedback: a small fraction of the output is fed back to the non-inverting input, offsetting the threshold based on the current output state.
The two thresholds become:
- Upper threshold (V_TH+): The threshold the input must cross for the output to switch low-to-high.
- Lower threshold (V_TH−): The threshold the input must cross for the output to switch high-to-low.
The hysteresis band = V_TH+ − V_TH−.
Adding hysteresis to an inverting comparator (V+ = threshold, V− = signal):
With pull-up resistor R_P connecting output to Vcc, and hysteresis resistor R_H from output to V+:
V_TH = (Vref × R_H + Vcc_or_GND × Rth) / (R_H + Rth)
where the output contribution is Vcc when high, 0V when low (for a CMOS output), or Vcc when high for open-drain with pull-up.
In practice, the hysteresis band should be at least 2–3× the peak-to-peak noise on the input. For a noisy temperature sensor with ±50 mV noise, set hysteresis to at least 150 mV.
Propagation Delay and Speed
Propagation delay is the time from when the input crosses the threshold to when the output reaches 50% of its final value. This determines the maximum signal frequency and triggering accuracy.
| Device | Output type | Propagation delay | Supply voltage |
|---|---|---|---|
| LM393 | Open-collector | ~1.3 µs | 2.0–36V |
| LM339 | Open-collector | ~1.3 µs | 3.0–32V |
| TLV6041 | Open-drain | ~220 ns | 1.8–5.5V |
| MAX9061 | Push-pull | ~9 ns | 2.4–5.5V |
For audio-frequency threshold detection or battery protection, the LM393 is adequate. For high-frequency zero-crossing detection or motor commutation, choose a fast comparator with nanosecond propagation delay.
Comparator vs Op-Amp: Key Differences
| Property | Comparator | Op-Amp |
|---|---|---|
| Intended use | Open-loop switching | Closed-loop linear amplification |
| Output type | Usually open-drain/open-collector | Usually push-pull |
| Propagation delay | Nanoseconds to microseconds | Microseconds to milliseconds |
| Output swing | Rail-to-rail not guaranteed | May be rail-limited |
| Recovery from saturation | Fast | Slow (op-amps saturate deeply) |
| Phase margin when open-loop | Not required | Internal compensation fights instability |
| Output voltage | Logic compatible (pull-up sets level) | Analog, limited swing |
The fundamental issue with using an op-amp as a comparator: Op-amps have internal frequency-compensation capacitors that limit how fast the output can respond. When driven open-loop, the op-amp's output slews slowly, the internal compensation causes ringing or oscillation near the threshold, and the recovery from saturation (when the output has been rail-to-rail for some time) is poor. For switching applications, use a comparator.
Practical Applications
Battery under-voltage lockout: A comparator monitors battery voltage through a divider. When voltage drops below a defined threshold, the output changes state and drives a P-channel MOSFET gate to disconnect the load. Hysteresis prevents the circuit from reconnecting and disconnecting rapidly as battery voltage oscillates near the threshold.
Zero-crossing detection: For a sine wave or PWM signal that swings through 0V, a comparator converts the analog waveform into a clean digital pulse train. The non-inverting input sees the AC signal (biased at mid-supply for single-supply circuits); the inverting input is biased to the crossing threshold. Each zero-crossing generates a rising or falling edge.
Window comparator: Two comparators share a common signal input. One comparator has its reference at the upper threshold; the other at the lower threshold. By connecting the outputs through logic, the circuit detects when the input is within a voltage window — useful for supply voltage monitoring ("power good" detection) or sensor out-of-range alarms.
For battery protection circuits, power management design, and product electronics that need threshold detection or monitoring circuits, Zeus Design's engineering team handles design through to validated prototype — contact Zeus Design.
Design Considerations
- Match the pull-up voltage to the connected logic level. Open-drain comparators allow the pull-up voltage to differ from the comparator supply. A 3.3V comparator can drive 5V logic with a 5V pull-up. Choose the pull-up supply voltage to match the input threshold of the receiving device.
- Select pull-up resistor value based on speed and current budget. Lower pull-up resistance gives faster output rise times (the output node charges through R_pull-up; lower R means faster charging) but increases power consumption — the comparator output transistor conducts through R_pull-up continuously when the output is low. For slow signals (≥1 kHz), 10 kΩ–100 kΩ pull-up is fine. For fast signals, use 1 kΩ–4.7 kΩ.
- Set hysteresis band to at least 2–3× the input noise amplitude. Hysteresis prevents chatter on noisy inputs. Too little hysteresis means the output still chatters for large noise. Too much hysteresis makes the circuit insensitive to small signal changes.
- Decouple the reference voltage thoroughly. Any noise on the reference input directly causes jitter or false triggering. Place a 100 nF ceramic capacitor directly at the reference input to GND. If the reference is generated by a voltage divider, add a 100 nF across the lower resistor.
Common Mistakes
- Connecting the comparator output to a logic input without a pull-up resistor. Without a pull-up, the open-drain output only pulls low; the high state is floating. Logic inputs seeing a floating output interpret it unpredictably — usually as random toggling at the logic threshold, triggering false interrupts.
- Adding hysteresis on the wrong input. Hysteresis must be applied to the input that receives the reference voltage (the input that creates the threshold), not to the signal input. Adding feedback to the signal input inverts the hysteresis effect.
- Using an op-amp as a comparator in a circuit with fast signal edges. Op-amps recover slowly from saturation. After being driven to a supply rail, an op-amp's output may take tens of microseconds to return to the linear region. For any application requiring reliable switching at frequencies above a few hundred hertz, use a dedicated comparator.
- Ignoring the common-mode input range. Comparators specify a common-mode input voltage range. Applying a voltage outside this range causes the output to behave unpredictably — sometimes inverting or locking up. For single-supply comparators, verify that both inputs are within the specified common-mode range at all operating conditions.
Frequently Asked Questions
- Why does a comparator need a pull-up resistor?
- Most comparators have an open-drain (or open-collector for BJT-output devices) output stage. Open-drain means the output transistor can only pull the output node low (to GND) — it cannot actively drive the output high. When the comparator output is in the high state, the transistor is switched off and the output is floating (high impedance). An external pull-up resistor connects the output node to the supply voltage; this pulls the node to a defined high level when the transistor is off. Without the pull-up, the output only toggles between low and floating — floating is not a logic level and will cause undefined behaviour in any circuit connected to the output. Pull-up values from 1 kΩ to 100 kΩ are typical; lower values give faster rise times but increase power consumption.
- What is hysteresis and why is it added to a comparator circuit?
- Hysteresis adds a threshold offset that makes the switching threshold different depending on which direction the input is moving. A comparator without hysteresis has a single threshold: the output switches every time the input crosses it. For a noisy input signal, this causes rapid, repeated output transitions ('chatter' or 'chattering') as the signal oscillates around the threshold. Hysteresis solves this by creating two distinct thresholds: a higher threshold for the low-to-high transition, and a lower threshold for the high-to-low transition. The gap between the two thresholds (the hysteresis band) must be larger than the amplitude of the noise on the input for clean switching. A comparator circuit with hysteresis is commonly called a Schmitt trigger.
- Can I use an op-amp as a comparator?
- An op-amp can function as a comparator in simple circuits, but it is generally a poor choice. Op-amps are internally compensated for stability in closed-loop linear circuits; without feedback they are open-loop, and the compensation capacitor causes the output to slew slowly. A general-purpose op-amp like the LM358 has a slew rate of 0.5 V/µs and a propagation delay of several microseconds — many times slower than a purpose-built comparator. Op-amps also have push-pull outputs that can conflict with external logic if a pull-up is accidentally applied. Dedicated comparators such as the LM393 (open-drain, 1.3 µs) or TLV6041 (open-drain, 220 ns) are a better fit for threshold detection. Use an op-amp as a comparator only in non-critical, low-speed applications where the output switching time doesn't matter.
References
Related Questions
What Is an Op-Amp (Operational Amplifier)?
An op-amp is a high-gain differential amplifier whose behaviour is determined by external feedback. Covers open-loop gain, virtual short, GBW, and applications.
What Are Inverting and Non-Inverting Op-Amp Amplifier Configurations?
The inverting amplifier sets gain as −Rf/Rin with phase inversion; non-inverting sets 1+Rf/Rin. Formulas, comparison table, and design rules.
What Is a Voltage Divider and How Does It Work?
A voltage divider splits a voltage using two resistors in series. Covers the Vout formula, loading effect, Thevenin equivalent, and when not to use one.
What Is an ADC (Analog-to-Digital Converter) and How Does It Work?
An ADC converts analog voltages to digital numbers. Covers resolution, LSB, sampling rate, Nyquist, SAR vs sigma-delta architectures, and anti-aliasing filters.
What Is a Battery Protection Circuit?
A Li-ion protection circuit prevents overcharge, overdischarge, overcurrent, and short circuits using a dedicated IC and back-to-back MOSFETs.
How Do You Design an Active Filter with an Op-Amp?
Active filters use op-amps for frequency roll-off without inductors. Covers Sallen-Key, MFB topologies, Butterworth response, and ADC anti-aliasing.