# Hysteresis on inverting terminal for comparator circuits?

If you examine 98% of circuits online that include hysteresis for a comparator, they always implement the hysteresis on the non-inverting input, like so:

This is easy enough to calculate. However, let's say your input is from a voltage divider. The calculation of the hysteresis gets a bit more complicated. A page of equations and a handy excel calc later, I got it figured out. I used a combination of the MCP6541's datasheet and this handy document from TI. The circuit looks like:

It's worth noting that in almost every explanation of hysteresis for op amps, the reference pin is on the non-inverting terminal, with input signal on the inverting terminal. While going through all this math, I wondered to myself, why can't I just add the hysteresis circuit on the inverting terminal? The math is simpler, and it seems like it would work much the same way. I could not find a single circuit online that did this, which made me wonder if I'm missing something terribly obvious. Additionally, I found this note in a ROHM application note, "Note: A comparator cannot be operated as a hysteresis comparator when a negative feedback is applied." My favorite question....but why not? I may be misunderstanding that statement. That circuit would look like this:

I'm not sure what's wrong with this. If you do the math, it seems like the VREF changes slightly with the expected hysteresis depending on whether Vout is slammed to GND or Vcc. I built the circuit in every circuit, and it seems to function just fine.

Is there a issue with this method of implementing hysteresis on the negative feedback loop?

Here are the two scenarios you describe, one with negative feedback (left), the other with positive (right):

simulate this circuit – Schematic created using CircuitLab

The only difference between the two circuits is the polartiy of op-amp inputs; OA2's inputs are swapped with respect to OA1. In both circuits, some fraction of a change in the output is fed back to one of the inputs, but the effect of that change will be grossly different in each case.

On the right, where feedback is positive, a rise in output causes the non-inverting input potential to also rise. Being the non-inverting input, that rise further increases the output potential, which increases non-inverting input potential, which further increases the output, and so on. The result is that the output hurtles upwards until it can't go any further. The same thing happens in the opposite direction; when the non-inverting input is slightly negative, the output falls, making the input more negative still, making the output even more negative and so on, until he output gets stuck at the negative extreme.

Positive feedback ensures that $$\V_P\$$ and $$\V_Q\$$ are as different as it's possible for them to be.

On the left, a rise in output potential causes a rise in potential at the input as before, but this time the rise occurs at the inverting input instead. A rise at the inverting input will incur a fall in output potential (and vice versa), in opposition to any change in output. That is, any fluctuation in output tends to correct itself, and it doesn't go off on some wild swing to extremes. In fact, what happens is that it settles at whatever potential is required to satisfy this condition:

$$V_P = V_Q$$

In each case the algebra that describes behavior may look similar, but there's a crucial sign difference that causes one circuit to behave very differently from the other. For instance, the formula for the left hand circuit, relating output to input is:

$$V_{OUT} = -\frac{R_2}{R_1}$$

That would be a straight line on a graph of $$\V_{OUT}\$$ vs. $$\V_{IN}\$$, behaviour we called "linear".

For the circuit on the right, a graph of $$\V_{OUT}\$$ vs. $$\V_{IN}\$$ would have vertical discontinuities at the thresholds, and horizontal portions elsewhere, very non-linear behaviour.

That's why the article you referred to says "a comparator cannot be operated as a hysteresis comparator when a negative feedback is applied"; either you get linear behaviour with negative feedback, or hysteresis from positive feedback, and never the twain shall meet. If you do try to mix them, you still end up with one or the other, depending on which of the two feedback quantities is dominant.

With regard to calculating the thresholds when input comes from a resistor potential divider, having formulae is OK, but knowing why is priceless. One way (possibly the simplest) is to take the Thevenin equivalent of that divider:

simulate this circuit

Replace the components in the blue box with their Thevenin equivalent:

simulate this circuit

Thevenin resistance $$\R_{TH}\$$ is

$$R_{TH} = R_3 \parallel R_4 = \frac{R_3R_4}{R_3+R_4}$$

Thevenin voltage $$\V_{TH}\$$ is

$$V_{TH} = V_{IN} \frac{R_4}{R_3 + R_4}$$

Now you have resistors $$\R_{TH}\$$ and $$\R_1\$$ in series, with a combined resistance of $$\R_{TH} + R_1\$$, which permits you to calculate thresholds using the usual method, yielding thresholds in terms of $$\V_{TH}\$$.

Then you can use the above relationship between $$\V_{TH}\$$ and $$\V_{IN}\$$ to express those thresholds to be in terms of $$\V_{IN}\$$.

An example:

simulate this circuit

$$R_{TH} = R_3 \parallel R_4 = \frac{12k\Omega \times 6k\Omega}{12k\Omega + 6k\Omega} = 4k\Omega$$

$$V_{TH} = V_{IN} \frac{6k\Omega}{12k\Omega + 6k\Omega} = \frac{1}{3}V_{IN}$$

simulate this circuit

simulate this circuit

Assuming that CMP1 is rail-to-rail output, reaching extremes of ±12V, the switching thresholds of $$\V_{TH}\$$ can be calculated like this:

\begin{aligned} V_{TH(L)} + \left(V_{OUT(H)} - V_{TH(L)}\right) \frac{R_5}{R_2 + R_5} &= 0 \\ \\ V_{TH(L)} + \left(12 - V_{TH(L)}\right) \frac{50k}{150k} &= 0 \\ \\ V_{TH(L)} + 4 - \frac{1}{3}V_{TH(L)} &= 0 \\ \\ \frac{2}{3}V_{TH(L)} = -4 \\ \\ V_{TH(L)} = -6 \\ \\ \end{aligned}

\begin{aligned} V_{TH(H)} + \left(V_{OUT(L)} - V_{TH(H)}\right) \frac{R_5}{R_2 + R_5} &= 0 \\ \\ V_{TH(H)} = +6 \\ \\ \end{aligned}

From before, we established the relationship between $$\V_{TH}\$$ and $$\V_{IN}\$$, and we can use that relationship to obtain thresholds in terms of $$\V_{IN}\$$:

\begin{aligned} V_{TH} &= \frac{1}{3}V_{IN} \\ \\ V_{IN} &= 3V_{TH} \\ \\ V_{IN(L)} &= 3 V_{TH(L)} \\ \\ &= -18V \\ \\ V_{IN(H)} &= 3 V_{TH(H)} \\ \\ &= +18V \\ \\ \end{aligned}

Let's run a simulation to verify:

simulate this circuit

Sweeping the input $$\V_{IN}\$$ from −24V to +24V, and back, input $$\V_{IN}\$$ is blue, output $$\V_{OUT}\$$ is orange:

• You are beast! This is exactly the kind of full explanation I'm always looking for with these questions. Proving why it doesn't work with examples is invaluable to me. I love how the voltage divider example just simplifies down to the same two resistors - how cool! Cheers dude Commented Jan 11 at 11:41

The point of hysteresis is to reinforce the output state using the input, so that if the input signal has a small amount of noise on it, your output does not change state due to that noise. The larger the hysteresis, the larger the noise has to be to trip it; e.g. if you have a comparator with a rising threshold of 0.5V and a falling threshold of 0.4V, it would take 100mV of noise to make it change state.

This means that if you have negative hysteresis, and you assume the output is incapable of staying mid-rail in a DC condition, negative hysteresis will make you oscillate on no noise at all. Going back to our previous example, if you have a 0.4V rising threshold and 0.5V falling threshold, the circuit will oscillate for any input between 0.4V and 0.5V.

The issue with trying to reinforce your negative input terminal with your positive output is that you end up in a situation where, on a rising edge, you shift your threshold up instead of down. If you want, you can invert your output and then shift your reference on the negative input as you mention, which would shift your threshold down on a rising edge. The downside to this is that unless your comparator has a negative output, this requires extra components (at least one extra transistor, if not a logic gate).

To look at your actual circuit (the last one): currently, since OUT=0 when Vin is low, your rising threshold is 2.97V. Then, when Vin rises to 2.97V, your rising threshold becomes 2.97V+1%*(VSUP). So when you hit 2.97V until you're above your rising threshold, your comparator output is going to bounce back and forth between high and low.

• In the context of the math I was trying, I used the Rising and Falling voltages from my positive feedback setup. When you use those values, they make sense with the last circuit. However, since the last circuit has negative feedback, those values have to be inverted. Then, the entire situation makes perfect sense. Does this track? Commented Jan 9 at 20:51
• @AJ_Smoothie when you say "since the last circuit has negative feedback, those values have to be inverted", what do you mean by "those values "? Commented Jan 9 at 23:51
• @user350400 thanks for the correction; got my superposition slightly wrong. Commented Jan 10 at 2:33

Vref does change, but into wrong direction, so it amplifies noise instead of ignoring noise.

So when input voltage is between thresholds, the output oscillates.

You can invert the output with a digital inverter and thus apply positive feedback to the inverting input.

Otherwise you've got negative feedback, which makes an amplifier or an oscillator, depending on the details.

With the divider the calculations are pretty easy and can be written down immediately:

Vin+ = (Vout/R3 + Vbat/R1)(R1||R2||R3).

So the total hysteresis for a R-R output is just (Vbat/R3)(R1||R2||R3) and the switching points are Vbat(1/R1+1/R3)(R1||R2||R3) and Vbat(1/R1)(R1||R2||R3).

• Where does this come from? Commented Jan 9 at 20:52
• @AJ_Smoothie Where does what come from? Commented Jan 9 at 21:15