Comparator hysteresis – selection of elements.

Comparators can be dedicated IC with built-in hysteresis. But they can also be built from an op-amp. But then external hysteresis resistors should be added. In this article I will try to show you how to choose them.

Why do I need hysteresis at all?

First, let’s build a comparator based on an operational amplifier, but without hysteresis. Let’s create such a circuit in LTSpice.

Figure 1. Comparator built on an operational amplifier without hysteresis.

V1 – Pulse signal.
V2 – Noise signal. I used a sinusoidal signal.
V3 – Op-amp power supply.
U1 – I used an “UniwersalOpamp2” model.
R1, R2 – Resistors that set the comparator switching threshold at 2.5 V.

Now let’s see what the input and output waveform looks like:

Figure 2. The input and output waveform of the comparator without hysteresis.
Figure 3. Magnification of the input and output waveforms of the comparator without hysteresis.

Rarely, electric waveforms are free from disturbances, noise and surges. When there is no hysteresis, such waveforms cause the comparator output to switch to opposite states repeatedly. This is similar to the bounce waveforms of switch contacts.

And it is for this reason that it is recommended to use hysteresis.

It is then somehow to set the hysteresis?

Electrically, the matter is simple. Just add one resistor. But the question is also its value.

Figure 4. Resistor R3 added to set the hysteresis.

The resistor R3 is the resistor that sets the hysteresis for us. Resistors R1 and R2 in our simulation have a value of 100 kΩ each. Therefore, the switching threshold at the moment is set at 2.5 V (half of the supply voltage). Let’s assume that we want to have a hysteresis of 1V, i.e. the switching thresholds should be Vh = 3 V and Vl = 2 V .

The presence of an op-amp may make the circuit a bit difficult to understand. Therefore, let’s try to understand how the resistors will be connected to each other. There are a total of 2 states to consider:

  1. When the output is high (+5 V).
  2. When the output is low (0V).

The connection of resistors when the output of the amplifier is high, looks like in Figure 5.

Figure 5.Resistor connection when amplifier output is high.

On the other hand, the connection of resistors, when the amplifier output is low, looks like in Figure 6.

Figure 6. Resistor connection when the amplifier output is low.

Since the hysteresis determined by us is symmetrical, it is enough to calculate the resistor R3 from one figure. Let’s take Figure 5 and calculate the value of R3 from it.

(1)   \[R13 = R1 \left|\right| R2\]

(2)   \[R13 = \frac{R1*R3}{R1+R3}\]

Due to this, our scheme is reduced to an ordinary voltage divider:

Figure 7. Simplification of the hysteresis circuit

(3)   \[I=\frac{U}{R}=\frac{U}{R2}=\frac{3V}{100k\Omega}=30\mu A\]

(4)   \[U_{R13}=5V-3V=2V\]

(5)   \[R13=\frac{U}{I}=\frac{2V}{30\mu A}=66666,(6)\approx 66666,7\Omega\]

Substituting the result into equation 2 we get:

(6)   \[66666,7=\frac{100000*R3}{100000+R3}\]

(7)   \[66666,7*(100000+R3)=100000*R3\]

(8)   \[6666670000+66666,7*R3=100000*R3\]

(9)   \[6666670000=100000*R3-66666,7*R3\]

(10)   \[6666670000=33333,3*R3\]

(11)   \[33333,3*R3=6666670000\]

(12)   \[R3=\frac{6666670000}{33333,3}\cong 200k\Omega \]

From equation 12 we get the result that our hysteresis resistor should be 200 kΩ. To be sure, using the scheme in Figure 6, we can verify the calculations. The former resistor R13 will now be resistor R23.

    \[R1=100k\Omega, R2=100k\Omega , R3=200k\Omega\]

(13)   \[R23=\frac{R2*R3}{R2+R3}=\frac{100k*200k}{100k+200k}=\frac{20000000000}{300000}\cong 66666,7\Omega \]

(14)   \[Rz=R1+R23=100k\Omega +66666,7\Omega =166666,7\Omega \]

(15)   \[I=\frac{U}{Rz}=\frac{5 V}{166666,7\Omega}\cong30\mu A\]

(16)   \[U_{R23}=I*R23=30\mu A*66666,7\Omega \cong 2V\]

As we can see from equation 16, we got a voltage of 2 V, so what we planned. Thus, we confirmed our calculations.

Now let’s try to simulate a circuit with an additional hysteresis resistor, equal to 200kΩ.

Figure 8. Comparator built on an operational amplifier with hysteresis.
Figure 9. The input and output waveform of the comparator with hysteresis.
Figure 10. Magnification of the input and output waveforms of the comparator with hysteresis.

It is clear from the simulation that by adding one additional resistor, we have created a hysteresis loop in the comparator, thanks to which the comparator output does not switch to opposite states when the signal passes around the switching threshold. That was the purpose of adding this resistor. Now it remains to check whether the voltage thresholds for hysteresis calculated by us coincide with the calculations.

Figure 11. The comparator switching threshold during the rise of the input signal.
Figure 12. The comparator switching threshold when the input signal is falling.

The simulation diagram clearly shows that we managed to obtain the switching thresholds that we assumed for the calculations. One threshold is 2V and the other is 3V.


In this case, the calculations were performed only for one case (Figure 5), and the second case (Figure 6) served only to confirm the result of the calculations. I could do so because I assumed the hysteresis symmetrically against the earlier switch point (2.5V). But if I had to do the hysteresis asymmetrically, then I would have to do the system of equations from these two cases and solve this system.