Comparator Circuits and Hysteresis

2026-04-22

A comparator is deceptively simple: it compares two voltages and outputs a digital high or low. Feed a signal into the non-inverting input (+) and a reference voltage into the inverting input (−). When V+ exceeds V−, the output swings to the positive rail. When it drops below, the output swings to the negative rail (or ground). That's it — an analog-to-digital decision in one component.

You can use a standard op-amp as a comparator in a pinch, but dedicated comparator ICs like the LM393 or LM311 are designed for this job. They have faster slew rates, open-collector/open-drain outputs for easy interfacing with logic levels, and they won't latch up when driven into saturation the way op-amps can.

The noise problem. In the real world, a signal near the threshold doesn't cross it cleanly once — it crosses it dozens of times as noise rides on top. Your comparator output chatters rapidly between high and low. This is called bouncing, and it will wreak havoc on any downstream digital logic or relay.

The fix is hysteresis, implemented with a single positive feedback resistor. Wire a resistor (R_fb) from the comparator output back to the non-inverting input (+), which already receives the signal through its own resistor (R_in). This creates two distinct thresholds:

The gap between V_H and V_L is the hysteresis band. Once the signal crosses one threshold, it must travel the full width of the band before the output changes again. Noise smaller than the band is ignored completely.

Rule of thumb for sizing: Set the hysteresis band to roughly 2–5× your expected noise amplitude. If your signal has 50 mV of noise riding on it, aim for 100–250 mV of hysteresis. The approximate hysteresis width is:

Hysteresis ≈ V_swing × (R_in / R_fb)

where V_swing is the output voltage swing of the comparator. For an LM393 with a 5 V pull-up and V_swing ≈ 5 V, if you want 200 mV of hysteresis, you'd pick R_in/R_fb ≈ 0.04. With R_in = 10 kΩ, that gives R_fb = 250 kΩ. A standard 270 kΩ resistor works perfectly.

Real-world example: A thermostat. You want a heater to turn on below 18°C and off above 22°C. A temperature sensor feeds a voltage proportional to temperature into a comparator with hysteresis set to span that 4°C band. Without hysteresis, the heater would cycle on and off every few seconds as the temperature hovered at the setpoint — destroying the relay contacts and wasting energy.

One caution: hysteresis makes the circuit intentionally non-linear. The output depends not just on the current input, but on the previous state. This is a feature, not a bug — but you need to account for both thresholds when analyzing the circuit's behavior.

See it in action: Check out Op Amps: Comparators With Hysteresis by Electronics with Professor Fiore to see this theory applied.
Key Takeaway: Always add positive-feedback hysteresis to comparator circuits — one resistor eliminates output chatter caused by noise near the switching threshold.

All newsletters