Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
AN-849APPLICATION NOTEOneTechnologyWay • P.O. Box 9106 • Norwood, MA 02062-9106, U.S.A. •Tel: 781.329.4700 • Fax: 781.461....
AN-849Rev. A | Page 2 of 8Most comparators are quite fast and some are very fast indeed—butso are some op amps. Why must w...
AN-849Rev. A | Page 3 of 8Another way of ensuring the correct logic interface levels is touse a clamp amplifier such as th...
AN-849Rev. A | Page 4 of 8READ THE DATA SHEETIt is necessary to read the data sheet very carefully to determineif the wors...
AN-849Rev. A | Page 5 of 8HYSTERESISSometimes it is not possible to prevent instability by thesemeasures. The only remaini...
AN-849Rev. A | Page 6 of 8NOTES
AN-849Rev. A | Page 7 of 8NOTES
AN-849Rev. A | Page 8 of 8NOTES©2006-2011 Analog Devices, Inc. All rights reserved. Trademarks andregistered trademarks ar...
Upcoming SlideShare
Loading in …5
×

An 849

216 views

Published on

  • Be the first to comment

  • Be the first to like this

An 849

  1. 1. AN-849APPLICATION NOTEOneTechnologyWay • P.O. Box 9106 • Norwood, MA 02062-9106, U.S.A. •Tel: 781.329.4700 • Fax: 781.461.3113 • www.analog.comRev. A | Page 1 of 8Using Op Amps as Comparatorsby James BryantINTRODUCTIONA comparator is a device with two input terminals, invertingand noninverting, and an output that usually swings from rail torail. So is an op amp.V+V–V+V–06125-001Figure 1.A comparator has low offset, high gain, and high common-moderejection. So does an op amp.So what is the difference? A comparator has a logic output thatindicates which of the two inputs is at a higher potential. If itsoutput is TTL or CMOS compatible (and many comparatorsare), it is always intended to be at one rail or the other—ormaking a rapid transition between the two.An op amp has an analog output that is not typically close to thesupply rails, but is somewhere between them. It is designed tobe used in closed-loop applications with feedback from itsoutput to its inverting input. But the outputs of most modernop amps can swing close to their supply rails. Why not use themas comparators?Op amps have high gain, low offset, and high common-moderejection. They usually have lower bias current and are cheaperthan comparators. In addition, op amps are often available inpackages of two or four—if you need three op amps and acomparator, it seems pointless to buy four op amps, not use oneof them, and then buy a separate comparator.However, the best advice on using an op amp as comparator isvery simple—don’t!Comparators are designed to work as open-loop systems, todrive logic circuits, and to work at high speed, even whenoverdriven. Op amps are designed for none of these. They areintended to work as closed-loop systems, to drive simpleresistive or reactive loads, and should never be overdriven tosaturation.But it is tempting to use op amps as comparators for a numberof reasons. The remainder of this document summarizes thereasons and warns of possible unexpected consequences ofusing an op amp as a comparator.WHY USE AN OP AMP AS A COMPARATOR?• Convenience• Economy• Low IB• Low VOSThere are several reasons to use op amps as comparators. Someare technical, one is purely economic. Op amps are manufacturedas single devices, but also as duals and quads, two or four opamps on a single chip. These duals and quads are cheaper thantwo or four separate op amps and occupy less board space, savingyet more money. It is economical to use the spare op amp in aquad as a comparator rather than buying an additionalcomparator, 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 beconvenient to use an op amp as a comparator in applicationsrequiring low VOS, low IB, and wide CMR. It is never worthwhileto 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/hysteresisThere 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 structureconsiderations. The following sections provide more detail.
  2. 2. AN-849Rev. A | Page 2 of 8Most comparators are quite fast and some are very fast indeed—butso are some op amps. Why must we expect low speed when usingan op amp as a comparator? A comparator is designed to be usedwith large differential input voltages, whereas op amps typicallyoperate closed loop with their input voltages minimized by negativefeedback. When an op amp is overdriven, sometimes by only a fewmillivolts, some of its stages may saturate. If this occurs, the devicetakes a comparatively long time to come out of saturation, and is,therefore, much slower than if it were unsaturated.OUTPUT OF OP AMP USEDAS A COMPARATOROUTPUT OF OP AMP USEDCLOSED-LOOP(NO SATURATION/DESATURATION)INPUT DELAY DUE TODESATURATIONt0 06125-002Figure 2.The desaturation time of an overdriven op amp is likely to beconsiderably longer than its normal group delay (effectively thetime a signal takes from input to output) and often depends onthe amount of overdrive.Because few op amps are characterized for their recovery timesfrom differing levels of overdrive, it is necessary for the user todetermine, by experiment, the delays likely to result from thelevels of overdrive expected in a particular application. Thevalue used in design calculations should be at least twice theworst value seen in any tests, because the samples tested maynot be representative.The output of a purpose-built comparator is designed to drive aparticular logic family or families. Often there is a separate supplyfor the output stage to ensure that the logic levels are correct.A modern op amp usually has rail-to-rail output—its maximumpositive level is close to the positive supply, and the minimumnegative level is close to the negative supply. (Older designs usedstructures with headroom of more than 1.5 V to both supplies.)OP AMP LOGIC06125-003Figure 3.If logic and op amp share the same supply, a rail-to-rail op ampcan drive CMOS and TTL logic families successfully, but if theop amp and logic have different supplies, additional interfacecircuitry is necessary between them. Note that this applies to anop amp with ±5 V supplies that must drive logic with +5 Vsupply; the logic is liable to be damaged if −5 V is applied to it.The simplest interface circuits are inverters. They may be builtwith NPN transistors, but these draw base current. N-channelMOSFET transistors are more convenient.OP AMP+VA–VARLRBLOGIC+VL–VLLOGICOP AMP+VA–VARL+VL–VL06125-004Figure 4.RB sets the transistor base current, and RL sets the collector/draincurrent. The lower their value, the faster the inverter, but themore power it consumes. Values of a few kilohms are usuallyused. The N-channel MOS device should have a low gatethreshold voltage (<2 V) and a gate-source breakdown voltagegreater than the maximum output voltages of the op amp.Usually, ±25 V is sufficient. Even though the op amp and thelogic use different supplies, they must be related to each other.The op amp positive supply, +VA, must be more positive thanthe logic negative supply, −VL, by at least 3 V to provide enoughvoltage to turn on the transistor or the MOSFET gate. Inaddition, the op amp negative supply must not be positiverelative to the logic negative supply, although it may beconnected to it. One must, of course, observe the absolutemaximum ratings of all the devices used.LOGICOP AMP+VA–VA+VL–VLPN06125-005Figure 5.A complementary MOS inverter can be built with a P-channeland an N-channel MOSFET. This has the advantage of drawingno standby current, but it does have a large current spike duringswitching when both devices are briefly turned on together.With this arrangement, the op amp positive supply, +VA, mustbe equal to or greater than the logic positive supply, +VL. Inaddition, the op amp negative supply must be equal to or lessthan the logic negative supply.
  3. 3. AN-849Rev. A | Page 3 of 8Another way of ensuring the correct logic interface levels is touse a clamp amplifier such as the AD8036. A clamp amplifierhas positive and negative reference terminals, and its output isclamped to within 30 mV of the reference voltages if it attemptsto go above or below the positive and negative limits.LOGICAD8036+VA–VA+VL–VL06125-006Figure 6.So if the positive and negative logic supplies are connected tothe reference inputs (and the amplifier supplies are outside thelogic 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 tosaturation. For this reason, it is unlikely that there are manyapplications where op amps, used as comparators, are requiredto drive emitter-coupled logic (ECL), which is, after all, usedwhere the highest logic speeds are required.ECLLOGICOP AMP+VA–VA–5.2VR3R1R206125-007Figure 7.But for the sake of completeness, Figure 7 shows an interfacethat uses just three resistors, R1, R2, and R3. They are chosen sothat when the op amp output is at its positive limit, the level atthe 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 thisrequirement; the absolute values are a compromise betweenspeed and power economy.There are a number of issues to consider with the inputs of opamps used as comparators. The first assumption is that theinput impedance of an op amp is infinite. While this is areasonable starting position with voltage-feedback op amps, itcannot be held throughout the design process. It is invalid withcurrent-feedback (transimpedance) op amps that have very lowimpedance at their inverting inputs. For this reason, theyshould never be used as comparators.The actual characteristics of the input impedance and the biascurrents must be considered. Because most op amps have highimpedance and low bias currents, there is usually little difficultyin ensuring that a design works with the actual range ofexpected values, rather than zero and infinity. But thecalculations should be made. If they are not, Murphy’s Lawguarantees that if anything can go wrong, it will.R = 0C = 0IB+ = 0IB– = 006125-008Figure 8.Some op amps have input stages consisting of a long-tailed pairof transistors or FETs. These have high input impedance evenwhen a large differential voltage is present between theinverting and noninverting inputs. But most op amps havemore complex input structures, such as bias compensated inputstages, or rail-to-rail input stages that are made of two inputstages, one uses NPN or N-channel devices, and the other usesPNP or P-channel ones, connected in parallel to allow theircommon-mode range to include both supplies.Op amps are designed to operate with negative feedback, whichminimizes their differential input. These complex structuresmay not respond well to large differential input voltages. It isnot practical to discuss all possible architectures in thisdocument, but the protection circuitry shown in Figure 9illustrates one of many such structures. With differential inputsbelow ±0.6 V, the device has high input impedance—but abovethat, the protection diodes conduct and the differential inputimpedance drops abruptly. 06125-009Figure 9.In many comparator applications, the differential input islimited to a few tens or hundreds of millivolts, but in many it isnot, and these effects become important.
  4. 4. AN-849Rev. A | Page 4 of 8READ THE DATA SHEETIt is necessary to read the data sheet very carefully to determineif the worst-case voltages expected in the comparator applicationsufficiently affects the op amp performance to prevent properoperation. Experiment is not a good guide here, as someovervoltage effects are cumulative—a single overvoltage eventdoes 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 lowvalues of absolute maximum differential input voltage, forgraphs of bias current or input current vs. differential orcommon-mode voltage that show discontinuities or grossnonlinearity, and for evidence of phase-inversion.For more information on reading data sheets, seehttp://www.analog.com/raq_caveat and the URLs linked tothat page, especially http://www.analog.com/raq_datasheet.If any of these potential dangers are present, it is essential toanalyze the behavior of your system to determine if theyprevent it from working properly. This may be done by asimulation, but do note that Spice and other models do notalways map well to device behavior under conditions of largedifferential input. It may well be better to do simple pen andpaper calculations of the effects to be expected, followed bysome experiments.PHASE INVERSIONOlder FET input op amps, and even some bipolar types, sufferedfrom a phenomenon called phase inversion or phase reversal. Ifthe input went outside the allowed common-mode range, theinverting and noninverting inputs exchanged functions.INPUTOUTPUT06125-010Figure 10.As can well be imagined, this is not good news in a comparatorapplication. It is important to ensure that any op amp used as acomparator is either free from phase inversion (most op ampsin the last decade are designed this way) or that the system isdesigned so that the comparator inputs never approach theregion where phase inversion might take place.Because op amp manufacturers do not want to call attention tophase inversion in their products, it tends to be mentioned as alimit to the common-mode range in the data tables, withoutmany details of what can happen if the limit is exceeded. Keepthis in mind, and if an op amp appears to be suffering from thephenomenon, test it.INSTABILITYAn op amp used as a comparator has no negative feedback, andthus, has very high open-loop gain. During transitions, verysmall amounts of positive feedback can start oscillation. Thefeedback can arise from stray capacitance between the outputand the noninverting input or from output currents flowing incommon-ground impedance.STRAY C COMMON GROUNDIMPEDANCE06125-011Figure 11.The cures are to minimize stray capacitance by proper layout andto ensure that the impedance seen by the noninverting input is aslow as possible to attenuate any residual capacitive feedback.Capacitive feedback to the inverting input is only a problem withcurrent feedback op amps (which are not recommended) andvoltage feedback op amps that are not fully compensated (that is,not unity-gain stable).Ground current feedback is controlled by intelligent design ofground circuit layout. This is discussed in a number of AnalogDevices, Inc. Application Notes, specifically AN-202, AN-214,AN-280, AN-345, and AN-347. For additional informationabout layout for analog system grounds, seehttp://www.analog.com/raq_groundingclean.
  5. 5. AN-849Rev. A | Page 5 of 8HYSTERESISSometimes it is not possible to prevent instability by thesemeasures. The only remaining possibility is to use a smallamount of controlled positive feedback to produce hysteresis sothat once a transition has started, the input must undergosignificant reversal before the reverse transition can occur.R1R2SIGNAL APPLIED TO R1 MUST COMEFROM A SOURCE IMPEDANCE WHICHIS MUCH LOWER THAN R1.OUTPUT SWING: VSHYSTERESISVS(R1)/(R1 + R2)06125-012Figure 12.This can be done with two resistors; the amount of hysteresis isproportional to their ratio. The signal input to the comparatormay be applied to either the inverting or the noninvertinginput, but if it is applied to the noninverting input, the sourceimpedance must be low enough to have an insignificant effecton R1. Of course, if the source impedance is predictableenough, it may be used as R1.If the reference voltage is midway between the two comparatoroutput voltages, as is the case with a symmetrical power supplyand a ground reference, the introduction of hysteresis movesthe positive and negative thresholds equal distances from thereference. But if the reference is nearer to one output than tothe other, the thresholds are asymmetrically placed about thereference voltage.Calculation of thresholds when the reference is notmidway between the supplies:Comparator output voltages are VP and VN.Reference voltage is VR.Positive threshold is21P1R2RRVRVR++Negative threshold is21N1R2RRVRVR++CONCLUSIONIn conclusion, although op amps are not designed to be used ascomparators, there are, nevertheless, many applications wherethe use of an op amp as a comparator is a proper engineeringdecision. It is important to make an educated decision to ensurethat the op amp chosen performs as expected.To do this, it is necessary to read the data sheet carefully and toconsider the effects of nonideal op amp parameters on theapplication. Because the op amp is being used in a nonstandardmanner, spice models may not reflect its actual behavior, andsome experiment is advisable. Furthermore, because not alldevices are typical in their behavior, some pessimism iswarranted when interpreting the experimental results.
  6. 6. AN-849Rev. A | Page 6 of 8NOTES
  7. 7. AN-849Rev. A | Page 7 of 8NOTES
  8. 8. AN-849Rev. A | Page 8 of 8NOTES©2006-2011 Analog Devices, Inc. All rights reserved. Trademarks andregistered trademarks are the property of their respective owners.AN06125-0-11/11(A)

×