Comparator Hysteresis (Schmitt Trigger) Calculator
Comparator Hysteresis (Schmitt Trigger) Calculator
Upper and lower switching thresholds, hysteresis width and centre for a comparator with positive feedback — inverting or non-inverting, push-pull or open-drain — plus a design mode that picks the resistors for the thresholds you want.
Comparator hysteresis
Non-inverting, 5 V push-pull output, reference 2.5 V, R1 = 10 kΩ, R2 = 100 kΩ
Thresholds with positive feedback
- R1
- from the signal (non-inverting) or the reference (inverting) to the + input
- R2
- from the output back to the + input — the positive feedback
- VOH, VOL
- the voltages the output actually reaches, not the supply rails
- VTH, VTL
- the input levels at which the output changes, going up and coming down
Worked example
Non-inverting, 5 V push-pull output, reference 2.5 V, R1 = 10 kΩ, R2 = 100 kΩ
R1 ÷ R2 = 10 kΩ ÷ 100 kΩ = 0.1, and the output swings the full 0 V to 5 V
Hysteresis = 5 V × 0.1 = 500 mV
Upper threshold = 2.5 + (2.5 − 0) × 0.1 = 2.750 V
Lower threshold = 2.5 + (2.5 − 5) × 0.1 = 2.250 V
Centre = 2.500 V, the reference itself in this symmetrical case
A signal carrying up to ±0.25 V of noise can cross the centre without the output changing twice
What R1 buys you, with R2 = 100 kΩ on a 5 V rail
| R1 | R1 ÷ R2 | Hysteresis | Lower threshold | Upper threshold |
|---|---|---|---|---|
| 1 kΩ | 0.0100 | 50 mV | 2.475 V | 2.525 V |
| 4.7 kΩ | 0.0470 | 235 mV | 2.382 V | 2.618 V |
| 10 kΩ | 0.1000 | 500 mV | 2.250 V | 2.750 V |
| 22 kΩ | 0.2200 | 1.1 V | 1.950 V | 3.050 V |
| 47 kΩ | 0.4700 | 2.35 V | 1.325 V | 3.675 V |
Why a comparator needs hysteresis
A bare comparator has enormous gain, so it responds to microvolts. Feed it a slowly changing signal — a temperature sensor, a light level, a battery voltage — and as the signal creeps past the reference the output does not switch once. Every millivolt of noise on the way through is amplified to a full swing, so the output rattles between high and low, sometimes for milliseconds, sometimes for seconds. Whatever is downstream — a relay, a counter, an interrupt pin — sees dozens of events instead of one.
Positive feedback fixes it. Take a resistor from the output back to the + input. When the output goes high it drags the + input up with it, which raises the effective threshold, so the input now has to fall a good deal further before the comparator changes its mind. The switching level is no longer one voltage but two, and the gap between them is the hysteresis. With the example above — a 5 V output, R1 = 10 kΩ and R2 = 100 kΩ — the gap is 500 mV: the output goes high at 2.750 V and does not come back low until 2.250 V. Noise of up to ±0.25 V riding on the signal cannot make it change twice, because after the first transition the threshold has moved 500 mV away. Choose the hysteresis to be comfortably larger than the noise on your signal and comfortably smaller than the change you actually want to detect.
Two configurations. In the non-inverting arrangement the signal drives R1 into the + input, the reference sits on the − input, and the output follows the input. The hysteresis is (VOH − VOL) × R1 ÷ R2, and the drawback is that the signal source has to drive R1 and is pulled about by the feedback. In the inverting arrangement the signal goes to the − input, which draws practically nothing, and R1 carries the reference into the + input instead; the hysteresis is (VOH − VOL) × R1 ÷ (R1 + R2) and the output is upside down. The inverting version is the usual choice when the source is weak; TI’s application note SBOA313 works through the non-inverting case step by step.
Which rails does the output actually reach? This is where the arithmetic goes wrong in practice, because the thresholds depend on VOH and VOL, not on the supply. A push-pull CMOS comparator gets within millivolts of both rails. An LM393’s output is an open-drain NPN transistor that can only pull down: its high level is whatever a pull-up resistor takes it to, and its low level is a couple of hundred millivolts above ground when it is sinking current. Choose the output stage above and enter the levels your part really reaches. Keep the pull-up much smaller than R2, or R2 will pull the output down and the upper threshold with it.
Related circuits. A 555 is a Schmitt trigger with the thresholds fixed at ⅓ and ⅔ of Vcc and a capacitor doing the moving — see the 555 astable calculator. An op-amp with negative feedback instead of positive is an amplifier, not a comparator: see the non-inverting amplifier calculator. And if the noise you are fighting is high-frequency rather than random, a low-pass filter in front of the comparator may serve better than hysteresis — the RC filter calculator sizes it.
Frequently asked questions
How do I calculate Schmitt trigger thresholds?
For a non-inverting comparator, VTH = Vref + (Vref − VOL)·R1/R2 and VTL = Vref + (Vref − VOH)·R1/R2, so the hysteresis is (VOH − VOL)·R1/R2. For the inverting version divide by (R1 + R2) instead of R2. VOH and VOL are the voltages the output really reaches, not the supply rails.
How much hysteresis do I need?
More than the peak-to-peak noise on your signal, and less than the change you want to detect. A few tens of millivolts is enough for a clean sensor signal on a 5 V rail; hundreds of millivolts for a long, unshielded run or a mechanical sensor.
What is the difference between the inverting and non-inverting comparator with hysteresis?
The non-inverting version takes the signal through R1 into the + input, so the source is loaded and pulled about by the feedback, and the output follows the input. The inverting version puts the signal on the − input, which draws nothing, and inverts the output. Their hysteresis formulas differ: R1/R2 against R1/(R1 + R2).
Does an LM393 need a pull-up resistor?
Yes. Its output is an open-drain NPN transistor that can only pull down, so without a pull-up there is no high level at all. The pull-up voltage sets VOH, which is also what fixes the upper threshold in a circuit like this. Keep the pull-up well below R2.
Why does my comparator output oscillate or chatter?
Either it has no hysteresis, or not enough for the noise on the input. Add positive feedback from the output to the + input and size it for a gap wider than the noise. Supply decoupling matters too: a comparator switching a heavy load can upset its own reference.
Related calculators
References
- Texas Instruments. Non-inverting comparator with hysteresis circuit, application note SBOA313, July 2018 — the design procedure used by this page’s non-inverting mode, worked there for VH = 1.7 V, VL = 1.3 V and 400 mV of hysteresis.
- Texas Instruments. LM393B, LM2903B dual comparators, datasheet SLCS005AH. “The output consists of an open drain NPN (pull-down or low side) transistor” — it needs a pull-up resistor; supply 2–36 V, output sink about 21 mA typical at 5 V.
- Horowitz P, Hill W. The Art of Electronics, 3rd ed. Cambridge University Press, 2015. §12.3 on comparators — outputs, inputs and the parameters that matter when a slow signal is squared up.
- IEC 60063:2015. Preferred number series for resistors and capacitors (E6, E12, E24, E48, E96 and E192). International Electrotechnical Commission.
