Voltage comparator
A comparator compares two input voltages and reports their relationship as an output state. The output type matters: LM393/LM339 examples use a pull-down output that needs a suitable pull-up for a HIGH level, while other comparators use different output structures.
A high-gain input stage responds to the difference between the two inputs. In the LM393 example, the output transistor sinks current when the negative input exceeds the positive input by enough to overcome offset. Otherwise the output is high impedance and an external pull-up establishes HIGH. Inputs must remain in the specified common-mode range; response time depends on overdrive, load, supply and temperature.
In plain terms
A see-saw with no middle ground: the heavier side slams to the floor, the lighter side springs up. There is no 'almost level' — just two states, and a hair-trigger threshold between them.
Why designers use it
- Detect when a battery voltage drops below a low-battery threshold and signal the MCU.
- Build a zero-crossing detector for triac firing or PLL phase detection on a 50/60 Hz line.
- Convert a noisy slow-rising signal (PIR sensor, photodiode amp) into a clean digital edge.
- Implement a one-shot window detector with two comparators for over/under voltage protection.
- Reset a microcontroller cleanly with hysteresis when the rail crosses a known threshold.
Best for
- Threshold detect
- Zero-crossing
- Window monitor
- Schmitt trigger
Key specifications
- Input range: Check common-mode limits at your supply and temperature
- Output: Open-collector for LM393/LM339 examples; other devices differ
- Pull-up and sink current: Size using the specified low-level output voltage and current (An absolute-maximum current is not a recommended drive point.)
- Response time and offset: Device- and test-condition-dependent
When not to use it
- As an op-amp — a comparator's lack of internal compensation makes it unstable in a closed analog loop; it'll oscillate aggressively.
- In situations needing rail-to-rail push-pull drive at 5 ns edges — push-pull-output comparators (TLV3501, MAX9201) exist, but the open-collector LM339/LM393 family is too slow.
- On signals that hover near the threshold without hysteresis — the output will chatter from a few mV of noise. Add positive feedback to make a Schmitt trigger.
Common mistakes
- Omitting the pull-up on an open-collector output.
- Applying an input outside the common-mode range even when it remains below an absolute maximum.
- Choosing a pull-up that requires excessive sink current.
- Ignoring noise near the threshold; assess whether hysteresis is needed.
Where you will find it
- A solar-charge controller uses an LM393 dual comparator to detect when the battery voltage falls below 11.5 V and the panel voltage rises above the battery: only when both conditions are TRUE does the controller energise a P-channel MOSFET to connect the panel — two comparators replacing a microcontroller for the entire load-disconnect circuit.
- A line-voltage zero-cross detector uses an LM311 comparator with the AC line attenuated through a 1 MΩ divider into V+ and ground at V−: the open-collector output produces a clean 100 Hz pulse train (50 Hz line) used to phase-fire a triac for AC dimmer control.
- A USB-PD source controller uses an integrated rail-to-rail comparator (inside the controller IC) to detect over-voltage on the VBUS pin: when VBUS exceeds 22 V, the comparator's nanosecond-class edge trips a fast disconnect FET before the downstream device sees the surge.
A short history
TI's LM393 and LM339 documentation illustrates two- and four-comparator arrangements with open-collector outputs. Their input common-mode range includes ground under specified conditions, but does not generally extend all the way to the positive supply. Modern B versions have different electrical limits from the older versions, so check the full code rather than treating the family name as a specification.
Good to know
- An open-collector output does not actively drive both logic levels: the pull-up supplies the HIGH state.
- Input offset shifts the practical comparison threshold, so equality is not an infinitely precise switching point.