Sponsored by: Texas Instruments. Generally speaking, an op amp doesn’t make for a good comparator. To achieve optimal performance and avoid additional debugging, an IC comparator is the best bet.
A comparator is a great circuit because it provides a near ideal transition between the analog and digital domains. The comparator looks at two linear input signals and gives a digital output that’s either high or low depending on whether one input is above or below the other. Simple, but widely useful.
If you need this type of circuit in your design, it’s best to use an IC comparator that was designed for such applications. However, most designers know that a standard op amp can be used as a comparator. And in some designs, an extra op amp may be available, thus avoiding any extra cost or need for more space.
Chances are that the resulting op-amp comparator will probably not deliver the desired optimum performance. This amateur design error can result in more debugging and redesign time than planned. The best advice is that if you need a comparator, use an IC comparator to avoid problems and achieve the best possible outcome.
The main differences between these two include:
Despite what may appear as similarities, the two circuits are different animals with different applications.
So is it okay to use an op amp as a comparator?  Maybe. Many engineers have used an op amp as a comparator. This is often done when you only need one comparator and you have a “spare” op amp in a quad op-amp package. The phase compensation required for stable op-amp operation means that it will be very slow as a comparator, but if speed requirements are modest, the op amp may suffice. Sometimes this approach works, but other times it falls short.
One way to look at the operation of a comparator is to examine the basic op-amp configuration shown in Figure 1a. The amplifier has very high open-loop gain (AOL >> 1000). What it amplifies is the difference between the two inputs V1 and V2. The output is:
Because of the high gain, it doesn’t take much of a differential input signal (V2 – V1) to drive the output to either the positive or negative power rail. For example, if the supplies are ±5 V, and the open-loop gain is 100,000, a differential input of 5/100,000 = 50 µV or more will drive the output to the rail. Figure 1b depicts the input-output transfer curve.
|Figure 1.||Here’s an op amp connected as an inverter (a), and its
input-output transfer curve (b).
A true comparator operates from a single supply that commonly also operates the digital logic. The output is connected to a pull-up resistor to the supply rail (Fig. 2a). The inputs to the comparator are the reference (VREF) and the signal that’s compared to the reference (VIN). Either of the two inputs can be connected to the reference or input signal. A common arrangement is a fixed reference voltage value and a varying input signal. Two common versions are the inverting and non-inverting configurations:
Fig. 2 shows an inverting arrangement with a fixed dc reference and a triangle wave input (Fig. 2c). With the input below the threshold, the output is high (see transfer curve in Fig. 2b). As the input exceeds the reference, the output switches low. Later, as the input decreases, the output again switches as the threshold is passed.
|Figure 2.||Shown is an inverting comparator with typical inputs (a), its transfer
curve (b) and input/output signals (c).
One problem that often occurs is the noise or multiple short transitions on the output at the threshold points. This so-called chatter occurs when the input is varying slowly and can cause false triggering in an application. Even with very clean input voltages, comparators have their own noise – like an op amp. They also sometimes make noise when the output slams from one rail to another, reverberating through the supply or output circuitry back to the input.
One way to overcome this is to use hysteresis  (Fig. 3). The reference is applied via two resistors that provide regenerative or positive feedback that speeds up the switching and virtually eliminates the chatter.
|Figure 3.||A comparator with hysteresis (a) can eliminate chatter
at the transition points (b).
What the hysteresis does is to establish upper (VU) and lower (VL) trip point voltages around the reference level. The small window or dead zone keeps the output clean with no chatter. The values of R1 and R2 set the trip points that can be calculated with these equations:
If you want to know more about the op amp as a comparator, check out the Texas Instruments Precision Labs training series on op amps. Lesson 14  covers the functionality of the comparator and its key dc and ac specifications; how to apply hysteresis to protect against comparator input noise; and the pros and cons of using op amps as comparators.
You may have to register before you can post comments and get full access to forum.