About Comparators
Comparator ICs are designed to compare the voltages that appear at their inputs and to output a voltage representing the sign of the net difference between them. In a comparator circuit, if the differential input voltage is higher than the input offset voltage (VOS), plus the required overdrive, the output swings to a voltage representing logic 1. In effect, a comparator can be thought of as a one-bit analog-to-digital converter. Besides being key components of A/D converters, comparators are also widely used in level detection, on-off controls, clock-recovery circuits, window detectors, and Schmitt triggers.
Operational amplifiers (op-amps) can be—and frequently are—used as comparators, either open-loop or in a high-gain mode, but a better way is to use the special integrated circuits that are optimized for this purpose. The output stage of a comparator is wired to be more flexible than that of an op-amp. Op-amps use push-pull outputs that ordinarily swing as close to the power-supply rails as feasible, while some comparators may have an open collector output with grounded emitter. This permits the pull-up voltage source for the output stage to vary over a wide range, allowing comparators to interface to a variety of logic families or load circuits. A reduced value for the pull-up resistor, providing increased current, will yield improved switching speed and noise immunity, but at the expense of increased power dissipation. Comparators often have a latch that permits strobing the input at the right time and a shutdown function that conserves power when the comparator is not needed.
Built to compare two levels as quickly as possible by running essentially "open-loop", comparators usually lack internal Miller compensation capacitors or integration circuitry and therefore have very wide bandwidth. Because of this, comparators are usually configured with no negative feedback (or with very small amounts if a controlled high gain is desired).
This absence of negative feedback means that, unlike that of op-amp circuits, the input impedance is not multiplied by the loop gain. As a result, the input current varies as the comparator switches. Therefore the driving impedance, along with parasitic feedbacks, can play a key role in affecting circuit stability. While negative feedback tends to keep amplifiers within their linear region, positive feedback forces them into saturation.
What's the role of hysteresis?
Even without actual feedback circuitry, capacitive strays from the output to an input (usually the non-inverting input), or coupling of output currents into ground (to which the non-inverting input is often connected) may cause the comparator circuit to become unstable. Guarding high impedance nodes and paying careful attention to layout and grounding can help to minimize these coupling effects. Latching is also helpful.
But it is not always possible to prevent instability by these measures. An often-effective solution is to use positive feedback to introduce a small amount of hysteresis. This has the effect of separating the up-going and down-going switching points so that, once a transition has started, the input must undergo a significant reversal before the reverse transition can occur.
When processing slowly varying signals with even small amounts of superimposed noise, comparators tend to produce multiple output transitions, or bounces, as the input crosses and re-crosses the threshold region (Figure 1). Noisy signals can occur in any application, and especially in industrial environments. As the signal crosses the threshold region, the noise is amplified by the open loop gain, causing the output to briefly bounce back and forth. This is unacceptable in most applications, but it can generally be cured by introducing hysteresis.

Where to use hysteresis
Besides comparator noise reduction, system hysteresis is used in on-off control to avoid overly frequent cycling of pumps, furnaces and motors. In the simplest applications a controller turns an actuator on and off as a system parameter falls below or rises above a reference set point. With hysteresis, the actuator remains on until the parameter rises somewhat above the set point, switches, and then remains off until the parameter falls to a value below the set point. The levels at which switching occurs are called the high and low threshold voltages, Vth and Vtl . An example of-set-point hysteresis is the home thermostat, which uses some form of- comparator to turn the furnace on or off. Allowing hysteresis for a few degrees of temperature change reduces unnecessary cycling adequately for home environments. Figure 2 shows a typical circuit for a comparator IC used in temperature control.

Designing comparator circuits with hysteresis
Hysteresis is applied by feeding back to the positive input a small fraction of the output voltage (which is at an upper or a lower limit). This voltage adds a polarity-sensitive offset to the input, increasing the threshold range.
With a chosen comparator, the designer must determine whether to use it in an inverting or non-inverting configuration, i.e., whether a positive overdrive will switch the output to a negative or positive limit. Some comparators have positive and negative outputs, imparting a great deal of flexibility to their use in a system. Hysteresis can be applied by connecting the positive input terminal to the tap of a two-resistor voltage divider between the positive output and the reference source; the amount of output voltage fed back depends on the resistance ratio. This frees the inverting input for direct connection of the input signal, as in Figure 2.
If the signal is applied to the non-inverting input, its source impedance should be low enough to have an insignificant effect on either the input scaling or the hysteresis ratio. To get the maximum performance out of a device, the hysteresis should be large enough to overcome the VOS (over the entire operating temperature) plus the required overdrive, as determined from the manufacturer's datasheet. Increasing the overdrive reduces the propagation delay of the part. The level of overdrive required increases with ambient temperature.
Figures 3 and 4 show the use of hysteresis with dual supplies. In Figure 3, the signal is applied to the inverting input. The output vs. input plot shows the vicinity of the switching point. R2 is usually much higher in resistance than R1. If R2 were infinite, there would be no hysteresis, and the device would switch at Vref. The hysteresis is determined by the output levels and the resistance ratio R1/(R1+R2), and the switching-point voltage is offset slightly from Vref by the attenuation ratio R2/(R1+R2).

In Figure 4, the signal is applied to the non-inverting input via R1. Because the input signal is slightly attenuated, the hysteresis will be slightly larger than in the inverting case.

If the reference voltage is midway between the comparator's high and low output voltages (as is the case with a symmetrical power supply and ground reference), the introduction of the hysteresis will move the high and low thresholds equal distances from the reference. If the reference is nearer to one output than the other, the thresholds will be asymmetrically placed around the reference voltage.
In single-supply comparator operations, the need arises to offset the reference, so that the circuit operates entirely within the first quadrant. Figure 5 shows how this can be achieved. The resistor divider (R2 and R1) creates a positive reference voltage that is compared with the input. The equations for designing the dc thresholds are shown in the figure.


Placing a capacitor across the feedback resistor in the above configurations will introduce a pole into the feedback network. This has the "triggering" effect of increasing the amount of hysteresis at high frequencies. This can be very useful when the input is a relatively slowly varying signal in the presence of high frequency noise. At frequencies greater than f(p) = 1/(2πCfRf), the hysteresis approaches Vth = Vcc and Vtl = 0V. At frequencies less than f(p) the threshold voltages remain as shown in the equations.
For comparators having complementary (Q and Q) outputs, positive feedback, and therefore hysteresis, can be implemented in two ways. This is shown in Figure 6. The advantage of Figure 6b is that a positive input-output relationship can be obtained without loading the signal source.


Figure 7 shows a circuit for comparing a bipolar signal against ground, using a single-supply part.

Variables affecting hysteresis
The offset voltage, input bias currents, and finite gain in the linear region of the comparator all limit the accuracy of the switching thresholds, Vth and Vtl. The input bias current is normally not a problem, since most applications use small source resistors to take advantage of the high speed of the comparators. Although it reduces power dissipation, high source resistance increase the propagation delay of the comparator. In order to keep the required overdrive low, the offset should be as small as possible. Open loop amplifiers could be used in place of comparators when extremely low offsets are required in the design.
The trip-point accuracies (with hysteresis) are also affected by the device-to-device variation of Voh and Vol. One possible remedy is to use a programmable reference , but this process can become costly and time consuming. A better way, though still somewhat cumbersome, is to use precision clamp circuitry to keep the output at a fixed value when it goes high (Figure 8).

Conclusion
Designers can use hysteresis to rid comparator circuits of instabilities due to noise.. Hysteresis is reliable and can be applied predictably using small amounts of positive feedback.