Comparator Hysteresis – What Resistors Go Where?

comparatorhysteresis

Consider the following almost-surely-wrong comparator circuit:

schematic

simulate this circuit – Schematic created using CircuitLab

In various places I've seen similar circuits, some have R3, some have R4, some have neither. Similarly, some have R5, some have R6. (Some have neither, but those are "without hysteresis" and can be ignored. AFAIK, none have both. Here, an absent resistor should be removed entirely along with its connections.)

What is the purpose of R3/R4 and how does one know when they can be omitted? How does one know whether to include R5 or R6?

Best Answer

Typically, you either want hysteresis (caused by positive feedback) or linearity (achieved with negative feedback).

Linearity will be important for amplifiers, such as audio applications. In such cases, you employ negative feedback:

schematic

simulate this circuit – Schematic created using CircuitLab

In all these configurations above, inverting and non-inverting, some fraction of the output potential is fed back to the inverting input, so that feedback is negative. They all produce an output highly proportional to the input, one of the great benefits of negative feedback in general.

I won't go further into detail about why R4 is or isn't necessary above, since you can read about that in any op-amp literature about linear amplifiers such as those. I will simply say that R5 in your own circuit is necessary if you require linearity, and R4 will almost always be present, which in combination with R5 sets the fraction of the output fed back, to determine "gain". R5 can be zero, in which case you have a "voltage follower".

Mixing both positive and negative feedback creates a situation in which one will dominate, completely nullifying any effect of the other. Having said that, it is possible to employ resistors R5 and R6, if you require a linear function of two separate input potentials, but it's too complex a topic for here. If positive feedback is dominant (your goal is to implement hysteresis), there's no reason that I can think of to also have negative feedback.

Your question suggests confusion mainly about resistor use in positive feedback configurations. Positive feedback causes the output to slam hard against one of the power rails, forming a digital "high" or "low" state, and it's impossible to get such systems to settle in the middle somewhere.

This is great for switching applications that require clear on/off signalling. Positive feedback results in hysteresis, very desirable for noise immunity, and perfect for preventing oscillation. Positive feedback, as you have guessed requires a feedback resistor (R6 in your circuit, and mine below) to cause a shift in potential at the non-inverting input.

Let me restate that with emphasis: hysteresis requires positive feedback, so R6 is always required, but the presence of R6 must result in a shift of potential at the non-inverting input as the output swings between high and low.

If the potential at the non-inverting input is held fixed by some voltage source, no amount of feedback via R6 can possibly influence that potential! Consider the following two circuits:

schematic

simulate this circuit

Note: R1 in these circuits, and the ones below, is the pull-up resistor necessary for many "open collector output" comparators, such as the LM393. Not all comparators require it.

Clearly both of these produce a low output when IN is above 5.1V, and high otherwise. On the left I provide a reference potential at the non-inverting input using a voltage source, and on the right I use a zener diode for the same purpose.

You might expect R6 to provide some hysteresis, but in both cases R6 is useless. That's because the reference potentials are very low impedance voltage sources, and no amount of pulling up or down of that potential by R6 can have any effect. Well, the zener diode reference isn't quite as "stiff" as the voltage source, and so there might be a little wobble of potential, but this is far from ideal.

In such cases where the potential at the non-inverting input is "held steady" like this, you need to provide a little flexibility there. That's the role of R3:

schematic

simulate this circuit

Here R3 is used to increase the reference source impedance, so that it can actually be "tweaked", or modulated by output transitions. R6 now has a fighting chance to actually influence the potential at the non-inverting input.

The amount of influence that the output has on the non-inverting input potential (the feedback), will correlate with the ratio between R6 and R3. The lower R3 is, the "stiffer" the opposition to change. The lower R6 is, the "stronger" the output can pull up or down.

R3 won't be strictly necessary if the impedance of the source providing the potential at the non-inverting input is already high. For instance, you may wish to use a resistor potential divider to present, say, a third of the supply potential, which I do here with Rx and Ry:

schematic

simulate this circuit

I can dispense with R3 here because the two resistors in the divider already provide a potential at their junction with quite a high source impedance. That potential is therefore already very "flexible", easily influenced by feedback via R6.

That source impedance (and its consequent "flexibility") becomes quite obvious when I replace the system consisting of Rx, Ry and the supply (in the blue box), with their Thevenin equivalent circuit, shown above right. Those two circuits would behave identically.


Update

To have the output go high when \$V_{IN}\$ exceeds some reference, IN must drive the non-inverting input, and now you must consider the impedance of the source of potential at IN. The only difference between the following two designs is the presence/absence of R3:

schematic

simulate this circuit

These two circuits are presented with an input, the blue trace below, a potential sweeping up from 0V to 8V, and then back to 0V. The left circuit's output is orange, and the tan trace is from the circuit on the right:

enter image description here

Hysteresis is only present for the left circuit (orange), and can be seen as two distinct switching thresholds at the green markers. Due to the zero impedance source V1, I've had to include R3 to permit R6 to modulate a little above, and a little below the potential at IN, prior to presenting that potential to the comparator's non-inverting input.

The tan plot (from the right-hand circuit) shows not even the slightest trace of hysteresis, because without R3, there's nothing that R6 can do to fight against the might of source V1.