Skip to content

Comparator Calculator

Reference and resistors

Voltage at the far end of R2, applied to the non-inverting input.

Comparator output levels
Hysteresis width —
Upper threshold (input rising), V
—
Lower threshold (input falling), V
—
Centre of the window, V
—
Feedback fraction β
—

An inverting comparator with positive feedback switches at V+ = (Vref·R1 + Vout·R2) ÷ (R1 + R2). With a 2.5 V reference, R1 = 100 kΩ, R2 = 10 kΩ and a 0–5 V output, the input must rise past 2.727 V to flip low and fall below 2.273 V to flip back, a window of 0.455 V.

About this tool

Bare comparators chatter when a slow or noisy signal hovers near the reference, so most designs add a little positive feedback. That turns the single trip point into two: one for a rising input and one for a falling input. This calculator handles the common inverting arrangement, where the signal drives the inverting input and the non-inverting input sits on a divider between a reference voltage (through R2) and the comparator output (through R1). Enter the reference, both resistors and the real output high and low levels, and it returns both thresholds, the hysteresis width, the centre of the window and the feedback fraction, with the working. It assumes an ideal input stage and a stiff reference source; an open-drain output with a pull-up or a reference with its own impedance shifts the thresholds and needs that resistance folded into R1 or R2.

How to use it

  1. Set the reference

    Type the voltage that R2 connects to. Use 0 V for a ground-referenced split-supply circuit.

  2. Enter R1 and R2

    R1 runs from the output to the non-inverting input; R2 runs from the reference to that same node. Both are in kilohms.

  3. Enter the output levels

    Use the actual swing from the datasheet at your load, not the supply rails, unless the part is rail-to-rail.

  4. Read the window

    The headline is the hysteresis width; the stats give each threshold and the steps show the divider sums.

Examples

2.5 V reference, 100 k and 10 k, 0–5 V output

Reference voltage (Vref)
2.5
Feedback resistor R1 (output to +)
100
Reference resistor R2 (Vref to +)
10
Output high level (VOH)
5
Output low level (VOL)
0

Result Hysteresis width: 0.4545
Upper threshold (input rising), V: 2.7273
Lower threshold (input falling), V: 2.2727
Centre of the window, V: 2.5
Feedback fraction β: 0.0909

  1. Feedback fraction β = R2 ÷ (R1 + R2) = 10 ÷ 110 = 0.0909
  2. Upper threshold = (Vref·R1 + VOH·R2) ÷ (R1 + R2) = 2.7273 V
  3. Lower threshold = (Vref·R1 + VOL·R2) ÷ (R1 + R2) = 2.2727 V
  4. Hysteresis = (VOH − VOL) × β = 0.4545 V

A rail-to-rail comparator on 5 V with about 0.45 V of hysteresis centred just above the reference.

±12 V swing, equal resistors

Reference voltage (Vref)
0
Feedback resistor R1 (output to +)
10
Reference resistor R2 (Vref to +)
10
Output high level (VOH)
12
Output low level (VOL)
-12

Result Hysteresis width: 12
Upper threshold (input rising), V: 6
Lower threshold (input falling), V: -6
Centre of the window, V: 0
Feedback fraction β: 0.5

  1. Feedback fraction β = R2 ÷ (R1 + R2) = 10 ÷ 20 = 0.5
  2. Upper threshold = (Vref·R1 + VOH·R2) ÷ (R1 + R2) = 6 V
  3. Lower threshold = (Vref·R1 + VOL·R2) ÷ (R1 + R2) = -6 V
  4. Hysteresis = (VOH − VOL) × β = 12 V

With the reference at ground and R1 = R2, half the output swing feeds back, so the window runs from −6 V to +6 V.

How it is calculated

VTH = (Vref·R1 + VOH·R2) ÷ (R1 + R2); VTL = (Vref·R1 + VOL·R2) ÷ (R1 + R2); ΔV = (VOH − VOL)·R2 ÷ (R1 + R2)

Vref
reference voltage at the far end of R2
R1
feedback resistor from output to the non-inverting input
R2
resistor from the reference to the non-inverting input
VOH, VOL
comparator output high and low levels
ΔV
hysteresis width, VTH − VTL

By superposition the non-inverting input is a weighted average of the reference and the output. While the output is high the node sits at VTH, so the input must climb past it to switch; once the output drops to VOL the node falls to VTL. The gap equals the output swing scaled by the feedback fraction β = R2 ÷ (R1 + R2).

When not to use it

  • Non-inverting Schmitt triggers, where the signal feeds the resistor network, follow a different formula.
  • Open-collector outputs whose pull-up resistor is comparable to R1 need that resistor included.
  • Fast edges where comparator propagation delay and input offset dominate the threshold error.

Common mistakes

  • Swapping R1 and R2, which turns a small hysteresis into a very large one.
  • Using supply rails for VOH and VOL on a part that cannot swing to them.
  • Forgetting that the reference source resistance adds in series with R2.

Frequently asked questions

How much hysteresis does a comparator need?

Enough to exceed the peak-to-peak noise on the input, plus some margin for offset drift. Many designs aim for 1–5 % of the supply, for example 50–250 mV on a 5 V rail, but a noisy sensor line may need more.

Why is the window not centred on Vref?

The centre equals Vref·(1 − β) + β·(VOH + VOL) ÷ 2, so it is pulled from the reference toward the middle of the output swing. It lands exactly on Vref only when the reference already sits at mid-swing, such as 2.5 V with a 0–5 V output.

How do I choose R1 for a target hysteresis?

Rearrange ΔV = (VOH − VOL)·R2 ÷ (R1 + R2) to R1 = R2·((VOH − VOL) ÷ ΔV − 1). For a 5 V swing, R2 = 10 kΩ and 0.5 V hysteresis, R1 = 10 kΩ × 9 = 90 kΩ.

Does this work for an op-amp used as a comparator?

Yes, as long as you enter its real saturated output levels under load. Op-amps are slower to recover from saturation than dedicated comparators, which affects timing but not the static thresholds computed here.

Can the reference be negative?

Yes. Enter any reference between −1000 V and 1000 V; the divider formula is linear, so negative references and split-supply output levels are handled the same way.

What is the feedback fraction β?

It is R2 ÷ (R1 + R2), the share of any output change that appears at the non-inverting input. Multiply it by the output swing and you get the hysteresis width.

Cite this tool

Using this tool in an assignment, article or report? Copy a citation, or a link for your website.

APA

Tools Directory Editorial Team. (2026, October 23). Comparator Calculator. Tools Directory. Retrieved October 27, 2026, from https://tools.milunir.com/electronics-physics/physics-reference/comparator-calculator/

MLA

Tools Directory Editorial Team. “Comparator Calculator.” Tools Directory, 23 Oct. 2026, https://tools.milunir.com/electronics-physics/physics-reference/comparator-calculator/. Accessed 27 Oct. 2026.

Chicago

Tools Directory Editorial Team. “Comparator Calculator.” Tools Directory. Last modified October 23, 2026. Accessed October 27, 2026. https://tools.milunir.com/electronics-physics/physics-reference/comparator-calculator/.

Link<a href="https://tools.milunir.com/electronics-physics/physics-reference/comparator-calculator/">Comparator Calculator – Tools Directory</a>