Difference between revisions of "Comparators"

From Mech
Jump to navigationJump to search
Line 6: Line 6:


Comparators are much like opamps, but opamps intend to have a continuous output Vout = G(V<sub>+</sub> - V<sub>--</sub>), where comparators intend to saturate, that is, always to have a full positive or zero output.
Comparators are much like opamps, but opamps intend to have a continuous output Vout = G(V<sub>+</sub> - V<sub>--</sub>), where comparators intend to saturate, that is, always to have a full positive or zero output.

<br>


An ideal comparator, like an ideal opamp, has infinite input impedance. That means that it observes the voltage at its input while allowing no current to flow. Real comparators are pretty close to this ideal, swallowing only a few nA. This is very useful when you have a high impedance signal (having very little current available) such as a phototransistor.
An ideal comparator, like an ideal opamp, has infinite input impedance. That means that it observes the voltage at its input while allowing no current to flow. Real comparators are pretty close to this ideal, swallowing only a few nA. This is very useful when you have a high impedance signal (having very little current available) such as a phototransistor.
Line 13: Line 15:
We will focus on the LM311P, a particularly nice comparator. Look up its datasheet. You can use it as shown in figure 2, and it will work exactly as described above. [[image:lm311p.jpg|right]]
We will focus on the LM311P, a particularly nice comparator. Look up its datasheet. You can use it as shown in figure 2, and it will work exactly as described above. [[image:lm311p.jpg|right]]


<br>


The LM311P, like most comparators, is open-collector. That means it is capable of grounding its output to indicate logic low, but that's all it can do. It cannot drive its output high (to +5V for instance). All it can do to indicate logic high output is NOT ground its output. It's your job to pull the output high (with a "pull up resistor") and the LM311P will pull it low when it needs to. [[image:light.jpg|right]]
The LM311P, like most comparators, is open-collector. That means it is capable of grounding its output to indicate logic low, but that's all it can do. It cannot drive its output high (to +5V for instance). All it can do to indicate logic high output is NOT ground its output. It's your job to pull the output high (with a "pull up resistor") and the LM311P will pull it low when it needs to. [[image:light.jpg|right]]
Line 18: Line 21:
Why don't they include a pull up resistor inside? Sometimes they do. However, the open collector output allows you to pull it up to other voltages besides +5 at your whim, for instance to +3 or +24, or to drive an LED (and its limiting resisitor.) You can also arrange several comparators "wired OR", meaning the outputs of several comparators are connected and if any of them pulls the output to ground, it dominates all the others. You couldn't do that if one was pulling the output high and another pulling it low.
Why don't they include a pull up resistor inside? Sometimes they do. However, the open collector output allows you to pull it up to other voltages besides +5 at your whim, for instance to +3 or +24, or to drive an LED (and its limiting resisitor.) You can also arrange several comparators "wired OR", meaning the outputs of several comparators are connected and if any of them pulls the output to ground, it dominates all the others. You couldn't do that if one was pulling the output high and another pulling it low.


<br>
Now the complications. There are several, but comparators are nevertheless very easy, robust, useful components.

There are several limitations, but comparators are nevertheless very easy, robust, useful components.


* Comparators are limited in amount of current they can sink (sink means take to ground.) They can overheat and die. This one can sink 50mA -- a lot by comparator standards.
* Comparators are limited in amount of current they can sink (sink means take to ground.) They can overheat and die. This one can sink 50mA -- a lot by comparator standards.

Revision as of 08:07, 12 January 2007

A comparator subtracts two voltages and gives you a logic output. Thus it lives at the boundary between the analog world of continuous voltages, and the digital world of 1's and 0's, represented by +5V and 0V, logic high and logic low.

Comparators have two inputs, called inverting and non-inverting inputs, and labeled simply - and + on a circuit diagram. We will call the potential at these inputs V-- and V+. Don't confuse these inputs with power supply connections! See figure 1: inputs on the side, power on the top and bottom. Often power is not even shown, but if you neglect to provide it the chip won't work.

Just5.jpg

The output of a comparator is logic high (+5V) if V+ > V-- and low (0V) if V+ < V-- . If they are within 1mV of equal, anything goes.

Comparators are much like opamps, but opamps intend to have a continuous output Vout = G(V+ - V--), where comparators intend to saturate, that is, always to have a full positive or zero output.


An ideal comparator, like an ideal opamp, has infinite input impedance. That means that it observes the voltage at its input while allowing no current to flow. Real comparators are pretty close to this ideal, swallowing only a few nA. This is very useful when you have a high impedance signal (having very little current available) such as a phototransistor.

An ideal comparator, like an ideal opamp, has zero output impedance. That means, when it drives its output to 0V, it will maintain 0V regardless of how much current it has to sink in order to do so. Real comparators are pretty good -- if forced to sink too much current they may burn up, but the output voltage won't rise more than 100mV or so.

We will focus on the LM311P, a particularly nice comparator. Look up its datasheet. You can use it as shown in figure 2, and it will work exactly as described above.

Lm311p.jpg


The LM311P, like most comparators, is open-collector. That means it is capable of grounding its output to indicate logic low, but that's all it can do. It cannot drive its output high (to +5V for instance). All it can do to indicate logic high output is NOT ground its output. It's your job to pull the output high (with a "pull up resistor") and the LM311P will pull it low when it needs to.

Light.jpg

Why don't they include a pull up resistor inside? Sometimes they do. However, the open collector output allows you to pull it up to other voltages besides +5 at your whim, for instance to +3 or +24, or to drive an LED (and its limiting resisitor.) You can also arrange several comparators "wired OR", meaning the outputs of several comparators are connected and if any of them pulls the output to ground, it dominates all the others. You couldn't do that if one was pulling the output high and another pulling it low.


There are several limitations, but comparators are nevertheless very easy, robust, useful components.

  • Comparators are limited in amount of current they can sink (sink means take to ground.) They can overheat and die. This one can sink 50mA -- a lot by comparator standards.
  • Comparators are limited in the pull-up voltage they can withstand. This one can withstand +50V (positive only, mind you!) That's also huge.
  • LM311P has several connections you didn't want to know about: strobe, balance, and emitter. Tie strobe and balance to Vcc+ (the positive supply) and the emitter to Vcc- (which is usually ground)
  • LM311 runs happily with Vcc+ = 5V and Vcc- = 0V. There are many other ways to use it
  • LM311 allows its inputs to range independently anywhere from +15 to -15, without damage. Many comparators are much more finicky. For many, the range of the inputs must not exceed the range between the power supply rails (e.g. 0 to +5)