An op-amp comparator compares two analogue input voltages, and switches its output between two fixed levels depending on which input is larger. The output Vout swings towards the positive supply rail if V1 is greater than V2, or towards the negative supply rail if V2 is greater than V1.
The high open loop gain of the op-amp will cause the output voltage to enter positive or negative saturation which will be close (but not quite equal) to the positive or negative supply rail voltages.
Dedicated Comparator IC
Although the above circuit demonstrates the principle of operation of an analogue comparator, a general purpose op-amp may be less than ideal for this application. Firstly, an op-amp output can be quite slow to recover from positive or negative saturation, hence limiting the maximum input frequency, Secondly, the output voltage is typically required to be a digital logic (true / false) signal, which may not be directly compatible with the output voltage range of the op-amp. Lastly, the input circuitry of the op-amp may not be well suited to the widely differing input voltages found with comparator applications.
A purpose designed comparator IC such as the LM339 offers four comparators in a single package, operates from a wide range of supply voltages, and allows direct connection to a range of logic families.
The output terminal of the LM339 comparator is linked internally to the otherwise unconnected collector terminal of an NPN bipolar transistor, which is called an open collector output, so an external pull-up resistor must be connected to allow the output to go to a high logic level. The value of this resistor will depend on the externally connected logic family and may be determined from the manufacturer's datasheet (100 kΩ may be suitable for CMOS, as shown above).
- 555 Timer
- Flash A-D Converter
- Relaxation Oscillator
- Successive Approximation A-D Converter
- Zero-crossing Detector
A digital comparator or magnitude comparator performs a similar function for digital systems, comparing two multiple bit binary numbers (A, B), and producing three digital outputs A < B, A > B and A = B, only one of which will be true for any combination of inputs.