The Celtic Engineer is a weekly newsletter produced by Celtic Engineering Solutions. We hope you enjoy it. If you have any suggestions for topics, would like to give feedback or want your email added to the distribution list please send an email to[email protected].
Round 1: Op Amp vs. Comparator
The symbols for an Op Amp and a comparator look so much alike, it is very easy to think they are the same thing. An Op Amp is designed to be operated in the linear range, not in saturation. In the linear range, the inputs are very close in voltage. An Op Amp is optimized to perform in this type of setting.
A comparator on the other hand has its output set at either the positive or negative rail voltages (saturation) and never lingers in the linear range. The inputs are usually very different and can even cause some problems if they remain very close in value. More on this shortly.
An Op Amp can be used, in some cases, as a comparator. However, most comparators have an open collector output that does not allow them to be used as Op Amps. This is a distinct advantage, because it allows the comparator to connect digital circuits that are operating at different voltages. So yes, a comparator can be used as a level shifter.
What does it do?
The comparator as its name suggests is used to compare two voltages. When the input voltages are different the output will be either at the positive rail voltage or negative rail voltage. There are two configurations for this type of comparison. Like with the Op Amp one is called the inverting comparator and the other is a non-inverting comparator. The difference is which input is used as the signal and which is used as the reference.
In the non-inverting configuration, the negative input is used as the stable reference. The positive input is the signal. When the signal is higher than the reference, the output is at the positive rail voltage. Once the signal drops below the reverence, the output will switch to the negative rail. An inverting comparator uses the positive input as reference and the negative as signal and has as the exact opposite output.
Comparators are very versatile devices. Instead of just switching at a single voltage (high above and low below or vice versa) you could connect two together to create a window. The output would be high (or low) when the signal was between two voltages. You can even set up several windows by adding more comparitors.
By sampling a voltage using several comparators each with a separate output, you can make a simple encoder, or depending on the arrangement an A to D.
What can go wrong?
Earlier I said that if the inputs are close together in voltage this can cause problems. If the signal is close in voltage to the reference and the signal is noisy, then the output of the comparator may rapidly switch between rails as the signal rises above and falls below the value of the reference. This is not a desirable situation. You could filter the input signal, but there is another way. By feeding back a portion of the output to the positive input (positive feedback), in an inverting configuration, we can offset the voltage where the output switches. The amount of offset is called beta, and it is proportional to resistors used to feed the voltage back to the input. It creates a band where no switching takes place. For example, if beta was configured to be 1 volt, then the voltage would have to rise 1 volt above the target before the output would switch. It would also have to fall one volt below target before it would switch again. This 2-volt band is called hysteresis and will prevent the output from switching rapidly in the presence of noise. The band needs to be larger than the peak to peak voltage of noise.
This type of arrangement, with positive feedback, is called a Schmitt trigger. The size of the hysteresis for a given system must be determined by the design engineer. It can also be used with a non-inverting configuration when the signal is sent to the positive input and the negative input is used as reference.
One giant leap
A few issues back, issue #14, we talked about level translators. The open collector nature of the comparator makes it a very useful tool in level translation. The output will switch from one voltage rail to another. With the output pulled up to the high level of the receiving circuit and the lower rail tied to the low level of the receiving circuit, you can see how level translation can be achieved.
This newsletter is sponsored by Celtic Engineering Solutions LLC, a design engineering firm based out of West Jordan, Utah, which can be found on the web atwww.celticengineeringsolutions.com. You can find the newsletter on the company blog, LinkedIn or by subscribing. Send your emails to The Celtic Engineer at[email protected].