SlideShare a Scribd company logo
1 of 8
Download to read offline
AN-849
APPLICATION NOTE
OneTechnologyWay • P.O. Box 9106 • Norwood, MA 02062-9106, U.S.A. •Tel: 781.329.4700 • Fax: 781.461.3113 • www.analog.com
Rev. A | Page 1 of 8
Using Op Amps as Comparators
by James Bryant
INTRODUCTION
A comparator is a device with two input terminals, inverting
and noninverting, and an output that usually swings from rail to
rail. So is an op amp.
V+
V–
V+
V–
06125-001
Figure 1.
A comparator has low offset, high gain, and high common-mode
rejection. So does an op amp.
So what is the difference? A comparator has a logic output that
indicates which of the two inputs is at a higher potential. If its
output is TTL or CMOS compatible (and many comparators
are), it is always intended to be at one rail or the other—or
making a rapid transition between the two.
An op amp has an analog output that is not typically close to the
supply rails, but is somewhere between them. It is designed to
be used in closed-loop applications with feedback from its
output to its inverting input. But the outputs of most modern
op amps can swing close to their supply rails. Why not use them
as comparators?
Op amps have high gain, low offset, and high common-mode
rejection. They usually have lower bias current and are cheaper
than comparators. In addition, op amps are often available in
packages of two or four—if you need three op amps and a
comparator, it seems pointless to buy four op amps, not use one
of them, and then buy a separate comparator.
However, the best advice on using an op amp as comparator is
very simple—don’t!
Comparators are designed to work as open-loop systems, to
drive logic circuits, and to work at high speed, even when
overdriven. Op amps are designed for none of these. They are
intended to work as closed-loop systems, to drive simple
resistive or reactive loads, and should never be overdriven to
saturation.
But it is tempting to use op amps as comparators for a number
of reasons. The remainder of this document summarizes the
reasons and warns of possible unexpected consequences of
using an op amp as a comparator.
WHY USE AN OP AMP AS A COMPARATOR?
• Convenience
• Economy
• Low IB
• Low VOS
There are several reasons to use op amps as comparators. Some
are technical, one is purely economic. Op amps are manufactured
as single devices, but also as duals and quads, two or four op
amps on a single chip. These duals and quads are cheaper than
two or four separate op amps and occupy less board space, saving
yet more money. It is economical to use the spare op amp in a
quad as a comparator rather than buying an additional
comparator, but this is not a good design practice.
Comparators are designed for clean fast switching and, as a result,
often have worse dc parameters than many op amps. So it may be
convenient to use an op amp as a comparator in applications
requiring low VOS, low IB, and wide CMR. It is never worthwhile
to use an op amp as a comparator if high speed is important.
WHY NOT USE AN OP AMP AS A COMPARATOR?
• Speed
• Inconvenient input structures
• Inconvenient logic structures
• Stability/hysteresis
There are several reasons not to use op amps as comparators.
First and foremost is speed, but there are also output levels,
stability (and hysteresis), and a number of input structure
considerations. The following sections provide more detail.
AN-849
Rev. A | Page 2 of 8
Most comparators are quite fast and some are very fast indeed—but
so are some op amps. Why must we expect low speed when using
an op amp as a comparator? A comparator is designed to be used
with large differential input voltages, whereas op amps typically
operate closed loop with their input voltages minimized by negative
feedback. When an op amp is overdriven, sometimes by only a few
millivolts, some of its stages may saturate. If this occurs, the device
takes a comparatively long time to come out of saturation, and is,
therefore, much slower than if it were unsaturated.
OUTPUT OF OP AMP USED
AS A COMPARATOR
OUTPUT OF OP AMP USED
CLOSED-LOOP
(NO SATURATION/
DESATURATION)
INPUT DELAY DUE TO
DESATURATION
t0 06125-002
Figure 2.
The desaturation time of an overdriven op amp is likely to be
considerably longer than its normal group delay (effectively the
time a signal takes from input to output) and often depends on
the amount of overdrive.
Because few op amps are characterized for their recovery times
from differing levels of overdrive, it is necessary for the user to
determine, by experiment, the delays likely to result from the
levels of overdrive expected in a particular application. The
value used in design calculations should be at least twice the
worst value seen in any tests, because the samples tested may
not be representative.
The output of a purpose-built comparator is designed to drive a
particular logic family or families. Often there is a separate supply
for the output stage to ensure that the logic levels are correct.
A modern op amp usually has rail-to-rail output—its maximum
positive level is close to the positive supply, and the minimum
negative level is close to the negative supply. (Older designs used
structures with headroom of more than 1.5 V to both supplies.)
OP AMP LOGIC
06125-003
Figure 3.
If logic and op amp share the same supply, a rail-to-rail op amp
can drive CMOS and TTL logic families successfully, but if the
op amp and logic have different supplies, additional interface
circuitry is necessary between them. Note that this applies to an
op amp with ±5 V supplies that must drive logic with +5 V
supply; the logic is liable to be damaged if −5 V is applied to it.
The simplest interface circuits are inverters. They may be built
with NPN transistors, but these draw base current. N-channel
MOSFET transistors are more convenient.
OP AMP
+VA
–VA
RL
RB
LOGIC
+VL
–VL
LOGICOP AMP
+VA
–VA
RL
+VL
–VL
06125-004
Figure 4.
RB sets the transistor base current, and RL sets the collector/drain
current. The lower their value, the faster the inverter, but the
more power it consumes. Values of a few kilohms are usually
used. The N-channel MOS device should have a low gate
threshold voltage (<2 V) and a gate-source breakdown voltage
greater than the maximum output voltages of the op amp.
Usually, ±25 V is sufficient. Even though the op amp and the
logic use different supplies, they must be related to each other.
The op amp positive supply, +VA, must be more positive than
the logic negative supply, −VL, by at least 3 V to provide enough
voltage to turn on the transistor or the MOSFET gate. In
addition, the op amp negative supply must not be positive
relative to the logic negative supply, although it may be
connected to it. One must, of course, observe the absolute
maximum ratings of all the devices used.
LOGICOP AMP
+VA
–VA
+VL
–VL
P
N
06125-005
Figure 5.
A complementary MOS inverter can be built with a P-channel
and an N-channel MOSFET. This has the advantage of drawing
no standby current, but it does have a large current spike during
switching when both devices are briefly turned on together.
With this arrangement, the op amp positive supply, +VA, must
be equal to or greater than the logic positive supply, +VL. In
addition, the op amp negative supply must be equal to or less
than the logic negative supply.
AN-849
Rev. A | Page 3 of 8
Another way of ensuring the correct logic interface levels is to
use a clamp amplifier such as the AD8036. A clamp amplifier
has positive and negative reference terminals, and its output is
clamped to within 30 mV of the reference voltages if it attempts
to go above or below the positive and negative limits.
LOGICAD8036
+VA
–VA
+VL
–VL
06125-006
Figure 6.
So if the positive and negative logic supplies are connected to
the reference inputs (and the amplifier supplies are outside the
logic supplies), the amplifier output safely drives the logic.
As previously noted, when op amps are used as comparators,
they tend to respond more slowly than expected, due to
saturation. For this reason, it is unlikely that there are many
applications where op amps, used as comparators, are required
to drive emitter-coupled logic (ECL), which is, after all, used
where the highest logic speeds are required.
ECL
LOGIC
OP AMP
+VA
–VA
–5.2V
R3
R1
R2
06125-007
Figure 7.
But for the sake of completeness, Figure 7 shows an interface
that uses just three resistors, R1, R2, and R3. They are chosen so
that when the op amp output is at its positive limit, the level at
the ECL gate input is −0.8 V, and when it is at its negative limit,
the voltage is −1.6 V. The ratio of R1, R2, and R3 is set by this
requirement; the absolute values are a compromise between
speed and power economy.
There are a number of issues to consider with the inputs of op
amps used as comparators. The first assumption is that the
input impedance of an op amp is infinite. While this is a
reasonable starting position with voltage-feedback op amps, it
cannot be held throughout the design process. It is invalid with
current-feedback (transimpedance) op amps that have very low
impedance at their inverting inputs. For this reason, they
should never be used as comparators.
The actual characteristics of the input impedance and the bias
currents must be considered. Because most op amps have high
impedance and low bias currents, there is usually little difficulty
in ensuring that a design works with the actual range of
expected values, rather than zero and infinity. But the
calculations should be made. If they are not, Murphy’s Law
guarantees that if anything can go wrong, it will.
R = 0C = 0
IB+ = 0
IB– = 0
06125-008
Figure 8.
Some op amps have input stages consisting of a long-tailed pair
of transistors or FETs. These have high input impedance even
when a large differential voltage is present between the
inverting and noninverting inputs. But most op amps have
more complex input structures, such as bias compensated input
stages, or rail-to-rail input stages that are made of two input
stages, one uses NPN or N-channel devices, and the other uses
PNP or P-channel ones, connected in parallel to allow their
common-mode range to include both supplies.
Op amps are designed to operate with negative feedback, which
minimizes their differential input. These complex structures
may not respond well to large differential input voltages. It is
not practical to discuss all possible architectures in this
document, but the protection circuitry shown in Figure 9
illustrates one of many such structures. With differential inputs
below ±0.6 V, the device has high input impedance—but above
that, the protection diodes conduct and the differential input
impedance drops abruptly. 06125-009
Figure 9.
In many comparator applications, the differential input is
limited to a few tens or hundreds of millivolts, but in many it is
not, and these effects become important.
AN-849
Rev. A | Page 4 of 8
READ THE DATA SHEET
It is necessary to read the data sheet very carefully to determine
if the worst-case voltages expected in the comparator application
sufficiently affects the op amp performance to prevent proper
operation. Experiment is not a good guide here, as some
overvoltage effects are cumulative—a single overvoltage event
does negligible damage, but many can slowly degrade offset,
noise, or open-loop gain—or all three.
While reading the data sheet, it is important to look for low
values of absolute maximum differential input voltage, for
graphs of bias current or input current vs. differential or
common-mode voltage that show discontinuities or gross
nonlinearity, and for evidence of phase-inversion.
For more information on reading data sheets, see
http://www.analog.com/raq_caveat and the URLs linked to
that page, especially http://www.analog.com/raq_datasheet.
If any of these potential dangers are present, it is essential to
analyze the behavior of your system to determine if they
prevent it from working properly. This may be done by a
simulation, but do note that Spice and other models do not
always map well to device behavior under conditions of large
differential input. It may well be better to do simple pen and
paper calculations of the effects to be expected, followed by
some experiments.
PHASE INVERSION
Older FET input op amps, and even some bipolar types, suffered
from a phenomenon called phase inversion or phase reversal. If
the input went outside the allowed common-mode range, the
inverting and noninverting inputs exchanged functions.
INPUT
OUTPUT
06125-010
Figure 10.
As can well be imagined, this is not good news in a comparator
application. It is important to ensure that any op amp used as a
comparator is either free from phase inversion (most op amps
in the last decade are designed this way) or that the system is
designed so that the comparator inputs never approach the
region where phase inversion might take place.
Because op amp manufacturers do not want to call attention to
phase inversion in their products, it tends to be mentioned as a
limit to the common-mode range in the data tables, without
many details of what can happen if the limit is exceeded. Keep
this in mind, and if an op amp appears to be suffering from the
phenomenon, test it.
INSTABILITY
An op amp used as a comparator has no negative feedback, and
thus, has very high open-loop gain. During transitions, very
small amounts of positive feedback can start oscillation. The
feedback can arise from stray capacitance between the output
and the noninverting input or from output currents flowing in
common-ground impedance.
STRAY C COMMON GROUND
IMPEDANCE
06125-011
Figure 11.
The cures are to minimize stray capacitance by proper layout and
to ensure that the impedance seen by the noninverting input is as
low as possible to attenuate any residual capacitive feedback.
Capacitive feedback to the inverting input is only a problem with
current feedback op amps (which are not recommended) and
voltage feedback op amps that are not fully compensated (that is,
not unity-gain stable).
Ground current feedback is controlled by intelligent design of
ground circuit layout. This is discussed in a number of Analog
Devices, Inc. Application Notes, specifically AN-202, AN-214,
AN-280, AN-345, and AN-347. For additional information
about layout for analog system grounds, see
http://www.analog.com/raq_groundingclean.
AN-849
Rev. A | Page 5 of 8
HYSTERESIS
Sometimes it is not possible to prevent instability by these
measures. The only remaining possibility is to use a small
amount of controlled positive feedback to produce hysteresis so
that once a transition has started, the input must undergo
significant reversal before the reverse transition can occur.
R1
R2
SIGNAL APPLIED TO R1 MUST COME
FROM A SOURCE IMPEDANCE WHICH
IS MUCH LOWER THAN R1.
OUTPUT SWING: VS
HYSTERESIS
VS(R1)/(R1 + R2)
06125-012
Figure 12.
This can be done with two resistors; the amount of hysteresis is
proportional to their ratio. The signal input to the comparator
may be applied to either the inverting or the noninverting
input, but if it is applied to the noninverting input, the source
impedance must be low enough to have an insignificant effect
on R1. Of course, if the source impedance is predictable
enough, it may be used as R1.
If the reference voltage is midway between the two comparator
output voltages, as is the case with a symmetrical power supply
and a ground reference, the introduction of hysteresis moves
the positive and negative thresholds equal distances from the
reference. But if the reference is nearer to one output than to
the other, the thresholds are asymmetrically placed about the
reference voltage.
Calculation of thresholds when the reference is not
midway between the supplies:
Comparator output voltages are VP and VN.
Reference voltage is VR.
Positive threshold is
21
P1R2
RR
VRVR
+
+
Negative threshold is
21
N1R2
RR
VRVR
+
+
CONCLUSION
In conclusion, although op amps are not designed to be used as
comparators, there are, nevertheless, many applications where
the use of an op amp as a comparator is a proper engineering
decision. It is important to make an educated decision to ensure
that the op amp chosen performs as expected.
To do this, it is necessary to read the data sheet carefully and to
consider the effects of nonideal op amp parameters on the
application. Because the op amp is being used in a nonstandard
manner, spice models may not reflect its actual behavior, and
some experiment is advisable. Furthermore, because not all
devices are typical in their behavior, some pessimism is
warranted when interpreting the experimental results.
AN-849
Rev. A | Page 6 of 8
NOTES
AN-849
Rev. A | Page 7 of 8
NOTES
AN-849
Rev. A | Page 8 of 8
NOTES
©2006-2011 Analog Devices, Inc. All rights reserved. Trademarks and
registered trademarks are the property of their respective owners.
AN06125-0-11/11(A)

More Related Content

What's hot

Schmitt trigger basics
Schmitt trigger  basicsSchmitt trigger  basics
Schmitt trigger basics
SAQUIB AHMAD
 

What's hot (20)

Seminar final
Seminar finalSeminar final
Seminar final
 
Study and implementation of comparator in cmos 50 nm technology
Study and implementation of comparator in cmos 50 nm technologyStudy and implementation of comparator in cmos 50 nm technology
Study and implementation of comparator in cmos 50 nm technology
 
Schmitt trigger basics
Schmitt trigger  basicsSchmitt trigger  basics
Schmitt trigger basics
 
Operational amplifier
Operational amplifierOperational amplifier
Operational amplifier
 
Operation amplifier
Operation amplifierOperation amplifier
Operation amplifier
 
Op-Amp 1
Op-Amp 1Op-Amp 1
Op-Amp 1
 
Unit-II Applications of Operational Amplifier
Unit-II Applications of Operational AmplifierUnit-II Applications of Operational Amplifier
Unit-II Applications of Operational Amplifier
 
Op amp-electronics
Op amp-electronicsOp amp-electronics
Op amp-electronics
 
Sample and hold circuit
Sample and hold circuitSample and hold circuit
Sample and hold circuit
 
Sample and hold instru
Sample and hold instru Sample and hold instru
Sample and hold instru
 
Operational Amplifier Part 1
Operational Amplifier Part 1Operational Amplifier Part 1
Operational Amplifier Part 1
 
op-amp
op-ampop-amp
op-amp
 
Lesson 8 op amps
Lesson 8 op ampsLesson 8 op amps
Lesson 8 op amps
 
Operational Amplifier (OpAmp)
Operational Amplifier (OpAmp)Operational Amplifier (OpAmp)
Operational Amplifier (OpAmp)
 
Basic of an OP-AMP
Basic of an OP-AMPBasic of an OP-AMP
Basic of an OP-AMP
 
Unit-I Characteristics of opamp
Unit-I Characteristics of opampUnit-I Characteristics of opamp
Unit-I Characteristics of opamp
 
Op amp
Op ampOp amp
Op amp
 
Operational amplifier
Operational amplifierOperational amplifier
Operational amplifier
 
opamp
opampopamp
opamp
 
Buffer op amplifier
Buffer op amplifierBuffer op amplifier
Buffer op amplifier
 

Similar to An 849

EC3451 LINEAR INTEGRATED CIRCUITS UNIT 1 .pdf
EC3451 LINEAR INTEGRATED CIRCUITS UNIT 1 .pdfEC3451 LINEAR INTEGRATED CIRCUITS UNIT 1 .pdf
EC3451 LINEAR INTEGRATED CIRCUITS UNIT 1 .pdf
VanithaR25
 
Op amp comparator
Op amp comparatorOp amp comparator
Op amp comparator
Ahmadoof
 
An operational amplifier for merge
An operational amplifier   for mergeAn operational amplifier   for merge
An operational amplifier for merge
beneden.morong
 

Similar to An 849 (20)

battery charging circuits
battery charging circuitsbattery charging circuits
battery charging circuits
 
EC3451 LINEAR INTEGRATED CIRCUITS UNIT 1 .pdf
EC3451 LINEAR INTEGRATED CIRCUITS UNIT 1 .pdfEC3451 LINEAR INTEGRATED CIRCUITS UNIT 1 .pdf
EC3451 LINEAR INTEGRATED CIRCUITS UNIT 1 .pdf
 
LIC UNIT I.pptx
LIC UNIT I.pptxLIC UNIT I.pptx
LIC UNIT I.pptx
 
Op amp comparator
Op amp comparatorOp amp comparator
Op amp comparator
 
SESD_Lect8_OpAmp_limitations.pdf
SESD_Lect8_OpAmp_limitations.pdfSESD_Lect8_OpAmp_limitations.pdf
SESD_Lect8_OpAmp_limitations.pdf
 
Electrónica: Probador de LOPT/FBT Flyback
Electrónica: Probador de LOPT/FBT FlybackElectrónica: Probador de LOPT/FBT Flyback
Electrónica: Probador de LOPT/FBT Flyback
 
Amplificador operacional
Amplificador operacionalAmplificador operacional
Amplificador operacional
 
Probador de-flybacks
Probador de-flybacksProbador de-flybacks
Probador de-flybacks
 
Slew rate, Open and closed loop configurations
Slew rate, Open and closed loop configurationsSlew rate, Open and closed loop configurations
Slew rate, Open and closed loop configurations
 
An operational amplifier for merge
An operational amplifier   for mergeAn operational amplifier   for merge
An operational amplifier for merge
 
Chapter 05. ppt operational amplifier
Chapter 05.    ppt operational amplifierChapter 05.    ppt operational amplifier
Chapter 05. ppt operational amplifier
 
Automatic doorbell with object detection
Automatic doorbell with object detectionAutomatic doorbell with object detection
Automatic doorbell with object detection
 
Op amp basics
Op amp basicsOp amp basics
Op amp basics
 
Operational Amplifiers
Operational AmplifiersOperational Amplifiers
Operational Amplifiers
 
Three Phase Fault Analysis With Auto Reset On Temporary Fault And Permanent Trip
Three Phase Fault Analysis With Auto Reset On Temporary Fault And Permanent TripThree Phase Fault Analysis With Auto Reset On Temporary Fault And Permanent Trip
Three Phase Fault Analysis With Auto Reset On Temporary Fault And Permanent Trip
 
Operational%20 amplifier
Operational%20 amplifierOperational%20 amplifier
Operational%20 amplifier
 
Analog CMOS design
Analog CMOS designAnalog CMOS design
Analog CMOS design
 
Reyes
ReyesReyes
Reyes
 
LIC UNIT II.pptx
LIC UNIT II.pptxLIC UNIT II.pptx
LIC UNIT II.pptx
 
analog elecronic designLecture 2 (1).pptx
analog elecronic designLecture 2 (1).pptxanalog elecronic designLecture 2 (1).pptx
analog elecronic designLecture 2 (1).pptx
 

More from Bipin Kujur

Th writing-grammar-mistakes-140501125825-phpapp01
Th writing-grammar-mistakes-140501125825-phpapp01Th writing-grammar-mistakes-140501125825-phpapp01
Th writing-grammar-mistakes-140501125825-phpapp01
Bipin Kujur
 
Mit6 007 s11_lec20
Mit6 007 s11_lec20Mit6 007 s11_lec20
Mit6 007 s11_lec20
Bipin Kujur
 
3 electromagneticwaves
3 electromagneticwaves3 electromagneticwaves
3 electromagneticwaves
Bipin Kujur
 
Design rules reference
Design rules referenceDesign rules reference
Design rules reference
Bipin Kujur
 
Module 9 setting up the pcb
Module 9   setting up the pcbModule 9   setting up the pcb
Module 9 setting up the pcb
Bipin Kujur
 

More from Bipin Kujur (10)

Th writing-grammar-mistakes-140501125825-phpapp01
Th writing-grammar-mistakes-140501125825-phpapp01Th writing-grammar-mistakes-140501125825-phpapp01
Th writing-grammar-mistakes-140501125825-phpapp01
 
Gvel
GvelGvel
Gvel
 
Lecture12
Lecture12Lecture12
Lecture12
 
Logic families
Logic  familiesLogic  families
Logic families
 
Mit6 007 s11_lec20
Mit6 007 s11_lec20Mit6 007 s11_lec20
Mit6 007 s11_lec20
 
An 1109
An 1109An 1109
An 1109
 
An 0971
An 0971An 0971
An 0971
 
3 electromagneticwaves
3 electromagneticwaves3 electromagneticwaves
3 electromagneticwaves
 
Design rules reference
Design rules referenceDesign rules reference
Design rules reference
 
Module 9 setting up the pcb
Module 9   setting up the pcbModule 9   setting up the pcb
Module 9 setting up the pcb
 

An 849

  • 1. AN-849 APPLICATION NOTE OneTechnologyWay • P.O. Box 9106 • Norwood, MA 02062-9106, U.S.A. •Tel: 781.329.4700 • Fax: 781.461.3113 • www.analog.com Rev. A | Page 1 of 8 Using Op Amps as Comparators by James Bryant INTRODUCTION A comparator is a device with two input terminals, inverting and noninverting, and an output that usually swings from rail to rail. So is an op amp. V+ V– V+ V– 06125-001 Figure 1. A comparator has low offset, high gain, and high common-mode rejection. So does an op amp. So what is the difference? A comparator has a logic output that indicates which of the two inputs is at a higher potential. If its output is TTL or CMOS compatible (and many comparators are), it is always intended to be at one rail or the other—or making a rapid transition between the two. An op amp has an analog output that is not typically close to the supply rails, but is somewhere between them. It is designed to be used in closed-loop applications with feedback from its output to its inverting input. But the outputs of most modern op amps can swing close to their supply rails. Why not use them as comparators? Op amps have high gain, low offset, and high common-mode rejection. They usually have lower bias current and are cheaper than comparators. In addition, op amps are often available in packages of two or four—if you need three op amps and a comparator, it seems pointless to buy four op amps, not use one of them, and then buy a separate comparator. However, the best advice on using an op amp as comparator is very simple—don’t! Comparators are designed to work as open-loop systems, to drive logic circuits, and to work at high speed, even when overdriven. Op amps are designed for none of these. They are intended to work as closed-loop systems, to drive simple resistive or reactive loads, and should never be overdriven to saturation. But it is tempting to use op amps as comparators for a number of reasons. The remainder of this document summarizes the reasons and warns of possible unexpected consequences of using an op amp as a comparator. WHY USE AN OP AMP AS A COMPARATOR? • Convenience • Economy • Low IB • Low VOS There are several reasons to use op amps as comparators. Some are technical, one is purely economic. Op amps are manufactured as single devices, but also as duals and quads, two or four op amps on a single chip. These duals and quads are cheaper than two or four separate op amps and occupy less board space, saving yet more money. It is economical to use the spare op amp in a quad as a comparator rather than buying an additional comparator, but this is not a good design practice. Comparators are designed for clean fast switching and, as a result, often have worse dc parameters than many op amps. So it may be convenient to use an op amp as a comparator in applications requiring low VOS, low IB, and wide CMR. It is never worthwhile to use an op amp as a comparator if high speed is important. WHY NOT USE AN OP AMP AS A COMPARATOR? • Speed • Inconvenient input structures • Inconvenient logic structures • Stability/hysteresis There are several reasons not to use op amps as comparators. First and foremost is speed, but there are also output levels, stability (and hysteresis), and a number of input structure considerations. The following sections provide more detail.
  • 2. AN-849 Rev. A | Page 2 of 8 Most comparators are quite fast and some are very fast indeed—but so are some op amps. Why must we expect low speed when using an op amp as a comparator? A comparator is designed to be used with large differential input voltages, whereas op amps typically operate closed loop with their input voltages minimized by negative feedback. When an op amp is overdriven, sometimes by only a few millivolts, some of its stages may saturate. If this occurs, the device takes a comparatively long time to come out of saturation, and is, therefore, much slower than if it were unsaturated. OUTPUT OF OP AMP USED AS A COMPARATOR OUTPUT OF OP AMP USED CLOSED-LOOP (NO SATURATION/ DESATURATION) INPUT DELAY DUE TO DESATURATION t0 06125-002 Figure 2. The desaturation time of an overdriven op amp is likely to be considerably longer than its normal group delay (effectively the time a signal takes from input to output) and often depends on the amount of overdrive. Because few op amps are characterized for their recovery times from differing levels of overdrive, it is necessary for the user to determine, by experiment, the delays likely to result from the levels of overdrive expected in a particular application. The value used in design calculations should be at least twice the worst value seen in any tests, because the samples tested may not be representative. The output of a purpose-built comparator is designed to drive a particular logic family or families. Often there is a separate supply for the output stage to ensure that the logic levels are correct. A modern op amp usually has rail-to-rail output—its maximum positive level is close to the positive supply, and the minimum negative level is close to the negative supply. (Older designs used structures with headroom of more than 1.5 V to both supplies.) OP AMP LOGIC 06125-003 Figure 3. If logic and op amp share the same supply, a rail-to-rail op amp can drive CMOS and TTL logic families successfully, but if the op amp and logic have different supplies, additional interface circuitry is necessary between them. Note that this applies to an op amp with ±5 V supplies that must drive logic with +5 V supply; the logic is liable to be damaged if −5 V is applied to it. The simplest interface circuits are inverters. They may be built with NPN transistors, but these draw base current. N-channel MOSFET transistors are more convenient. OP AMP +VA –VA RL RB LOGIC +VL –VL LOGICOP AMP +VA –VA RL +VL –VL 06125-004 Figure 4. RB sets the transistor base current, and RL sets the collector/drain current. The lower their value, the faster the inverter, but the more power it consumes. Values of a few kilohms are usually used. The N-channel MOS device should have a low gate threshold voltage (<2 V) and a gate-source breakdown voltage greater than the maximum output voltages of the op amp. Usually, ±25 V is sufficient. Even though the op amp and the logic use different supplies, they must be related to each other. The op amp positive supply, +VA, must be more positive than the logic negative supply, −VL, by at least 3 V to provide enough voltage to turn on the transistor or the MOSFET gate. In addition, the op amp negative supply must not be positive relative to the logic negative supply, although it may be connected to it. One must, of course, observe the absolute maximum ratings of all the devices used. LOGICOP AMP +VA –VA +VL –VL P N 06125-005 Figure 5. A complementary MOS inverter can be built with a P-channel and an N-channel MOSFET. This has the advantage of drawing no standby current, but it does have a large current spike during switching when both devices are briefly turned on together. With this arrangement, the op amp positive supply, +VA, must be equal to or greater than the logic positive supply, +VL. In addition, the op amp negative supply must be equal to or less than the logic negative supply.
  • 3. AN-849 Rev. A | Page 3 of 8 Another way of ensuring the correct logic interface levels is to use a clamp amplifier such as the AD8036. A clamp amplifier has positive and negative reference terminals, and its output is clamped to within 30 mV of the reference voltages if it attempts to go above or below the positive and negative limits. LOGICAD8036 +VA –VA +VL –VL 06125-006 Figure 6. So if the positive and negative logic supplies are connected to the reference inputs (and the amplifier supplies are outside the logic supplies), the amplifier output safely drives the logic. As previously noted, when op amps are used as comparators, they tend to respond more slowly than expected, due to saturation. For this reason, it is unlikely that there are many applications where op amps, used as comparators, are required to drive emitter-coupled logic (ECL), which is, after all, used where the highest logic speeds are required. ECL LOGIC OP AMP +VA –VA –5.2V R3 R1 R2 06125-007 Figure 7. But for the sake of completeness, Figure 7 shows an interface that uses just three resistors, R1, R2, and R3. They are chosen so that when the op amp output is at its positive limit, the level at the ECL gate input is −0.8 V, and when it is at its negative limit, the voltage is −1.6 V. The ratio of R1, R2, and R3 is set by this requirement; the absolute values are a compromise between speed and power economy. There are a number of issues to consider with the inputs of op amps used as comparators. The first assumption is that the input impedance of an op amp is infinite. While this is a reasonable starting position with voltage-feedback op amps, it cannot be held throughout the design process. It is invalid with current-feedback (transimpedance) op amps that have very low impedance at their inverting inputs. For this reason, they should never be used as comparators. The actual characteristics of the input impedance and the bias currents must be considered. Because most op amps have high impedance and low bias currents, there is usually little difficulty in ensuring that a design works with the actual range of expected values, rather than zero and infinity. But the calculations should be made. If they are not, Murphy’s Law guarantees that if anything can go wrong, it will. R = 0C = 0 IB+ = 0 IB– = 0 06125-008 Figure 8. Some op amps have input stages consisting of a long-tailed pair of transistors or FETs. These have high input impedance even when a large differential voltage is present between the inverting and noninverting inputs. But most op amps have more complex input structures, such as bias compensated input stages, or rail-to-rail input stages that are made of two input stages, one uses NPN or N-channel devices, and the other uses PNP or P-channel ones, connected in parallel to allow their common-mode range to include both supplies. Op amps are designed to operate with negative feedback, which minimizes their differential input. These complex structures may not respond well to large differential input voltages. It is not practical to discuss all possible architectures in this document, but the protection circuitry shown in Figure 9 illustrates one of many such structures. With differential inputs below ±0.6 V, the device has high input impedance—but above that, the protection diodes conduct and the differential input impedance drops abruptly. 06125-009 Figure 9. In many comparator applications, the differential input is limited to a few tens or hundreds of millivolts, but in many it is not, and these effects become important.
  • 4. AN-849 Rev. A | Page 4 of 8 READ THE DATA SHEET It is necessary to read the data sheet very carefully to determine if the worst-case voltages expected in the comparator application sufficiently affects the op amp performance to prevent proper operation. Experiment is not a good guide here, as some overvoltage effects are cumulative—a single overvoltage event does negligible damage, but many can slowly degrade offset, noise, or open-loop gain—or all three. While reading the data sheet, it is important to look for low values of absolute maximum differential input voltage, for graphs of bias current or input current vs. differential or common-mode voltage that show discontinuities or gross nonlinearity, and for evidence of phase-inversion. For more information on reading data sheets, see http://www.analog.com/raq_caveat and the URLs linked to that page, especially http://www.analog.com/raq_datasheet. If any of these potential dangers are present, it is essential to analyze the behavior of your system to determine if they prevent it from working properly. This may be done by a simulation, but do note that Spice and other models do not always map well to device behavior under conditions of large differential input. It may well be better to do simple pen and paper calculations of the effects to be expected, followed by some experiments. PHASE INVERSION Older FET input op amps, and even some bipolar types, suffered from a phenomenon called phase inversion or phase reversal. If the input went outside the allowed common-mode range, the inverting and noninverting inputs exchanged functions. INPUT OUTPUT 06125-010 Figure 10. As can well be imagined, this is not good news in a comparator application. It is important to ensure that any op amp used as a comparator is either free from phase inversion (most op amps in the last decade are designed this way) or that the system is designed so that the comparator inputs never approach the region where phase inversion might take place. Because op amp manufacturers do not want to call attention to phase inversion in their products, it tends to be mentioned as a limit to the common-mode range in the data tables, without many details of what can happen if the limit is exceeded. Keep this in mind, and if an op amp appears to be suffering from the phenomenon, test it. INSTABILITY An op amp used as a comparator has no negative feedback, and thus, has very high open-loop gain. During transitions, very small amounts of positive feedback can start oscillation. The feedback can arise from stray capacitance between the output and the noninverting input or from output currents flowing in common-ground impedance. STRAY C COMMON GROUND IMPEDANCE 06125-011 Figure 11. The cures are to minimize stray capacitance by proper layout and to ensure that the impedance seen by the noninverting input is as low as possible to attenuate any residual capacitive feedback. Capacitive feedback to the inverting input is only a problem with current feedback op amps (which are not recommended) and voltage feedback op amps that are not fully compensated (that is, not unity-gain stable). Ground current feedback is controlled by intelligent design of ground circuit layout. This is discussed in a number of Analog Devices, Inc. Application Notes, specifically AN-202, AN-214, AN-280, AN-345, and AN-347. For additional information about layout for analog system grounds, see http://www.analog.com/raq_groundingclean.
  • 5. AN-849 Rev. A | Page 5 of 8 HYSTERESIS Sometimes it is not possible to prevent instability by these measures. The only remaining possibility is to use a small amount of controlled positive feedback to produce hysteresis so that once a transition has started, the input must undergo significant reversal before the reverse transition can occur. R1 R2 SIGNAL APPLIED TO R1 MUST COME FROM A SOURCE IMPEDANCE WHICH IS MUCH LOWER THAN R1. OUTPUT SWING: VS HYSTERESIS VS(R1)/(R1 + R2) 06125-012 Figure 12. This can be done with two resistors; the amount of hysteresis is proportional to their ratio. The signal input to the comparator may be applied to either the inverting or the noninverting input, but if it is applied to the noninverting input, the source impedance must be low enough to have an insignificant effect on R1. Of course, if the source impedance is predictable enough, it may be used as R1. If the reference voltage is midway between the two comparator output voltages, as is the case with a symmetrical power supply and a ground reference, the introduction of hysteresis moves the positive and negative thresholds equal distances from the reference. But if the reference is nearer to one output than to the other, the thresholds are asymmetrically placed about the reference voltage. Calculation of thresholds when the reference is not midway between the supplies: Comparator output voltages are VP and VN. Reference voltage is VR. Positive threshold is 21 P1R2 RR VRVR + + Negative threshold is 21 N1R2 RR VRVR + + CONCLUSION In conclusion, although op amps are not designed to be used as comparators, there are, nevertheless, many applications where the use of an op amp as a comparator is a proper engineering decision. It is important to make an educated decision to ensure that the op amp chosen performs as expected. To do this, it is necessary to read the data sheet carefully and to consider the effects of nonideal op amp parameters on the application. Because the op amp is being used in a nonstandard manner, spice models may not reflect its actual behavior, and some experiment is advisable. Furthermore, because not all devices are typical in their behavior, some pessimism is warranted when interpreting the experimental results.
  • 6. AN-849 Rev. A | Page 6 of 8 NOTES
  • 7. AN-849 Rev. A | Page 7 of 8 NOTES
  • 8. AN-849 Rev. A | Page 8 of 8 NOTES ©2006-2011 Analog Devices, Inc. All rights reserved. Trademarks and registered trademarks are the property of their respective owners. AN06125-0-11/11(A)