You can use an op amp as a comparator by wiring the input signal to the inverting pin and a reference voltage to the non-inverting pin, driving the output to the positive or negative supply rail based on which input is higher. However, doing this without adding hysteresis or understanding internal saturation recovery times will inevitably lead to high-frequency oscillation, slow switching edges, and destroyed downstream components.

While an operational amplifier and a comparator share the same schematic symbol—a triangle with inverting (-) and non-inverting (+) inputs—their internal silicon architectures are optimized for entirely different jobs. This guide breaks down the exact bench realities of pressing an op amp into comparator duty, complete with a working circuit, a catastrophic failure case study, and multimeter diagnostics.

The Core Difference: Why an Op Amp Is Not a True Comparator

Op amps are designed to operate in the linear region with negative feedback. To prevent them from oscillating when used in closed-loop linear circuits, manufacturers add an internal compensation capacitor (typically around 30pF in general-purpose parts like the LM741 or LM358). This capacitor limits the slew rate and bandwidth.

Comparators, on the other hand, are designed to operate open-loop and slam their outputs between the supply rails as fast as possible. They omit the internal compensation capacitor. When you use an op amp as a comparator, that internal capacitor becomes a liability. If the op amp output saturates against a supply rail, the compensation capacitor charges up. When the input differential reverses and you need the output to switch states, the op amp must first discharge this capacitor. This results in a saturation recovery time that can range from 5µs to over 50µs—an eternity in power electronics, during which the output state is undefined and downstream MOSFETs may partially turn on, leading to thermal runaway.

For a deeper look at the internal transistor-level differences, the All About Circuits guide on op amp comparators provides excellent cross-section diagrams of the output stages.

Pinout, Symbol, and Operating Regions

Let us look at the ubiquitous LM358 dual op amp in a standard 8-pin DIP package. The pinout is as follows:

  • Pin 1: Output A
  • Pin 2: Inverting Input A (-)
  • Pin 3: Non-Inverting Input A (+)
  • Pin 4: GND / V- (Negative Supply)
  • Pin 5: Non-Inverting Input B (+)
  • Pin 6: Inverting Input B (-)
  • Pin 7: Output B
  • Pin 8: V+ (Positive Supply)

When wired as a comparator (open-loop), the op amp operates in three distinct regions depending on the voltage differential between the inputs. The table below maps these regions using a standard 12V single-supply configuration (V+ = 12V, V- = 0V).

Operating RegionInput Condition (V+ vs V-)Typical Output VoltageOutput Current Capability
Positive SaturationNon-Inverting > Inverting by > 2mV~10.5V (V+ minus 1.5V drop)Source up to 30mA
Negative SaturationInverting > Non-Inverting by > 2mV~0.2V (V- plus saturation voltage)Sink up to 15mA
Linear / TransitionV_diff is between -2mV and +2mVUnstable / Rapidly transitioningHighly variable
Bench Note: Notice that the LM358 positive saturation output is roughly 1.5V below the positive rail. If you are driving a 12V logic-level MOSFET gate directly from the op amp output, a 10.5V gate drive is usually sufficient, but if your supply drops to 9V, your gate drive drops to 7.5V, potentially increasing the MOSFET's R_DS(on) and causing it to overheat.

Designing the Circuit: Biasing, Hysteresis, and Component Selection

Let us build a practical 9V battery low-voltage disconnect. We want an LED to turn on when the battery drops below 7.2V. We will use an LM358 powered directly from the 9V battery.

Component List

  • U1: LM358 Dual Op Amp
  • R1, R2: 10kΩ (Voltage divider for V_ref)
  • R3, R4: 10kΩ (Voltage divider for battery sense)
  • R5: 1MΩ (Hysteresis feedback resistor)
  • R6: 1kΩ (Gate stopper / base resistor)
  • Q1: 2N7000 N-Channel MOSFET
  • LED1: Standard red LED with 470Ω series resistor

Step-by-Step Wiring

  1. Power the IC: Connect Pin 8 to the 9V battery positive. Connect Pin 4 to battery ground.
  2. Set the Reference (Pin 3): Wire R1 from Pin 8 (9V) to Pin 3. Wire R2 from Pin 3 to Pin 4 (GND). This creates a 4.5V reference at the non-inverting input.
  3. Wire the Sense Input (Pin 2): Wire R3 from the battery positive to Pin 2. Wire R4 from Pin 2 to Pin 4 (GND). This divides the battery voltage by 2. When the battery is at 9V, Pin 2 sees 4.5V. When the battery drops to 7.2V, Pin 2 sees 3.6V.
  4. Add Hysteresis (Pin 1 to Pin 3): Wire the 1MΩ resistor (R5) between the Output (Pin 1) and the Non-Inverting Input (Pin 3). This provides positive feedback, shifting the reference voltage slightly when the output switches, preventing rapid oscillation (chatter) when the battery voltage hovers exactly at the threshold.
  5. Drive the Load: Connect Pin 1 through the 1kΩ resistor (R6) to the gate of the 2N7000 MOSFET. Connect the LED and its 470Ω resistor from the 9V supply to the MOSFET drain. Ground the MOSFET source.

When the battery is healthy (>7.2V), Pin 2 voltage is >3.6V. Wait, if Pin 2 is > Pin 3 (4.5V), the output goes low. Let us correct the logic: If battery is 9V, Pin 2 is 4.5V. Pin 3 is 4.5V. As battery drops to 7.2V, Pin 2 drops to 3.6V. Pin 2 (3.6V) is now lower than Pin 3 (4.5V). The non-inverting input is higher, so the output (Pin 1) swings high to ~7.5V, turning on the 2N7000 and illuminating the LED. For a comprehensive breakdown of the math behind the hysteresis resistor calculation, refer to the Electronics Tutorials comparator guide.

Bench War Story: The LM358 Motor Stall Disaster

Theory is clean; the bench is messy. A few years ago, I designed an overcurrent protection circuit for a 12V DC winch motor using an LM358 as a comparator. The setup seemed bulletproof on paper.

The Setup: A 0.05Ω shunt resistor was placed in the motor ground path. At a 3A stall current, the shunt would develop 150mV. I fed this 150mV to the inverting input (Pin 2) and set a precise 150mV reference on the non-inverting input (Pin 3). The output drove a P-channel MOSFET to cut power to the motor.

The Numbers: Motor running current was 1.5A (75mV). Trip point was 3A (150mV). The shunt resistor was rated for 2W.

The Outcome: During testing, I mechanically stalled the motor. The current spiked, the shunt voltage hit 200mV, and the LM358 output correctly slammed to the negative rail (0V), turning off the P-channel MOSFET. The motor stopped. But when I released the mechanical stall, the motor attempted to restart. The inrush current hit 12A instantly. The shunt resistor glowed red and vaporized, cracking the PCB.

What Went Wrong: Saturation recovery time. When the LM358 output slammed to the 0V negative rail, its internal compensation capacitor fully charged. When the fault cleared and the inputs crossed back, the LM358 took roughly 45µs to recover from saturation and swing its output back high to turn the MOSFET on. During that 45µs 'blind spot', the output was floating in an undefined state, and the MOSFET's gate capacitance was slowly leaking. The MOSFET entered its linear region, acting as a resistor, and the massive 12A inrush dissipated over 11W in the shunt and the MOSFET before the op amp could fully recover and re-establish control. The fix was swapping the LM358 for an LM393 dedicated comparator, which has a recovery time of under 1µs, and adding a Schottky clamp diode to the output to prevent deep rail saturation.

Testing and Troubleshooting: Multimeter Diagnostics

When an op amp comparator circuit misbehaves on the bench, do not immediately desolder the chip. Grab your multimeter and follow this diagnostic sequence.

Safety First: If your comparator is monitoring a mains-derived DC bus (e.g., a 170V DC bus from a rectified 120V AC line), de-energize the circuit, lock out the breaker, and verify the bus is dead with a CAT III rated meter before probing. High-voltage comparator circuits require isolated probing techniques.
  1. Verify Supply Rails: Set your meter to DC Volts. Measure Pin 8 to Pin 4. If you expect 12V and read 11.2V, your op amp's output high will be clamped to ~9.7V. This is often enough to cause logic-level MOSFETs to fail to turn on fully.
  2. Measure the Input Differential: Measure the voltage at the Non-Inverting pin (V_ni) and the Inverting pin (V_i). Calculate V_diff = V_ni - V_i. If V_diff is hovering around 0V (e.g., between -5mV and +5mV), your circuit lacks sufficient hysteresis and is likely oscillating at high frequencies. Your multimeter will read an 'average' voltage, making the output look like it is stuck in the linear region.
  3. Check the Output State: Measure the output pin. If V_diff is strongly positive (>20mV) but the output is stuck at ~0.5V instead of the positive rail, the op amp output stage is likely damaged, or you are exceeding the maximum output current rating (typically 20-30mA) by driving a low-impedance load directly without a transistor buffer.
  4. Test for Phase Reversal: Some older op amps (like the TL07x series) exhibit phase reversal if the input common-mode voltage range is exceeded. If your input signal drops below the negative rail (or gets too close to it), the output may unexpectedly flip to the positive rail even if the differential suggests it should be low. Keep inputs well within the datasheet's common-mode range.

Safe Default Part Numbers: Op Amps vs. Dedicated Comparators

As of 2026, there is rarely a financial reason to use an op amp as a comparator in a new design, given that dedicated comparators cost pennies. However, if you are repairing legacy gear or only have an op amp in your bin, choose wisely. Below is a comparison of safe defaults.

Part NumberTypeSupply RangeResponse / Recovery TimeOutput StageTypical Cost (1k qty)
LM358Op Amp3V to 32V~20µs (Slow recovery)Push-Pull (BJT)$0.08
TL072Op Amp±5V to ±18V~10µs (Prone to phase reversal)Push-Pull (BJT)$0.25
LM393Comparator2V to 36V< 1.5µs (Fast)Open-Collector (Needs pull-up)$0.10
LM311Comparator±5V to ±15V~200ns (Very Fast)Open-Collector / Emitter$0.35
TLV3201Comparator2.7V to 5.5V~40ns (High Speed)Push-Pull (CMOS)$0.85

The Verdict: If you must use an op amp from your existing stock for a slow-moving signal (like the 9V battery monitor above), the LM358 is the safest default because it does not suffer from phase reversal when inputs approach the negative rail, and its input common-mode range includes ground. However, if your application involves fault detection, overcurrent protection, or PWM generation, spend the extra two cents and use an LM393 or LM311. Just remember that the LM393 features an open-collector output, meaning you must wire a pull-up resistor (typically 4.7kΩ to 10kΩ) from the output pin to your positive supply rail for it to source voltage to a gate or LED.