Q. What is a comparator? How does it differ from an op amp?
A. The basic function of a high-gain comparator is to determine whether an input voltage is higher or lower than a reference voltage—and to present that decision as one of two voltage levels, established by the output’s limiting values. Comparators have a variety of uses, including: polarity identification, 1-bit analog-to-digital conversion, switch driving, square/triangular-wave generation, and pulse-edge generation.
In principle, any high-gain amplifier can be used to perform this simple decision. But “the devil is in the details.” So there are some basic differences between devices designed as op amps and devices designed to be comparators. For example, for use with digital circuitry, many comparators have latched outputs, and all are designed to have output levels compatible with digital voltage-level specifications. There are some more differences of importance to designers—they will be discussed here.
Q. What are some circumstances where one can go either way?
A. Amplifiers should be considered for use as comparators in applications where low offset and drift, and low bias current, are needed—combined with low cost. On the other hand, there are many designs where an amplifier could not be considered as a comparator because of its lengthy recovery time from output saturation, its long propagation delay, and the inconvenience of making its output compatible with digital logic. Additionally, dynamic stability is a concern.
However, there are cost and performance benefits in using amplifiers as comparators—if their similarities and differences are clearly understood, and the application can tolerate the generally slower speed of amplifiers. No one can claim that an amplifier will serve as a drop-in replacement for a comparator in all cases—but for slow-speed situations requiring highly precise comparison, the performance of some newer amplifiers cannot be matched by that of comparators having greater noise and offset. In some applications with slowly changing inputs, noise will cause comparator outputs to slew rapidly back and forth (see “Curing comparator instability with hysteresis,” Analog Dialogue, Volume 34, 2000). In addition, there can be savings in cost or valuable printed-circuit-board (PCB) area in applications where a dual op amp could be used instead of an op amp and a comparator—or in a design where three of the four amplifiers in a quad package are already committed, and two dc or slowly varying signals must be compared.
Q. Can that fourth amplifier be used as a comparator?
A. This is a question that many system designers are asking us these days. It would pointless to buy a quad op amp, use only three channels, and then buy a separate comparator—if indeed that amplifier could be used in a simple way for the comparison function. Be clear, though, that an amplifier can’t be used as a comparator interchangeably in all cases. For example, if the application requires comparison of signals in less than a microsecond, adding a comparator is probably the only way to go. But if you understand the internal architectural differences between an amplifier and a comparator, and how these differences affect the performance of these ICs in applications, you may be able to obtain the inherent efficiency of using a single chip.
In these pages, we will describe the parametric differences between these two branches of IC amplifier technology and provide useful hints for using an amplifier as a comparator.
Q. So how do amplifiers and comparators differ?
A. Overall, the operational amplifier (op amp) is optimized to provide accuracy and stability (both dc and dynamic) for a specified linear range of output values in precision closed-loop (feedback) circuits. However, when an open-loop amplifier is used as a comparator, with its outputs swinging between their limits, its internal compensation capacitance—used to provide dynamic stability—causes the output to be slow to come out of saturation and slew through its output range. Comparators, on the other hand, are generally designed to operate open loop, with outputs slewing between specified upper and lower voltage limits in response to the sign of the net difference between the two inputs. Since they do not require the op amp’s compensation capacitors, they can be quite fast.
If the input voltage to a comparator is more positive than the reference voltage plus the offset—VOS (with zero reference, it’s just the offset) plus the required overdrive (due to limited gain and output nonlinearity), a voltage corresponding to logic “1” appears at the output. The output will be at logic “0” when the input is less than VOS and the required overdrive. In effect, a comparator can be thought of as a one-bit analog-to-digital converter.
There are different ways of specifying a comparator and an amplifier. As an example, in an amplifier, the offset voltage is the voltage that must be applied to the input to drive the output to a specified mid-range value corresponding to ideal zero input. In a comparator this definition is modified to center in the specified voltage range between 1 and 0 at the output. The comparator’s “low” output value (logic 0) is specified at less than 0.4 V max in comparators with TTL-compatible outputs, while for a low-voltage amplifier, the low output value is very close to its negative rail (e.g., 0 V in a single-supply system). Figure 1 compares the low output values of typical amplifier and comparator models, with a –1-mV differential input applied to each.
Built to compare two levels as quickly as possible, comparators do not have the internal compensation capacitor (“Miller” capacitor) usually found in op amps, and their output circuit is capable of more flexible excitation than that of op amps. This absence of compensation circuitry gives comparators very wide bandwidth. At the output, ordinary op amps use push-pull output circuitry for essentially symmetrical swings between the specified power supply voltages, while comparators usually have an “open-collector” output with grounded emitter. This means that the output of a comparator can be returned through a low-value collector load resistor (“pullup” resistor) to a voltage different from the main positive supply. This feature allows the comparator to interface with a variety of logic families. Using a low value of pull-up resistance yields improved switching speed and noise immunity—but at the expense of increased power dissipation.
Because comparators are rarely configured with negative feedback, their (differential) input impedance is not multiplied by loop gain, as is characteristic of op amp circuits. As a result, the input signal sees a changing load and changing (small) input current as the comparator switches. Therefore, under certain conditions, the driving-point impedance must be considered. While negative feedback keeps amplifiers within their linear output region, thus maintaining little variation of most internal operating points, positive feedback is often used to force comparators into saturation (and provide hysteresis to reduce noise sensitivity). A comparator’s input usually accommodates large signal swings, while its output has a limited range due to interfacing requirements, so a lot of rapid level shifting is required within the comparator.
Each of the above differences between an amplifier and a comparator is there for a reason, with the major goal of comparing rapidly varying signals as quickly as possible. But, for comparing slow-speed signals—especially where sub-mV resolution is required—some new rail-to-rail amplifiers from Analog Devices could be better buys than comparators.
Q. OK. I can see that there are overall differences. How do they look to the designer who wants to use an op amp to replace a comparator?
A. Here are six major points:
1. Consider VOS and IB non-linearity vs. input common-mode voltage
When using voltage comparators, it is common practice to ground one input terminal and use a single ended input. The primary reason has been the poor common-mode rejection of the input stage. In contrast, many amplifiers have very high common mode rejection and are capable of detecting microvolt-level differences in the presence of large common-mode signals. Figure 2 shows the response of an AD8605 op amp to a 100-mV differential step riding on a 3-V common-mode voltage.
But, for many rail-to-rail-input amplifiers, input offset voltage (VOS) and input bias current (IB) are non-linear over the input common-mode voltage range. With these amplifiers, the user needs to take this variation into account in the design. If the threshold is set at zero common-mode, but the part is used at some other common-mode level, then the logic level that results may not be as anticipated. For example, a part with offset of 2 mV at zero common mode, and 5-to-6 mV over the entire common mode range may give an erroneous output when comparing a difference of 3 mV at some levels in that range.
2. Watch out for input protection diodes
Many amplifiers have protection circuitry at their inputs. When the two inputs experience a differential voltage greater than a nominal diode drop (say, 0.7 V), the protection diodes start conducting and the input breaks down. Therefore, it is critical to look at the input structure of an amplifier and make sure that it can accommodate the expected range of input signals. Some amplifiers, such as the OP777 / OP727 / OP747, do not have protection diodes; their inputs can accommodate differential signals up to the supply voltage levels. Figure 3 shows the response to a large differential signal at the input of an OP777. Many amplifiers’ inputs break down under this condition, while the OP777 responds correctly. CMOS-input amplifiers do not have protection diodes at their input, and their input differential voltage can swing rail-to-rail. But remember that, in some cases, applying a large differential signal at the input causes significant shifts of amplifier parameters.
3. Watch out for input voltage range specs and phase-reversal tendencies:
Unlike operational amplifiers that usually operate with the input voltages at the same level, comparators typically see large differential voltage swings at their inputs. But some comparators without rail-to-rail inputs are specified to have a limited common mode input voltage range. If the inputs exceed a device’s specified common-mode range (even though within the specified signal range), the comparator may respond erroneously. This may also be true for some of the older types of amplifiers designed with junction-FET (JFET) and bipolar technologies. As the input common-mode voltage exceeds a certain limit (IVR), the output goes through phase inversion. This phenomenon can be detrimental (see in Chapter 6 of Ask the Applications Engineer”, the figure that follows the table). Therefore, it is absolutely critical to pick an amplifier that does not exhibit phase reversal when overdriven. This is one type of problem that can be overcome by using amplifiers with rail-to-rail-inputs.
4. Consider saturation recovery
Typical op amps are not designed to be used as fast comparators, so individual gain stages will go into saturation when the amplifier output is driven to one of its extremes, charging the compensation capacitor and parasitic capacitances. A design difference between amplifiers and comparators is the addition of clamp circuitry in comparators to prevent internal saturation. When an amplifier is pushed into saturation, it takes time for it to recover and then slew to its new final output value—depending on the output structure and the compensation circuitry. Because of the time it takes to come out of saturation, an amplifier is slower when used as comparator than when it is used under control in a closed-loop configuration. One can find saturation-recovery information in many amplifier data sheets. Figure 4 shows saturation recovery plots for two popular amplifiers (AD8061 and AD8605). The output structures of these amplifiers are standard push-pull rail-to-rail common-emitter.
5. Factors affecting transition time
Speed is one of the distinguishing differences between amplifier and comparator families. Propagation delay is the time it takes for a comparator to compare two signals at its input, and for its output to reach the midpoint between the two output logic levels. Propagation delay is usually specified with an overdrive, which is the voltage difference between the applied input voltage and the reference that is required for switching within a given time. In the following graphs, the responses of several rail-to-rail CMOS amplifiers are compared with a popular comparator. All amplifiers are configured as shown in Figure 5(a-e) with applied voltage, VIN, = ±0.2 V, centered around 0 V. In the case of the comparator, a 10-kΩ pullup is used instead of a load to ground. The amplifier speeds differ widely, but because of saturation and their lower slew rate, all are much slower than the comparator.
Figure 5. Responses of comparator and three open-loop amplifier models compared, ±0.2-V drive. a. Amplifier circuit configuration. b. Positive step. c. Negative step. Then, with 50-mV signal applied and overdrive of 20 mV. Period = 10 μs. d. Positive step. e. Negative step.
|Part Number||Supply Current (µA)||Offset Voltage (mV)||Supply Range (V)||Slew Rate (V/µs|
While most comparators are specified with 2-mV to 5-mV overdrive, most high precision, low input offset amplifiers can reliably operate with as little as 0.05-mV overdrive. The amount of overdrive applied at the input has a significant effect on propagation delay. Figure 6 shows the response of the AD8605 to several values of overdrive voltage.
As amplifiers are allowed to consume more power, their speed improves substantially, so that they can compete with comparators in terms of rise- and fall times. Figure 7 includes an example of this—for an AD8061, with a 300 V/μs slew rate, in an open loop configuration responding to a sinusoidal zero crossing input, the output recovery time is 19 ns. However, one of the biggest drawbacks to using an amplifier as a comparator is often its power consumption, since one can generally find comparators that draw less supply current (ISY), but still function well. Of course, for instruments using line power, power consumption is usually not a big driving factor. Besides, many amplifiers have a shutdown pin—a feature rarely available in comparators; it can be used to conserve power.
In Figure 8, the AD8061’s step response is compared with that of the popular LM139, and two other open-loop amplifiers, connected in the same circuit configuration as in Figure 6. As can be seen, the AD8061 responds within 300 ns, which is faster than LM139. This is achieved at the expense of higher current consumption.
6. Consider the way to interface with different logic families
Many of today’s rail-to-rail-output amplifiers operate with single supply of 5 V to 15 V, which can easily provide TTL- or CMOS-compatible output without the need for additional interfacing circuitry. If the logic circuit and op amp share the same supply, then a rail-to-rail op amp will drive CMOS and TTL logic families quite successfully, but if the op amp and logic circuitry need different supply levels, additional interface circuitry will be required. For example, consider an op amp with ±5 V supplies that must drive logic with +5 V supply: Since the logic is liable to be damaged if –5 V is applied to it, careful attention must be paid to the design of interface circuitry.
Figure 9 shows an OP1177 (dual-supply amplifier), interfaced to logic circuitry, and Figure 10 shows its response to 100 mV of overdrive. With ±5-V supplies, quiescent power dissipation is lowered and thermal feedback—due to output stage dissipation—is minimized, compared to ±15-V operation. The lower supply voltage also reduces the OP1177 rise and fall times as the output slews over a reduced voltage range—which in turn reduces the output response time.
Without the protective circuitry on the output of OP1177, the output would swing to +VCC2 and –VEE2; these levels might be detrimental to downstream logic circuitry. Adding Q2 and D2 prevents the output from going negative and translates the limits to TTL-compatible output levels. D2 clamps the output, so that it will not go below 0.7 V, as can be seen from waveform V(D2,2). The value of VCC of Q2 can be selected (5 V was selected for this analysis) such that a correct logic level results, as shown by waveform VOUT.
To conserve power, an N-channel MOSFET may be used instead of the NPN transistor shown in Figure 9.
Q. So the bottom line is...
A. An amplifier can be used as a comparator with excellent precision at low frequencies. In fact, for comparing signals with microvolt-level resolution, precision amplifiers are the only practical choice. They can also be an economical choice for multiple-channel op amp users when employment of free amplifier channels to satisfy comparator requirements is feasible. Savvy designers can save money while optimizing their designs if they take the trouble to: understand the similarities and differences between amplifiers and comparators; read the amplifier’s data sheet for the right features; understand about trade-offs in recovery time, speed, and power consumption; and are willing to verify designs with amplifiers configured as comparators.