Electronics: Voltage Comparator


A voltage comparator is a common tool used in electronic design that signals a change in voltage level. Comparators are used in a wide variety of applications, and can commonly be found in analog-to-digital converters, digital logic designs, and even RAM chips in your computer. The example discussed below is pedagogical, but will suffice. Comparators used in the applications mentioned above are generally made of tougher stuff.

As an example, a simple voltage comparator utilizing an operational amplifier (See Op Amp for more information) serves as an excellent starting point.

A simple op amp voltage comparator compares two input voltages (V1, V2) and outputs a signal that determines which voltage is greater. This is a very simple task, but it is also very important in the world of electronics.

The principle behind a simple comparator is understanding that op amps have a gain, we will call A. For most op amps, A is on the order of 200,000. This value has no units, but can be thought of as a multiplier or constant. The two voltage inputs to the op amp (V1, V2) are the input voltages to be compared. The output (Vo) is the result of the comparison.

The equation:

Vo = A * ( V1 - V2 )
describes the basic functionality of the op amp. We will now re-label V2 as VR, which is short for reference voltage, for the rest of this discussion. This then transforms the last equation to:
Vo = A*( V1 - VR )

I already mentioned that A is very large, so it follows that any difference between V1 and VR will be greatly magnified (multiplied by a number on the order of 200,000). This causes something called saturation. Op amps saturate if the output voltage goes higher than the voltage level that actually powers the op amp. Think of how you can't create something from nothing: you can't create an output greater than your total input. The following diagram should clarify things some. The labels VCC and -VCC are the positive and negative voltage power connections. These are the maximum voltage levels for your output. Typically, they are set anywhere from +/- 3 volts to +/- 12 volts, but depend on the op amp being used. Consult op amp for more information.

   
             VCC
        |\   |
        |  \ |
V1 -----|-   \
        |      >--- VO
VR -----|+   /
        |  / |
        |/   |
            -VCC


Typical 741 op amp (Thank you to CamTarn for the ASCII art found at op amp)

So, from this diagram and the equations above, if V R is connected to some non-zero, known voltage level, and V 1 is connected to the voltage to compare, you will see a voltage difference ( V 1 - V R ). This difference will be multiplied by the enormous value A and the op amp will essentially saturate. We call this "hitting the rails," where the rails are generally the VCC and -VCC inputs (the power to the whole deal). So your output saturates, signaling a voltage is greater or less than the reference.

If the saturation occurs at the voltage VCC, the voltage you are comparing (V1) is greater than the reference VR and the difference in the equation is positive, hence, a positive output. If the saturation occurs at -VCC, then the compared voltage (V1) is less than the reference VR, and the difference in the equation is negative, you guessed it, a negative output.

A simple graph may help:


                       ^  Vo
                       |
                       |
                       |
                       |
                       |
                       X  VCC          |----------------------------   
                       |               |
                       |               |
                       |               |
                       |               |
                       |               |
                     0 |               VR
---------------------------------------X---------------------->  V1   
                       |               |
                       |               |
                       |               |
                       |               |
                       |               |
                       |               |      
-----------------------X---------------|
                       |  -VCC
                       |
                       |
                       |


So, this graph shows us that as the voltage we are comparing V1 approaches the reference voltage VR, it is still less than the reference and therefore the output Vosaturates to -VCC. When V1 reaches VR, the output Vo saturates to VCC for any voltage greater than the reference.

I hope this is helpful for anyone who may stumble upon it. It may be most helpful for first year electrical engineering students, or anyone interested in electronics as a hobby. If there is anything listed above that is unclear, or you believe is incorrect, please, let me know via /msg and I will be sure to correct/augment anything that needs it.

Although a general-purpose high-gain op amp, like the one above, can be used as a comparator, some op amps are specially designed for such use and are so designated. These typically are capable of higher speeds than a normal op amp. In addition to single comparator op amps, IC (Integrated Circuit) chips that contain two or four independent comparators are available.

Variations on basic comparators are level detectors and zero-crossing detectors.



Sources: My own brain. I have over six years of electrical engineering education under my belt (going for my masters currently). If you need some sources, I could name a few great textbooks for you to thumb through.