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
analogtodigital 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 (V_{1}, V_{2}) 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 (V_{1}, V_{2}) are the input voltages to be compared. The output (V_{o}) is the result of the comparison.
The equation:
V_{o} = A * ( V_{1}  V_{2} )
describes the basic functionality of the op amp. We will now relabel
V_{2} as
V_{R}, which is short for
reference voltage, for the rest of this discussion. This then
transforms the last equation to:
V_{o} = A*( V_{1}  V_{R} )
I already mentioned that A is very large, so it follows that any difference between V_{1} and V_{R} 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 V_{CC}
and V_{CC} 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.
V_{CC}
\ 
 \ 
V_{1}  \
 > V_{O}
V_{R }+ /
 / 
/ 
V_{CC}
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 nonzero, 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
V_{CC} and
V_{CC} 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 V_{CC}, the voltage you are comparing (V_{1}) is greater than the reference V_{R} and the difference in the equation is positive, hence, a positive output. If the saturation occurs at V_{CC}, then the compared voltage (V_{1}) is less than the reference V_{R}, and the difference in the equation is negative, you guessed it, a negative output.
A simple graph may help:
^ V_{o}





X V_{CC} 
 
 
 
 
 
0  V_{R}
X> V_{1}
 
 
 
 
 
 
X
 V_{CC}



So, this graph shows us that as the voltage we are comparing V_{1} approaches the reference voltage V_{R}, it is still less than the reference and therefore the output V_{o}saturates to V_{CC}. When V_{1} reaches V_{R}, the output V_{o} saturates to V_{CC} 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 generalpurpose highgain 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 zerocrossing 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.