Comparator-hysteresis calculator

Comparator output levels

Enter decimals or scientific notation, such as 2.5 or 2.5e0. Voltages may be negative. Changing a unit reinterprets its number.

Shaded band: between the thresholds the output keeps its last state. Arrows show the switching direction.

No valid result to draw.

Show the steps

Interactive calculation is unavailable until JavaScript loads. The formulas, worked examples and references below remain available.

Calculate comparator switching thresholds and hysteresis from feedback resistors and output levels, or the resistors for a target window.

How to use

Choose the topology: the signal on the non-inverting (+) input, or on the inverting (−) input.

Choose Thresholds from resistors, or Resistors for a window.

Enter the comparator's real output high and low levels; for an open-collector output, V_OH is the pull-up voltage it reaches.

Enter the reference voltage and both resistors, or the two thresholds and your chosen R2. The R1 slider shows how R1 sets the width.

Read the thresholds, hysteresis and loop. Copy result copies the labeled values. Reset restores the starting example.

Science

A comparator without hysteresis switches every time the input crosses the reference, so noise on a slow signal makes the output chatter. Positive feedback from the output to the non-inverting input moves the switching point after each change, which creates two thresholds.

In the non-inverting topology the signal reaches the + input through R1 and the output feeds back through R2. The input must rise above V_TH to switch the output high, then fall below V_TL to switch it low. The width is (V_OH − V_OL) × R1 ÷ R2.

In the inverting topology the signal drives the − input, and the + input is set by V_ref through R1 and the output through R2. The output goes low above V_TH and high again below V_TL. The width is (V_OH − V_OL) × R1 ÷ (R1 + R2), so it can never exceed the output swing.

Here R1 is always the resistor into the + input from the signal or the reference, and R2 is always the feedback resistor from the output. TI's application notes name the same two resistors differently, so match them by position, not by name. The thresholds depend on the output levels actually reached, and the window is generally not centered on V_ref.

Limitations: the comparator and the reference source are ideal, and the output levels are the values you enter; open-collector pull-up loading is not modelled. Input offset, propagation delay, built-in hysteresis, source resistance and resistor tolerance shift the thresholds. The tool suggests no standard resistor values.

Formulas

Non-inverting thresholds: V_TH = V_ref × (1 + R1 ÷ R2) − V_OL × R1 ÷ R2; V_TL = V_ref × (1 + R1 ÷ R2) − V_OH × R1 ÷ R2.

Inverting thresholds: V_TH = (V_ref × R2 + V_OH × R1) ÷ (R1 + R2); V_TL = (V_ref × R2 + V_OL × R1) ÷ (R1 + R2).

Hysteresis: Non-inverting ΔV = (V_OH − V_OL) × R1 ÷ R2; inverting ΔV = (V_OH − V_OL) × R1 ÷ (R1 + R2).

Design, non-inverting: R1 ÷ R2 = (V_TH − V_TL) ÷ (V_OH − V_OL); V_ref = (V_TH + V_OL × R1 ÷ R2) ÷ (1 + R1 ÷ R2).

Design, inverting: m = (V_TH − V_TL) ÷ (V_OH − V_OL); R1 = m × R2 ÷ (1 − m); V_ref = (V_TH − V_OH × m) ÷ (1 − m).

Examples

Non-inverting, V_ref 2.5 V, R1 10 kΩ, R2 100 kΩ, output 0 V to 5 V: V_TH = 2.75 V, V_TL = 2.25 V, hysteresis 500 mV. Rising above 2.75 V switches the output high; it stays high until the input falls below 2.25 V.

Inverting, thresholds 3 V and 2 V, output 0 V to 5 V, R2 100 kΩ: R1 = 25 kΩ, V_ref = 2.5 V. m = 1 V ÷ 5 V = 0.2, so R1 = 0.2 × 100 kΩ ÷ 0.8.

Inverting, V_ref 1.65 V, R1 4.7 kΩ, R2 47 kΩ, output 0.2 V to 3.3 V: V_TH = 1.8 V, V_TL = 1.518 V, center 1.659 V. A nonzero low level and the inverting divider move the window off V_ref; entering 0 V for V_OL would give 1.5 V for V_TL.

Inverting, thresholds 5 V and 0 V, output 0 V to 5 V: No resistor pair fits. The inverting window is always narrower than the output swing; a 5 V window needs the non-inverting topology.

References

Texas Instruments: Comparator with Hysteresis Reference Design (TIDU020)

Texas Instruments: Non-Inverting Comparator with Hysteresis Circuit (SBOA313)

Texas Instruments: Inverting Comparator with Hysteresis Circuit (SNOA997)

Texas Instruments: LM393 dual comparator data sheet