# Comparator

Last updated

In electronics, a comparator is a device that compares two voltages or currents and outputs a digital signal indicating which is larger. It has two analog input terminals ${\displaystyle V_{+}\,}$ and ${\displaystyle V_{-}\,}$ and one binary digital output ${\displaystyle V_{\rm {o}}\,}$. The output is ideally

## Contents

${\displaystyle V_{\rm {o}}={\begin{cases}1,&{\mbox{if }}V_{+}>V_{-}\\0,&{\mbox{if }}V_{+}

A comparator consists of a specialized high-gain differential amplifier. They are commonly used in devices that measure and digitize analog signals, such as analog-to-digital converters [ clarification needed ] (ADCs), as well as relaxation oscillators.

## Differential voltage

The differential voltages must stay within the limits specified by the manufacturer. Early integrated comparators, like the LM111 family, and certain high-speed comparators like the LM119 family, require differential voltage ranges substantially lower than the power supply voltages (±15 V vs. 36 V). [1] Rail-to-rail comparators allow any differential voltages within the power supply range. When powered from a bipolar (dual rail) supply,

${\displaystyle V_{S-}\leq V_{+},V_{-}\leq V_{S+}}$

or, when powered from a unipolar TTL/CMOS power supply:

${\displaystyle 0\leq V_{+},V_{-}\leq V_{\rm {cc}}}$

Specific rail-to-rail comparators with p-n-p input transistors, like the LM139 family, allow the input potential to drop 0.3 volts below the negative supply rail, but do not allow it to rise above the positive rail. [2] Specific ultra-fast comparators, like the LMH7322, allow input signal to swing below the negative rail and above the positive rail, although by a narrow margin of only 0.2 V. [3] Differential input voltage (the voltage between two inputs) of a modern rail-to-rail comparator is usually limited only by the full swing of power supply.

## Op-amp voltage comparator

An operational amplifier (op-amp) has a well balanced difference input and a very high gain. This parallels the characteristics of comparators and can be substituted in applications with low-performance requirements. [4]

A comparator circuit compares two voltages and outputs either a 1 (the voltage at the plus side; VDD in the illustration) or a 0 (the voltage at the negative side) to indicate which is larger. Comparators are often used, for example, to check whether an input has reached some predetermined value. In most cases a comparator is implemented using a dedicated comparator IC, but op-amps may be used as an alternative. Comparator diagrams and op-amp diagrams use the same symbols.

Figure 1 above shows a comparator circuit. Note first that the circuit does not use feedback. The circuit amplifies the voltage difference between Vin and VREF, and it outputs the result at Vout. If Vin is greater than VREF, then voltage at Vout will rise to its positive saturation level; that is, to the voltage at the positive side. If Vin is lower than VREF, then Vout will fall to its negative saturation level, equal to the voltage at the negative side.

In practice, this circuit can be improved by incorporating a hysteresis voltage range to reduce its sensitivity to noise. The circuit shown in Figure 1, for example, will provide stable operation even when the Vin signal is somewhat noisy.

In practice, using an operational amplifier as a comparator presents several disadvantages as compared to using a dedicated comparator: [5]

1. Op-amps are designed to operate in the linear mode with negative feedback. Hence, an op-amp typically has a lengthy recovery time from saturation. Almost all op-amps have an internal compensation capacitor which imposes slew rate limitations for high frequency signals. Consequently, an op-amp makes a sloppy comparator with propagation delays that can be as long as tens of microseconds.
2. Since op-amps do not have any internal hysteresis, an external hysteresis network is always necessary for slow moving input signals.
3. The quiescent current specification of an op-amp is valid only when the feedback is active. Some op-amps show an increased quiescent current when the inputs are not equal.
4. A comparator is designed to produce well limited output voltages that easily interface with digital logic. Compatibility with digital logic must be verified while using an op-amp as a comparator.
5. Some multiple-section op-amps may exhibit extreme channel-channel interaction when used as comparators.
6. Many op-amps have back to back diodes between their inputs. Op-amp inputs usually follow each other so this is fine. But comparator inputs are not usually the same. The diodes can cause unexpected current through inputs.

## Working

A dedicated voltage comparator will generally be faster than a general-purpose operational amplifier used as a comparator, and may also contain additional features such as an accurate, internal reference voltage, adjustable hysteresis, and a clock gated input.

A dedicated voltage comparator chip such as LM339 is designed to interface with a digital logic interface (to a TTL or a CMOS). The output is a binary state often used to interface real world signals to digital circuitry (see analog to digital converter). If there is a fixed voltage source from, for example, a DC adjustable device in the signal path, a comparator is just the equivalent of a cascade of amplifiers. When the voltages are nearly equal, the output voltage will not fall into one of the logic levels, thus analog signals will enter the digital domain with unpredictable results. To make this range as small as possible, the amplifier cascade is high gain. The circuit consists of mainly Bipolar transistors. For very high frequencies, the input impedance of the stages is low. This reduces the saturation of the slow, large P-N junction bipolar transistors that would otherwise lead to long recovery times. Fast small Schottky diodes, like those found in binary logic designs, improve the performance significantly though the performance still lags that of circuits with amplifiers using analog signals. Slew rate has no meaning for these devices. For applications in flash ADCs the distributed signal across eight ports matches the voltage and current gain after each amplifier, and resistors then behave as level-shifters.

The LM339 accomplishes this with an open collector output. When the inverting input is at a higher voltage than the non inverting input, the output of the comparator connects to the negative power supply. When the non inverting input is higher than the inverting input, the output is 'floating' (has a very high impedance to ground). The gain of op amp as comparator is given by this equation V(out)=V(in)

## Key specifications

While it is easy to understand the basic task of a comparator, that is, comparing two voltages or currents, several parameters must be considered while selecting a suitable comparator:

### Speed and power

While in general comparators are "fast," their circuits are not immune to the classic speed-power tradeoff. High speed comparators use transistors with larger aspect ratios and hence also consume more power. [6] Depending on the application, select either a comparator with high speed or one that saves power. For example, nano-powered comparators in space-saving chip-scale packages (UCSP), DFN or SC70 packages such as MAX9027, LTC1540, LPV7215, MAX9060 and MCP6541 are ideal for ultra-low-power, portable applications. Likewise if a comparator is needed to implement a relaxation oscillator circuit to create a high speed clock signal then comparators having few nano seconds of propagation delay may be suitable. ADCMP572 (CML output), LMH7220 (LVDS Output), MAX999 (CMOS output / TTL output), LT1719 (CMOS output / TTL output), MAX9010 (TTL output), and MAX9601 (PECL output) are examples of some good high speed comparators.

### Hysteresis

A comparator normally changes its output state when the voltage between its inputs crosses through approximately zero volts. Small voltage fluctuations due to noise, always present on the inputs, can cause undesirable rapid changes between the two output states when the input voltage difference is near zero volts. To prevent this output oscillation, a small hysteresis of a few millivolts is integrated into many modern comparators. [7] For example, the LTC6702, MAX9021 and MAX9031 have internal hysteresis desensitizing them from input noise. In place of one switching point, hysteresis introduces two: one for rising voltages, and one for falling voltages. The difference between the higher-level trip value (VTRIP+) and the lower-level trip value (VTRIP-) equals the hysteresis voltage (VHYST).

If the comparator does not have internal hysteresis or if the input noise is greater than the internal hysteresis then an external hysteresis network can be built using positive feedback from the output to the non-inverting input of the comparator. The resulting Schmitt trigger circuit gives additional noise immunity and a cleaner output signal. Some comparators such as LMP7300, LTC1540, MAX931, MAX971 and ADCMP341 also provide the hysteresis control through a separate hysteresis pin. These comparators make it possible to add a programmable hysteresis without feedback or complicated equations. Using a dedicated hysteresis pin is also convenient if the source impedance is high since the inputs are isolated from the hysteresis network. [8] When hysteresis is added then a comparator cannot resolve signals within the hysteresis band.

### Output type

Because comparators have only two output states, their outputs are either near zero or near the supply voltage. Bipolar rail-to-rail comparators have a common-emitter output that produces a small voltage drop between the output and each rail. That drop is equal to the collector-to-emitter voltage of a saturated transistor. When output currents are light, output voltages of CMOS rail-to-rail comparators, which rely on a saturated MOSFET, range closer to the rail voltages than their bipolar counterparts. [9]

On the basis of outputs, comparators can also be classified as open drain or push–pull. Comparators with an open drain output stage use an external pull up resistor to a positive supply that defines the logic high level. Open drain comparators are more suitable for mixed-voltage system design. Since the output is high impedance for logic level high, open drain comparators can also be used to connect multiple comparators to a single bus. Push-pull output does not need a pull up resistor and can also source current, unlike an open drain output.

### Internal reference

The most frequent application for comparators is the comparison between a voltage and a stable reference. Most comparator manufacturers also offer comparators in which a reference voltage is integrated on to the chip. Combining the reference and comparator in one chip not only saves space, but also draws less supply current than a comparator with an external reference. [9] ICs with wide range of references are available such as MAX9062 (200 mV reference), LT6700 (400 mV reference), ADCMP350 (600 mV reference), MAX9025 (1.236 V reference), MAX9040 (2.048 V reference), TLV3012 (1.24 V reference) and TSM109 (2.5 V reference).

### Continuous versus clocked

A continuous comparator will output either a "1" or a "0" any time a high or low signal is applied to its input and will change quickly when the inputs are updated. However, many applications only require comparator outputs at certain instances, such as in A/D converters and memory. By only strobing a comparator at certain intervals, higher accuracy and lower power can be achieved with a clocked (or dynamic) comparator structure, also called a latched comparator. Often latched comparators employ strong positive feedback for a "regeneration phase" when a clock is high, and have a "reset phase" when the clock is low. [10] This is in contrast to a continuous comparator, which can only employ weak positive feedback since there is no reset period.

## Applications

### Null detectors

A null detector identifies when a given value is zero. Comparators are ideal for null detection comparison measurements, since they are equivalent to a very high gain amplifier with well-balanced inputs and controlled output limits. The null detector circuit compares two input voltages: an unknown voltage and a reference voltage, usually referred to as vu and vr. The reference voltage is usually on the non-inverting input (+), while the unknown voltage is usually on the inverting input (). (A circuit diagram would display the inputs according to their sign with respect to the output when a particular input is greater than the other.) Unless the inputs are nearly equal (see below), the output is either positive or negative, for example ±12 V. In the case of a null detector the aim is to detect when the input voltages are nearly equal, which gives the value of the unknown voltage since the reference voltage is known.

When using a comparator as a null detector, accuracy is limited; an output of zero is given whenever the magnitude of the voltage difference multiplied by the gain of the amplifier is within the voltage limits. For example, if the gain is 106, and the voltage limits are ±6 V, then an output of zero will be given if the voltage difference is less than 6 μV. One could refer to this as a fundamental uncertainty in the measurement. [11]

### Zero-crossing detectors

For this type of detector, a comparator detects each time an ac pulse changes polarity. The output of the comparator changes state each time the pulse changes its polarity, that is the output is HI (high) for a positive pulse and LO (low) for a negative pulse squares the input signal. [12]

### Relaxation oscillator

A comparator can be used to build a relaxation oscillator. It uses both positive and negative feedback. The positive feedback is a Schmitt trigger configuration. Alone, the trigger is a bistable multivibrator. However, the slow negative feedback added to the trigger by the RC circuit causes the circuit to oscillate automatically. That is, the addition of the RC circuit turns the hysteretic bistable multivibrator into an astable multivibrator. [13]

### Level shifter

This circuit requires only a single comparator with an open-drain output as in the LM393, TLV3011 or MAX9028. The circuit provides great flexibility in choosing the voltages to be translated by using a suitable pull up voltage. It also allows the translation of bipolar ±5 V logic to unipolar 3 V logic by using a comparator like the MAX972. [9]

### Analog-to-digital converters

When a comparator performs the function of telling if an input voltage is above or below a given threshold, it is essentially performing a 1-bit quantization. This function is used in nearly all analog to digital converters (such as flash, pipeline, successive approximation, delta-sigma modulation, folding, interpolating, dual-slope and others) in combination with other devices to achieve a multi-bit quantization. [14]

### Window detectors

Comparators can also be used as window detectors. In a window detector, a comparator is used to compare two voltages and determine whether a given input voltage is under voltage or over voltage.

### Absolute value detectors

Comparators can be used to create absolute value detectors. In an absolute value detector, two comparators and a digital logic gate are used to compare the absolute values of two voltages. [15]

## See also

This article incorporates  public domain material from the General Services Administration document "Federal Standard 1037C" .

## Related Research Articles

An amplifier, electronic amplifier or (informally) amp is an electronic device that can increase the power of a signal. It is a two-port electronic circuit that uses electric power from a power supply to increase the amplitude of a signal applied to its input terminals, producing a proportionally greater amplitude signal at its output. The amount of amplification provided by an amplifier is measured by its gain: the ratio of output voltage, current, or power to input. An amplifier is a circuit that has a power gain greater than one.

An operational amplifier is a DC-coupled high-gain electronic voltage amplifier with a differential input and, usually, a single-ended output. In this configuration, an op-amp produces an output potential that is typically hundreds of thousands of times larger than the potential difference between its input terminals. Operational amplifiers had their origins in analog computers, where they were used to perform mathematical operations in many linear, non-linear, and frequency-dependent circuits.

In electronics a relaxation oscillator is a nonlinear electronic oscillator circuit that produces a nonsinusoidal repetitive output signal, such as a triangle wave or square wave. The circuit consists of a feedback loop containing a switching device such as a transistor, comparator, relay, op amp, or a negative resistance device like a tunnel diode, that repetitively charges a capacitor or inductor through a resistance until it reaches a threshold level, then discharges it again. The period of the oscillator depends on the time constant of the capacitor or inductor circuit. The active device switches abruptly between charging and discharging modes, and thus produces a discontinuously changing repetitive waveform. This contrasts with the other type of electronic oscillator, the harmonic or linear oscillator, which uses an amplifier with feedback to excite resonant oscillations in a resonator, producing a sine wave. Relaxation oscillators are used to produce low frequency signals for applications such as blinking lights and electronic beepers and in voltage controlled oscillators (VCOs), inverters and switching power supplies, dual-slope analog to digital converters, and function generators.

A differential amplifier is a type of electronic amplifier that amplifies the difference between two input voltages but suppresses any voltage common to the two inputs. It is an analog circuit with two inputs and and one output in which the output is ideally proportional to the difference between the two voltages

A preamplifier is an electronic amplifier that converts a weak electrical signal into an output signal strong enough to be noise-tolerant and strong enough for further processing, or for sending to a power amplifier and a loudspeaker. Without this, the final signal would be noisy or distorted. They are typically used to amplify signals from analog sensors such as microphones and pickups. Because of this, the preamplifier is often placed close to the sensor to reduce the effects of noise and interference.

In electronics, a Schmitt trigger is a comparator circuit with hysteresis implemented by applying positive feedback to the noninverting input of a comparator or differential amplifier. It is an active circuit which converts an analog input signal to a digital output signal. The circuit is named a "trigger" because the output retains its value until the input changes sufficiently to trigger a change. In the non-inverting configuration, when the input is higher than a chosen threshold, the output is high. When the input is below a different (lower) chosen threshold the output is low, and when the input is between the two levels the output retains its value. This dual threshold action is called hysteresis and implies that the Schmitt trigger possesses memory and can act as a bistable multivibrator. There is a close relation between the two kinds of circuits: a Schmitt trigger can be converted into a latch and a latch can be converted into a Schmitt trigger.

A buffer amplifier is one that provides electrical impedance transformation from one circuit to another, with the aim of preventing the signal source from being affected by whatever currents that the load may be produced with. The signal is 'buffered from' load currents. Two main types of buffer exist: the voltage buffer and the current buffer.

Almost all integrated circuits (ICs) have at least two pins that connect to the power rails of the circuit in which they are installed. These are known as the power-supply pins. However, the labeling of the pins varies by IC family and manufacturer.

Delta-sigma modulation is a method for encoding analog signals into digital signals as found in an analog-to-digital converter (ADC). It is also used to convert high bit-count, low-frequency digital signals into lower bit-count, higher-frequency digital signals as part of the process to convert digital signals into analog as part of a digital-to-analog converter (DAC).

This article illustrates some typical operational amplifier applications. A non-ideal operational amplifier's equivalent circuit has a finite input impedance, a non-zero output impedance, and a finite gain. A real op-amp has a number of non-ideal features as shown in the diagram, but here a simplified schematic notation is used, many details such as device selection and power supply connections are not shown. Operational amplifiers are optimised for use with negative feedback, and this article discusses only negative-feedback applications. When positive feedback is required, a comparator is usually more appropriate. See Comparator applications for further information.

Crossover distortion is a type of distortion which is caused by switching between devices driving a load. It is most commonly seen in complementary, or "push-pull", Class-B amplifier stages, although it is occasionally seen in other types of circuits as well.

A constant fraction discriminator (CFD) is an electronic signal processing device, designed to mimic the mathematical operation of finding a maximum of a pulse by finding the zero of its slope. Some signals do not have a sharp maximum, but short rise times .

A flash ADC is a type of analog-to-digital converter that uses a linear voltage ladder with a comparator at each "rung" of the ladder to compare the input voltage to successive reference voltages. Often these reference ladders are constructed of many resistors; however, modern implementations show that capacitive voltage division is also possible. The output of these comparators is generally fed into a digital encoder, which converts the inputs into a binary value.

The operational transconductance amplifier (OTA) is an amplifier whose differential input voltage produces an output current. Thus, it is a voltage controlled current source (VCCS). There is usually an additional input for a current to control the amplifier's transconductance. The OTA is similar to a standard operational amplifier in that it has a high impedance differential input stage and that it may be used with negative feedback.

In the field of electronics, a bootstrap circuit is one where part of the output of an amplifier stage is applied to the input, so as to alter the input impedance of the amplifier. When applied deliberately, the intention is usually to increase rather than decrease the impedance. Generally, any technique where part of the output of a system is used at startup is described as bootstrapping.

A fully differential amplifier (FDA) is a DC-coupled high-gain electronic voltage amplifier with differential inputs and differential outputs. In its ordinary usage, the output of the FDA is controlled by two feedback paths which, because of the amplifier's high gain, almost completely determine the output voltage for any given input.

A log amplifier is an amplifier for which the output voltage Vout is K times the natural log of the input voltage Vin. This can be expressed as,

The input offset voltage is a parameter defining the differential DC voltage required between the inputs of an amplifier, especially an operational amplifier (op-amp), to make the output zero.

The Millers theorem refers to the process of creating equivalent circuits. It asserts that a floating impedance element, supplied by two voltage sources connected in series, may be split into two grounded elements with corresponding impedances. There is also a dual Miller theorem with regards to impedance supplied by two current sources connected in parallel. The two versions are based on the two Kirchhoff's circuit laws.

A comparator is an electronic component that compares two input voltages. Comparators are closely related to operational amplifiers, but a comparator is designed to operate with positive feedback and with its output saturated at one power rail or the other. An op-amp can be pressed into service as a poorly performing comparator if necessary, but its slew rate will be impaired.

## References

1. LM111/LM211/LM311 datasheet. Texas Instruments. August 2003. Retrieved 2014-07-02.
2. LM139/LM239/LM339/LM2901/LM3302 datasheet. Texas Instruments. August 2012. Retrieved 2014-07-02.
3. LMH7322 datasheet. Texas Instruments. March 2013. Retrieved 2014-07-02.
4. Malmstadt, Enke and Crouch, Electronics and Instrumentation for Scientists, The Benjamin/Cummings Publishing Company, Inc., 1981, ISBN   0-8053-6917-1, Chapter 5.
5. Ron Mancini, "Designing with comparators," EDN, March 29, 2001.
6. Rogenmoser, R.; Kaeslin, H, "The impact of transistor sizing on power efficiency in submicron CMOS circuits," Solid-State Circuits, IEEE Journal of Volume 32, Issue 7, Jul 1997 Page(s):1142–1145.
7. Ron Mancini, "Adding Hysteresis to comparators Archived 2005-02-21 at the Wayback Machine ," EDN, May 3, 2001.
8. AN3616, Maxim Integrated Products, Adding Extra Hysteresis to Comparators.
9. AN886, Maxim Integrated Products, Selecting the Right Comparator.
10. Pedro M. Figueiredo, João C. Vital (2009). Offset Reduction Techniques in High-Speed Analog-to-Digital Converters: Analysis, Design and Tradeoffs. Springer. pp. 54–62. ISBN   978-1-4020-9715-7.
11. Malmstadt, Howard V.; Enke, Christie G.; Crouch, Stanley R. (January 1981), , The Benjamin/Cummings Publishing Co, pp.  108–110, ISBN   978-0-8053-6917-5
12. Electronics and Instrumentation for Scientists. Malmstadt, Enke, and Crouch, The Benjamin/Cummings Publishing Co., In., 1981, p.230.
13. Paul Horowitz and Winfield Hill: The Art of Electronics, Cambridge University Press, Second edition, Cambridge 1989, pp.284–285.
14. Phillip Allen and Douglas Holberg: CMOS Analog Circuit Design, Oxford University Press, Second edition, Oxford 2002.
15. "Iranmanesh, S., Rodriguez-Villegas, E. (2016). CMOS implementation of a low power absolute value comparator circuit. IEEE NEWCAS, June 2016". doi:10.1109/NEWCAS.2016.7604807.Cite journal requires |journal= (help)