Why buy an expensive comparator when an op amp is just as good?
Because it isn't. My advice to anyone tempted to use an operational amplifier (op amp) as a comparator is the same as Mr. Punch's advice to those about to marry. "Don't!" But since my good advice is as likely to be taken as Mr. Punch's this piece contains some advice for those who are going ahead anyway.
Comparators have differential inputs and a rail-to-rail output. So do op amps. They have low offset, high gain and high common mode rejection ratio (CMRR). So do op amps. But comparators are designed to work open-loop, drive logic circuits, work at high speed even when over-driven, and accept large differential input voltages. Op amps are intended to work closed-loop, driving simple resistive or reactive loads – and are not designed to recover quickly from overdrive. But op amps are cheaper, often come in four- or even six-packs (so often one is spare and begging to be used), and compared to most comparators, have better offset and bias current specifications.
Using an op amp as a comparator may lead to difficulties for three major reasons: speed, logic drive capability, and various effects of input structures.
Comparators are designed to work with large differential inputs, while op amps are intended for closed-loop operation with both inputs at very similar potentials. If an op amp sees a differential input voltage of even a few millivolts its internal circuitry may saturate. Recovery may be very slow and recovery time may vary considerably with the level of over-drive and from device to device. Such variability and loss of speed may be unwelcome in a comparator.
If an op amp has rail-to-rail output and is operated on the same supplies as the saturating logic it is driving (CMOS or TTL) then interfacing is not hard. But if the op amp and logic supplies differ then additional interface circuitry, which may be quite complex, is necessary to produce the correct levels.
Finally, op amp inputs usually have high impedance and low bias current. But if a differential input voltage of more than a few hundred millivolts is applied to them this may no longer be the case, and all sorts of less than ideal behaviour may occur. Higher levels of over-drive may also do minor damage to an op amp's input stages, resulting in slowly accumulating long-term changes in performance which may be overlooked during laboratory development.