A comparator with op amp configuration forces a high-gain amplifier into open-loop saturation to output a binary high or low signal based on two input voltages. When the non-inverting input (IN+) exceeds the inverting input (IN-), the output swings to the positive rail; when IN- is higher, it swings to the negative rail. However, there is a massive practical difference between wiring a standard operational amplifier (like the LM358) in open-loop and using a dedicated comparator IC (like the LM393). Standard op-amps are designed to stay in their linear region and will suffer from slow recovery times and phase reversal if driven into saturation. Dedicated comparators are optimized for fast switching and feature open-collector or push-pull outputs designed to interface directly with logic families.

Symbol, Pinout, and Operation Regions

Before wiring any board, you need to understand the schematic symbol and the physical pinout. The comparator symbol is identical to an op-amp: a triangle with two inputs and one output. The IN+ (non-inverting) and IN- (inverting) inputs sit on the flat left side, while the OUT pin is on the pointed right side. Power pins (VCC and VEE/GND) are typically omitted in schematic symbols but are critical on the physical IC.

For a standard 8-pin DIP package like the LM393 (dual) or LM311 (single), the pinout is generally:

  • Pin 1 / 7: Output A / Output B (or OUT for single)
  • Pin 2 / 6: IN- A / IN- B
  • Pin 3 / 5: IN+ A / IN+ B
  • Pin 4: VEE or GND
  • Pin 8: VCC
Bench Tip: Always check the specific datasheet. The LM311 single comparator includes additional pins for "Balance/Strobe" (Pins 5 and 6) which must be bypassed to ground via a 10nF capacitor or left floating depending on the application, otherwise the output will chatter.

Unlike linear amplifiers, comparators operate almost entirely in saturation. The table below defines the operation regions and typical electrical limits for a standard 5V logic-level comparator setup.

Table 1: Comparator Operation Regions and Electrical Limits (VCC = 5V)
Operation Region Differential Input (V_IN+ - V_IN-) Output State Typical Output Current Output Voltage (V_OUT)
Positive Saturation > +5 mV High (Hi-Z if Open-Collector) 0 mA (Pull-up sources current) 5.0V (via pull-up)
Linear Transition -5 mV to +5 mV Transitioning Varies Varies (ns/µs transition)
Negative Saturation < -5 mV Low (Active Sink) 16 mA (Max sink) ~0.2V (V_CE sat)
Input Overvoltage > VCC + 0.3V Undefined / Latch-up Destructive N/A (IC Damage)

Op-Amp vs Dedicated Comparator: Selecting the Right IC

A common beginner mistake is grabbing an LM358 or LM741 and using it as a comparator with op amp circuit without understanding the consequences. Standard op-amps feature internal compensation capacitors (often 30pF or more) to ensure stability when used in closed-loop feedback. When you drive an op-amp into saturation (open-loop), that capacitor charges fully. When the input polarity reverses, the op-amp must first discharge that capacitor before the output can begin moving. This results in a "recovery time" that can easily exceed 100 µs—glacially slow for modern digital logic.

Dedicated comparators omit this compensation capacitor and utilize output stages optimized for switching. According to Texas Instruments Application Note SNOA653, using an op-amp as a comparator also risks "phase reversal" in older JFET and bipolar designs, where the output flips to the wrong rail if the input common-mode range is exceeded.

Table 2: Safe Default Part Numbers and Ratings
Part Number Architecture Output Stage Propagation Delay Max Supply Best Use Case
LM393 Dedicated Dual Open-Collector 1.3 µs 36V General purpose, battery monitoring, 5V/12V logic interfacing
LM311 Dedicated Single Open-Collector/Emitter 200 ns 30V Higher speed single-channel, driving relays via emitter follower
TLV3201 High-Speed Comp Push-Pull (CMOS) 40 ns 5.5V High-speed logic, PWM generation, 3.3V microcontroller interfacing
LM358 Standard Op-Amp Push-Pull (Bipolar) ~100 µs (Recovery) 32V Avoid for comparators unless speed is irrelevant (<10 Hz)

Complete Application Circuit: Non-Inverting Comparator with Hysteresis

Floating inputs or slow-moving signals (like a charging capacitor or a thermistor voltage) will cause a comparator to oscillate wildly when the differential voltage hovers near zero. To fix this, we add positive feedback to create hysteresis (a Schmitt Trigger). Below is a complete, bench-tested circuit for a 5V non-inverting zero-crossing or threshold detector.

Component List and Values

  • U1: LM393 (Dual Comparator, using Channel A)
  • R1: 10 kΩ (Output pull-up resistor to 5V)
  • R2: 100 kΩ (Hysteresis feedback resistor from OUT to IN+)
  • R3: 10 kΩ (Reference divider, top resistor to 5V)
  • R4: 10 kΩ (Reference divider, bottom resistor to GND)
  • C1: 100 nF (Bypass capacitor across VCC and GND, physically adjacent to IC)

Wiring and Biasing Steps

  1. Establish the Reference: Connect R3 and R4 in series between 5V and GND. The midpoint connects to the IN- pin. This biases the reference voltage at exactly 2.5V. Place a 100nF capacitor from this midpoint to GND to filter out high-frequency noise.
  2. Wire the Input: Connect your analog sensor or signal directly to the IN+ pin.
  3. Set the Output: Because the LM393 has an open-collector output, it cannot source current. You must connect R1 (10 kΩ) between the OUT pin and your logic high voltage (e.g., 5V or 3.3V). This allows the comparator to interface with different logic levels safely.
  4. Apply Hysteresis: Connect R2 (100 kΩ) between the OUT pin and the IN+ pin. When the output is low (~0.2V), R2 pulls the IN+ threshold slightly below 2.5V (approx 2.45V). When the output is high (5V), R2 pushes the IN+ threshold slightly above 2.5V (approx 2.55V). This creates a 100mV deadband that prevents chatter.
  5. Verify: Apply a slow triangle wave (0V to 5V) to IN+. Probe the OUT pin with an oscilloscope. You should see a clean square wave that transitions sharply at ~2.45V on the falling edge and ~2.55V on the rising edge.
Biasing Rule of Thumb: The hysteresis voltage band is roughly calculated as V_hyst = (V_OH - V_OL) * (R_input / R_feedback). If your source impedance is high (e.g., a 1MΩ thermistor divider), your feedback resistor R2 must be significantly larger (e.g., 10MΩ) to prevent the feedback loop from loading down the input signal and skewing your threshold.

Failure Modes and Multimeter Testing

Comparators are rugged, but they fail in predictable ways on the bench. The most common failure modes include input overvoltage (exceeding the absolute maximum differential input rating, typically ±36V for an LM393, which melts the input differential pair), output short circuits (shorting the open-collector output directly to VCC without a pull-up resistor, instantly destroying the internal NPN sink transistor), and latch-up from exceeding the common-mode input range.

If a circuit isn't switching, do not immediately desolder the IC. You can perform a highly effective in-circuit and out-of-circuit diagnostic using a standard digital multimeter (DMM). As noted in standard semiconductor testing guides, testing the internal junctions will quickly reveal a dead chip.

How to Test a Comparator with a Multimeter

  1. De-energize and Isolate: Remove all power from the circuit. If the IC is socketed, pull it. If soldered, in-circuit testing is possible but parasitic parallel paths may skew resistance readings. For definitive results, desolder the chip.
  2. Test the Output Transistor (Diode Mode): Set your DMM to Diode Test mode. Place the red probe on the GND (VEE) pin and the black probe on the OUT pin. You should read a forward voltage drop of approximately 0.5V to 0.7V (the base-collector/collector-emitter junction of the internal open-collector NPN). Reverse the probes; it should read "OL" (Open Loop). If it reads 0.00V (short) or OL in both directions, the output transistor is destroyed.
  3. Test Input Clamping Diodes: Many comparators feature internal ESD protection diodes from the inputs to the rails. Set DMM to Diode mode. Red probe on GND, black probe on IN+. You should see ~0.6V. Repeat for IN-. If you read a dead short, the input stage is blown from overvoltage.
  4. Power-On Functional Test (Voltage Mode): If the diode checks pass, wire the IC to a breadboard with 5V VCC and GND. Tie IN- to GND. Connect a 10k pull-up from OUT to 5V. Set DMM to DC Voltage. Probe OUT with the black probe on GND. With IN+ floating or tied to 5V, you should read 5V. Momentarily short IN+ to GND; the DMM should instantly drop to ~0.2V. If it stays at 5V, the IC is internally open.

By understanding the physical limitations of op-amps in saturation and leveraging the correct dedicated IC, you can eliminate switching chatter, avoid microsecond-scale propagation delays, and build robust threshold detectors that survive real-world noise. Always default to the LM393 for general 5V/12V logic, and step up to the TLV3201 when nanosecond response times are non-negotiable.