What Is a Comparator?
A comparator is an IC that compares two voltages and reports which is larger with a digital (high/low) output. It's the threshold element connecting the analog world to the digital.
How Does It Work?
It has two inputs. If the (+) input is larger than the (−) input the output is high (1), if smaller it's low (0). So it works like a "threshold detector".
Difference From an Op-Amp
An op-amp is designed for linear amplification and used with feedback; a comparator is optimized for fast switching (saturation) and its output is usually 0 or 1.
| Property | Comparator | Op-Amp |
|---|---|---|
| Output | Digital (0/1) | Linear |
| Speed | Fast switching | Medium |
| Feedback | Usually positive | Negative |
Hysteresis (Schmitt Trigger)
If the input is noisy around the threshold, the output can chatter. With positive feedback two separate thresholds (hysteresis) are created to prevent this chatter; this structure is called a Schmitt trigger.
Where Is It Used?
Threshold detection, zero-crossing detectors, battery/temperature monitoring, square-wave generation and converting a noisy signal into a clean digital one.
Output Types
Comparators have two output types: push-pull drives 0/1 directly; open-collector/open-drain needs an external pull-up resistor but allows adapting to different voltage levels and a "wired-AND" connection. The right type must be chosen in the design.
Common Mistakes
- Using it without hysteresis: with a noisy input the output chatters rapidly.
- Mistaking an op-amp for a comparator: an op-amp's switching is slow and not ideal.
- Output type: a comparator with an open-collector output needs a pull-up resistor.
Frequently Asked Questions
Can I use an op-amp as a comparator?+
What is the LM393?+
Search parts related to "What Is a Comparator?"
Find the right part by comparing price, stock and distributors.