# How can I provide hysteresis (schmitt trigger) for a comparator?

Generally, comparators* are used to determine whether an input voltage is higher or lower than a reference voltage. In a noisy environment, a slowly changing input or an input close to the threshold voltage might cause the output to cross VOH or VOL repeatedly. This undesirable situation can be avoided by using a comparator with a dead band (ΔV), or more specifically, a comparator with different positive-going (VIH) and negative-going (VIL) thresholds as shown in Figure 1.
The effect of having two threshold values depending on the prior state is called a hysteresis characteristic.

Although there are several types of circuits that provide a comparator with hysteresis (schmitt trigger), what they have in common is a positive feedback loop from the output to the input of the comparator. Figure 2 shows the simplest comparator with hysteresis. It is assumed that the comparator has a push-pull output with the ideal characteristics (i.e., infinite input impedance and zero output impedance), and that the output impedance of the reference power supply is zero.

Suppose that a voltage lower than VIL is applied to the IN(-) input. At this time, the output voltage is equal to VOH. This voltage is fed back to the IN(+) input via R2. At the same time, Vref is also applied to the IN(+) input via R1. Since the comparator has infinite input impedance, the voltage of IN(+) is calculated as follows:
VIN(+) ＝ (VOH – Vref) x R1 / (R1 + R2) + Vref (1)

Since VOH = VCC, Equation 1 indicates that the output voltage of the ideal comparator is higher than Vref. Therefore, once the output transitions to logic High, it becomes difficult for the output to return to logic Low. Let the voltage of IN(+) at this time be VIH.
Next, suppose that a voltage higher than VIH is applied to the IN(-) input. Then, VOUT transitions to logic Low (VOL).

At this time, VIN(+) is calculated as follows:
VIN(+) = (VOL – Vref) x R1 / (R1 + R2) + Vref (2)

Since VOL is lower than Vref, the first term on the right-hand side of this equation is negative. Hence, VIN(+) is lower than Vref.
Therefore, once the output transitions to logic Low, it is necessary to apply an even lower voltage to VIN(+) in order to make the output transition back to logic High.
In this way, an op-amp comparator with positive feedback has hysteresis.

From Equation 1 and Equation 2, the hysteresis range (ΔV) is calculated to be (VOH – VOL) x R1 / (R1 + R2) centered around Vref.

* Although op-amps and comparators have almost the same internal configuration, comparators do not contain a phase compensation capacitor whereas op-amps always require one. Since comparators are not generally used with negative feedback, they do not need a capacitor to make negative feedback less prone to oscillation. This capacitor reduces the response speed of op-amps. Care should be exercised regarding the response speed when an op-amp is used as a comparator.