100nF

Comparator hysteresis and Schmitt trigger calculator

The resistors that give a comparator an upper threshold VH and a lower threshold VL, for the non-inverting and the inverting Schmitt trigger circuit, with a push-pull output or an open-drain output and its pull-up; or, from resistors already on the board, the thresholds and hysteresis they set. It solves TI's own design equations, rounds to E-series values in TI's order and reports the thresholds the rounded parts really give, with the resistor-tolerance spread, the pull-up's effect and the currents.

V_iV_oV_OH2.93 VV_OL0.00 VV_L1.30 VV_H1.71 VV_HYS 401 mVV_HV_LV_iV_o2onethreshold22
Fig 1 — Top: Non-inverting comparator with an open-drain output pulled up to 3.00 V. A rising input switches the output high at V_H = 1.71 V; it switches back only when the input falls below V_L = 1.30 V, so V_HYS = 401 mV. The output swings between 0.00 V and 2.93 V at the switching point (the pull-up loaded by the feedback path). The input axis spans one hysteresis either side of the loop. Bottom: a slow input carrying noise of 0.7 × V_HYS peak to peak. With these thresholds the output switches 2 times; a comparator with one threshold at the 1.50 V centre switches 22 times.
Exact solution R1 · R4
273.19 kΩ · 1.0058 MΩ
R4, solved from the rounded R1, before rounding
1.0065 MΩ
Fitted, E96: R1 · R4
274 kΩ · 1.00 MΩ
Thresholds the fitted values give: V_H · V_L
1.706 V · 1.304 V
Off target by: V_H · V_L
+5.50 mV · +4.29 mV
Hysteresis V_HYS = V_H − V_L
401.2 mV
Reference on the − pin V_TH, for the rounded R1
1.495 V
With ±1 % resistors, every corner: V_H · V_L
1.684 V to 1.727 V · 1.283 V to 1.325 V
Output high, at the switching point: V_pu less the drop in R3
2.93 V
Feedback over pull-up, R2/R3 (TIDU020: above 100)
20.0
R3 moves V_L by, against leaving it out
+9.79 mV
Current the output sinks from R3 while low
30.0 µA
Resistance the + pin sees, output low · high
241 kΩ · 242 kΩ
Resistance the − pin sees, R4 ∥ R5
500 kΩ
Reference divider current V_ref/(R4 + R5)
1.50 µA
Current the input supplies through R1 at V_H · V_L
750 nA · −714 nA

The output goes high when the input rises past 1.706 V and low only when it falls below 1.304 V. Noise smaller than 401 mV peak to peak cannot switch it back.

An input bias current I_B into the + pin moves both thresholds by I_B·R1 (274 kΩ) at the input; into the − pin it moves V_TH by I_B·(R4 ∥ R5). Take I_B from the comparator's datasheet.

The feedback resistor is only 20.0 times the pull-up. TIDU020: "The pull-up will create a voltage divider at the comparator output that introduces an error when the output is at logic high. This error can be minimized if Rh > 100Rp." The calculator includes R3, as TI's SBOA313 and SNOA997 equations do, so the thresholds above are right; the rule matters if R3 is left out of the sums.

How this is calculated

Standard: TI SBOA313A, Non-Inverting Comparator with Hysteresis Circuit; TI SNOA997A, Inverting Comparator With Hysteresis Circuit; TI TIDU020A, Comparator with Hysteresis Reference Design

VTH=VH×(R2R1+R2),VTH=VL×(R2+R3R1+R2+R3)+Vpu×(R1R1+R2+R3)V_{TH} = V_H \times \left(\frac{R_2}{R_1 + R_2}\right), \qquad V_{TH} = V_L \times \left(\frac{R_2 + R_3}{R_1 + R_2 + R_3}\right) + V_{pu} \times \left(\frac{R_1}{R_1 + R_2 + R_3}\right)
Non-inverting, SBOA313 steps 2 and 3, page 2–3: the + pin voltage at the moment of switching, with the output low (0 V) as the input rises through V_H, and with the open-drain output released, pulled up to V_pu through R3, as it falls through V_L. For a push-pull output, R3 = 0 and V_pu = V_cc. V_TH is the reference on the − pin.
0=VPU×R12+[VPU×R2+VL×(R2+R3)−VH×R2]×R1+(VL−VH)×(R22+R2×R3),VTH=VREF×(R5R4+R5)0 = V_{PU} \times R_1^2 + \left[V_{PU} \times R_2 + V_L \times (R_2 + R_3) - V_H \times R_2\right] \times R_1 + (V_L - V_H) \times \left(R_2^2 + R_2 \times R_3\right), \qquad V_{TH} = V_{REF} \times \left(\frac{R_5}{R_4 + R_5}\right)
SBOA313 step 4 (the two V_TH equations set equal, for R1 with R2 chosen) and step 6 (the reference divider, for R4 with R5 chosen), page 3. TI's result is "R1 = 273.19kΩ ≅ 273kΩ" (the calculator: 273.19 kΩ), then "VTH = 1.4958V", which is V_H·R2/(R1 + R2) evaluated with the rounded 273 kΩ (1.4958 V); with the unrounded R1 it is 1.4957 V.
VPU−VHR3+R4+VREF−VHR1=VHR2,VREF−VLR1=VLR2+VLR4\frac{V_{PU} - V_H}{R_3 + R_4} + \frac{V_{REF} - V_H}{R_1} = \frac{V_H}{R_2}, \qquad \frac{V_{REF} - V_L}{R_1} = \frac{V_L}{R_2} + \frac{V_L}{R_4}
Inverting, SNOA997 steps 3 and 4, page 2–3: Kirchhoff's current law at the + pin, with the output high (V_PU through R3 and R4) as the input rises through V_H, and low (R4 to 0 V) as it falls through V_L. The input is on the − pin, so these + pin voltages are the thresholds.
(BA−CR2)R42+[BA(R2+R3)−CR2R3+DR2]R4+BAR2R3=0,R1=A×R2R4R2+R4\left(\frac{B}{A} - C R_2\right) R_4^2 + \left[\frac{B}{A}(R_2 + R_3) - C R_2 R_3 + D R_2\right] R_4 + \frac{B}{A} R_2 R_3 = 0, \qquad R_1 = A \times \frac{R_2 R_4}{R_2 + R_4}
SNOA997 steps 5 and 7, page 3, with A = V_REF/V_L − 1, B = V_REF − V_H, C = V_H/R2, D = V_PU − V_H; for push-pull R3 = 0 and V_PU = V_CC. TI: "R4 = 808.88kΩ ≅ 809kΩ", "R1 = 112.36kΩ ≅ 112kΩ" (the calculator: 808.88 kΩ and 112.36 kΩ).
RhRx=VLVH−VL,RyRx=VLVCC−VH,VH−VL=RxRyRhRx+RhRy+RxRy Vcc\frac{R_h}{R_x} = \frac{V_L}{V_H - V_L}, \qquad \frac{R_y}{R_x} = \frac{V_L}{V_{CC} - V_H}, \qquad V_H - V_L = \frac{R_x R_y}{R_h R_x + R_h R_y + R_x R_y}\,V_{cc}
TIDU020 Equations 1, 2 and the right-hand side of 9, pages 7 and 21: the inverting circuit with a push-pull output and the divider fed from V_cc, where R_x, R_y and R_h are SNOA997's R1, R2 and R4. TIDU020 prints Eq 9's middle expression as a copy of Eq 8's; the right-hand side, typeset here, is the one that follows from Eqs 7 and 8. For its 2.7 V and 2.3 V on 5 V: R_h/R_x = 5.75 and R_y/R_x = 1.
VHYS=(VOH−VOL) R1R2  (non-inverting),VHYS=(VOH−VOL) R1∥R2R1∥R2+R4  (inverting)V_{HYS} = (V_{OH} - V_{OL})\,\frac{R_1}{R_2} \;\text{(non-inverting)}, \qquad V_{HYS} = (V_{OH} - V_{OL})\,\frac{R_1 \parallel R_2}{R_1 \parallel R_2 + R_4} \;\text{(inverting)}
The hysteresis of a push-pull output in closed form. The non-inverting one follows from SBOA313's steps 2 and 3 with R3 = 0 and is derived here, not printed by TI; the inverting one is TIDU020 Eq 9 rewritten. Neither depends on the reference. V_OL, the output's low level, is 0 V in all three TI notes; the calculator lets it differ, and re-derives the design equations for that case.

Assumptions

What sets a comparator's thresholds

A comparator with one threshold switches every time its input crosses it. On a clean, fast edge that is once. On a slow or noisy input it is many times, because the noise carries the input back and forth across the threshold while the signal itself drifts through. TI's reference design TIDU020 puts it this way: "Noise or signal variation at the comparison threshold will cause multiple transitions. Hysteresis sets an upper and lower threshold to eliminate the multiple transitions caused by noise." Its own example of the damage is a comparator driving an actuator: "This erratic transitioning near the threshold would cause the valve or motor to be turned on and off multiple times during the critical transition."

Hysteresis comes from positive feedback: a resistor from the output back to the comparator's + pin. Whatever state the output is in, the feedback moves the + pin in the direction that holds that state. With the output high, the + pin is pulled up; with it low, down. So the input has to go further to switch the output than it has to go to switch it back, and there are two thresholds: the upper one, VH, which a rising input must pass, and the lower one, VL, which a falling input must pass. Between them the output keeps whatever state it had. The difference, VHYS = VH − VL, is the hysteresis, and noise smaller than it, peak to peak, cannot switch the output back once it has switched. The figure above draws the loop from the calculator's thresholds, and under it runs a noisy input through those thresholds and through a single threshold at their centre.

Each threshold is found the same way: with the output in one state, the resistors make the + pin a weighted average of the input or reference, ground and the output. Setting that equal to the voltage on the other pin at the moment of switching gives one equation per threshold. TI's two Analog Engineer's Circuit notes do exactly that for the two ways of wiring it, and the reference note above typesets their equations as printed. SBOA313 is the non-inverting circuit, with the input through R1 to the + pin, R2 from the output back to it, and a reference divider R4 over R5 on the − pin. SNOA997 is the inverting circuit, with the input straight on the − pin and R1 from the reference, R2 to ground and R4 from the output all meeting at the + pin. Both use an open-drain comparator, and both carry its pull-up resistor, R3, in the sums: "The TLV7041 has an open-drain output stage, so a pull-up resistor is needed."

Designing runs the equations backwards. There are two thresholds and more than two resistors, so some must be chosen first. TI chooses R2 in both notes, large "for power conservation" (2 MΩ in SBOA313, 500 kΩ in SNOA997), and then solves a quadratic for the other feedback resistor. The calculator does the same, with the low output level VOL and a push-pull output's high level VOH free to be other than the 0 V and VCC TI assumes; with those two set to TI's values its equations are TI's.

Comparator hysteresis formula for a push-pull output

For a push-pull output the hysteresis has a closed form, and it is worth knowing because it shows what sets the hysteresis and what does not. In the non-inverting circuit, VHYS = (VOH − VOL)·R1/R2, whatever the reference: the reference moves both thresholds together and the ratio of the input resistor to the feedback resistor sets the gap. In the inverting circuit VHYS = (VOH − VOL)·(R1∥R2)/(R1∥R2 + R4), TIDU020's Equation 9 rewritten: the divider's Thevenin resistance against the feedback resistor. Both scale with the output swing, which is why an output that does not reach its rails gives less hysteresis than the resistors promise.

An open-drain output has no closed form, because the pull-up R3 is in series with the feedback resistor when the output is high and out of circuit when it is low. That changes one threshold and not the other, and it is why both TI notes solve a quadratic rather than a ratio.

Schmitt trigger resistor values for 3.3 V and 5 V

Resistors for thresholds centred on half the supply, from a push-pull output that swings rail to rail, with the reference taken from the supply, rounded to E96. The columns VH and VL are what the E96 parts give, not the targets. Non-inverting, with R2 = 1 MΩ and R5 = 1 MΩ chosen:

SupplyTarget VHYSR1R4VHVL
3.30 V20.0 mV6.04 kΩ1.00 MΩ1.660 V1.640 V
3.30 V50.0 mV15.0 kΩ1.00 MΩ1.675 V1.625 V
3.30 V100 mV30.1 kΩ1.00 MΩ1.700 V1.600 V
3.30 V200 mV60.4 kΩ1.00 MΩ1.750 V1.550 V
3.30 V500 mV150 kΩ1.00 MΩ1.897 V1.403 V
5.00 V20.0 mV4.02 kΩ1.00 MΩ2.510 V2.490 V
5.00 V50.0 mV10.0 kΩ1.00 MΩ2.525 V2.475 V
5.00 V100 mV20.0 kΩ1.00 MΩ2.550 V2.450 V
5.00 V200 mV40.2 kΩ1.00 MΩ2.600 V2.400 V
5.00 V500 mV100 kΩ1.00 MΩ2.750 V2.250 V

Inverting, with R2 = 100 kΩ chosen. Centred thresholds make the divider symmetrical, R1 = R2, as TIDU020's Equation 2 says they must when VL = VCC − VH, and the feedback resistor follows its Equation 1, R4/R1 = VL/VHYS:

SupplyTarget VHYSR1R4VHVL
3.30 V20.0 mV100 kΩ8.25 MΩ1.660 V1.640 V
3.30 V50.0 mV100 kΩ3.24 MΩ1.675 V1.625 V
3.30 V100 mV100 kΩ1.62 MΩ1.699 V1.601 V
3.30 V200 mV100 kΩ768 kΩ1.751 V1.549 V
3.30 V500 mV100 kΩ280 kΩ1.900 V1.400 V
5.00 V20.0 mV100 kΩ12.4 MΩ2.510 V2.490 V
5.00 V50.0 mV100 kΩ4.99 MΩ2.525 V2.475 V
5.00 V100 mV100 kΩ2.43 MΩ2.550 V2.450 V
5.00 V200 mV100 kΩ1.21 MΩ2.599 V2.401 V
5.00 V500 mV100 kΩ453 kΩ2.749 V2.251 V

Two things stand out. Small hysteresis on the inverting circuit asks for a large feedback resistor: 8.25 MΩ for 20 mV on 3.3 V, against a 100 kΩ divider, because it has to move the + pin by only 20 mV across the whole output swing. And small hysteresis is fragile. On the 20 mV, 3.3 V non-inverting row, 1 % resistors at their worst corners move VH by up to 16.8 mV, more than the whole hysteresis, while the gap itself holds at 19.5 mV or more. The thresholds wander with the resistors; the hysteresis between them is the robust quantity. The calculator shows that spread for whatever it designs.

Worked example: TI's non-inverting comparator with hysteresis

SBOA313's design goals are VH = 1.7 V and VL = 1.3 V, 400 mV of hysteresis, with the supply, the pull-up and the reference all at 3 V and a TLV7041 open-drain comparator. Its step 1 defines the thresholds: "VL is the necessary input voltage for the comparator output to transition low and VH is the required input voltage for the comparator to output high." Step 2 has the output low as the input reaches VH; step 3 has it released, "Vo=Vpu (or Vo=Vcc if the comparator has a push-pull output stage)", as the input reaches VL. Setting the two + pin voltages equal gives the quadratic in R1 of step 4. The left column is the calculator's arithmetic; the right is what TI prints.

chosen    R2 = 2 MΩ, R5 = 1 MΩ, R3 = 100 kΩ to V_pu = 3 V
R1        root of the step 4 quadratic                 = 273.19 kΩ   TI: 273.19kΩ ≅ 273kΩ
V_TH      1.7 × 2 MΩ / (273 kΩ + 2 MΩ)                 = 1.4958 V    TI: 1.4958V
          with the unrounded R1 it would be 1.4957 V
R4        1 MΩ × (3 V / 1.4958 V − 1)                  = 1.0056 MΩ   TI: 1.0056MΩ ≅ 1.01MΩ
fitted    273 kΩ, 2 MΩ, 100 kΩ, 1.01 MΩ, 1 MΩ
          upper threshold V_H                          = 1.696 V     TI: 1.7 V goal
          lower threshold V_L                          = 1.297 V     TI: 1.3 V goal
          hysteresis V_HYS                             = 399.7 mV    TI: 400 mV goal

R1 agrees to the digit. The next step needs care: TI's VTH of 1.4958 V is VH·R2/(R1 + R2) evaluated with R1 already rounded to 273 kΩ. With the unrounded 273.19 kΩ it is 1.4957 V, and R4 would come out at 1.0058 MΩ rather than 1.0056 MΩ. That is the right way to do it, not a slip: rounding R1 first and solving the reference for the rounded value keeps VH where it was asked for, and lets the rounding land on VL alone. The calculator rounds in the same order. Its "3 significant figures" option reproduces TI's 273 kΩ and 1.01 MΩ; on E96 it fits 274 kΩ and 1.00 MΩ, which give 1.706 V and 1.304 V.

TI's fitted values give 1.696 V and 1.297 V, within 5 mV of the goals. Two other numbers from the same circuit are worth having. The pull-up is only 20 times smaller than the feedback resistor, so when the output is high it sits at 2.928 V, not 3 V: R3 and the R2–R1 chain form a divider. Leaving R3 out of the sums would put VL at 1.287 V, −9.80 mV from the real value. And with 1 % resistors the worst corners put VH anywhere from 1.675 V to 1.717 V and VL from 1.276 V to 1.317 V.

The same goals with a push-pull output, R3 = 0 and the output high at 3 V, need R1 = 266.67 kΩ, which is 400 mV/3 V × 2 MΩ exactly: the closed form above.

Worked example: TI's inverting comparator with hysteresis

SNOA997's goals are VH = 2.5 V and VL = 2.2 V, 300 mV, on the same 3 V supply, pull-up and reference and the same comparator. Step 1 chooses R2: "In this case, it is assumed that power conservation is necessary, therefore, R2 is selected to be large", 500 kΩ. Steps 3 and 4 write Kirchhoff's current law at the + pin for the two output states, and step 5 defines four constants and combines the two into a quadratic in R4. Step 6 says to "Solve the quadratic equation for R4 and pick the most logical result"; the arithmetic shows what that means.

chosen    R2 = 500 kΩ, R3 = 100 kΩ to V_PU = 3 V, V_REF = 3 V
A         V_REF/V_L − 1 = 3/2.2 − 1                    = 0.3636     
B, D      V_REF − V_H = V_PU − V_H                     = 500 mV     
C         V_H/R2 = 2.5 V / 500 kΩ                      = 5.00 µA    
R4        roots of the step 5 quadratic                = -75.550 kΩ and 808.88 kΩ
          the positive one                             = 808.88 kΩ   TI: 808.88kΩ ≅ 809kΩ
R1        A × R2·R4/(R2 + R4)                          = 112.36 kΩ   TI: 112.36kΩ ≅ 112kΩ
fitted    112 kΩ, 500 kΩ, 809 kΩ, 100 kΩ
          upper threshold V_H                          = 2.501 V     TI: 2.5 V goal
          lower threshold V_L                          = 2.202 V     TI: 2.2 V goal
          hysteresis V_HYS                             = 299.3 mV    TI: 300 mV goal

One root is negative, so the choice is not a judgement call. R4 and R1 agree with TI's to the digit, and rounding in TI's order, R4 first and R1 solved from the rounded R4, reproduces its 809 kΩ and 112 kΩ. On E96 the calculator fits 806 kΩ and 113 kΩ, giving 2.498 V and 2.196 V. Here the feedback resistor is only 8.1 times the pull-up, and it is VH that the pull-up moves, since the output is high while the input rises: left out, VH would be 2.507 V, +5.58 mV from the 2.501 V TI's values give.

A caution on reading the note. SNOA997's step 2 repeats SBOA313's sentence word for word, "VL is the necessary input voltage for the comparator output to transition low and VH is the required input voltage for the comparator to output high". In the inverting circuit it is the other way round, as the note's own design-goal table (output low for Vi > VH) and its step 3 ("the transition to a logic low is initiated") say. The equations are right; only that sentence was carried over. The calculator's result rows say which way the output goes at each threshold.

The same circuit on 5 V: TIDU020

TIDU020 designs the inverting circuit for a push-pull comparator on 5 V, with the divider fed from the supply, under different names: Rx from 5 V to the + pin, Ry to ground and Rh for the feedback. It explains the mechanism plainly: "When the output is at a logic high (5V), Rh is in parallel with Rx", raising the threshold, and "When the output is at logic low (0V), Rh is in parallel with Ry", lowering it. For 2.7 V and 2.3 V, its Equations 1 and 2 give Rh/Rx = 5.75 and Ry/Rx = 1, and "Rh was calculated to be 575kΩ, so the closest standard value 576kΩ was used." The calculator, with R2 = Ry = 100 kΩ chosen, gives R1 = 100.00 kΩ and R4 = 575.00 kΩ.

With 576 kΩ the thresholds are 2.700 V and 2.300 V: the standard value moves each by 319 µV, inward. TIDU020's simulation of the fitted circuit reports 2.706 V and 2.294 V, and attributes the difference from the goals to two things: "The error is primarily from the comparator offset voltage and the difference between the standard resistor value and the ideal value". Its measurements on the bench came out at 2.74 V and 2.32 V with a TLV3202 and 2.76 V and 2.34 V with a TLV1702, and it lists "passive element tolerances or a pull-up resistor at the output" among the causes. The arithmetic cannot say more than that; it can only show that the 1 kΩ change of Rh accounts for a fraction of a millivolt, so the rest is the parts and the comparator.

One more of its numbers checks exactly. TIDU020 simulates the divider current at 23 µA and 27 µA "(calculated = 5V / 200kΩ = 25µA)". The two values match the current through Rx in the two states, (5 V − VH)/100 kΩ and (5 V − VL)/100 kΩ, which the calculator gives as 23.0 µA and 27.0 µA.

Inverting or non-inverting Schmitt trigger

The two circuits switch at the same kind of thresholds and differ in what the input sees and which way the output goes.

Push-pull, open-drain and an op amp as the comparator

The resistor maths needs only two things from the device: that its output sits at one level or the other, and where those levels are. TI's reference design says as much: "This method can be used for any comparator." What differs between devices is the output stage.

A push-pull output drives both ways, and TI models its high state as the supply itself. An open-drain or open-collector output only sinks, and its high level is made by a pull-up that is then in the feedback path. TIDU020, whose method assumes push-pull, spells out the consequence: "The methods described in this design TI Precision Design were derived for a push-pull output stage. An open-collector output stage requires a pull-up resistor (Rp). The pull-up will create a voltage divider at the comparator output that introduces an error when the output is at logic high. This error can be minimized if Rh > 100Rp." It picks a 5 kΩ pull-up for its 576 kΩ feedback resistor, a ratio of 115, and notes the price: "The output will need to drive 1mA for a logic low (5V/5kΩ = 1mA)." The calculator puts the pull-up in the equations, as SBOA313 and SNOA997 do, so the 100-to-1 rule is not needed for accuracy; with TIDU020's 5 kΩ it moves VH by 1.58 mV. It reports the ratio, the shift and the sink current so the trade is visible: a smaller pull-up gives a firmer high level and costs current every moment the output is low.

An open-drain output has one advantage the maths makes plain: its high level is Vpu, which can be a clean rail, rather than whatever the comparator's output stage manages under load.

None of the three TI documents treats an op amp used as a comparator, so this page makes no claims about how one behaves when it switches. What the model needs from it is the same as from any comparator: enter its real output swing as VOH and VOL, from its datasheet at the load the feedback resistor presents, and the thresholds follow. Because the hysteresis scales with the swing, an output that stops short of the rails gives proportionally less of it.

The 74HC14: a Schmitt trigger with fixed thresholds

Where the thresholds do not need to be anywhere in particular, a logic gate with a Schmitt-trigger input does the same job with no resistors. TI's SN74HC14 datasheet says its input "provides hysteresis as defined by ΔVT", which "makes this device extremely tolerant to slow or noisy inputs". Its thresholds are set by the silicon, and the datasheet gives them as ranges, at 25 °C:

VCCVT+ min–typ–maxVT− min–typ–maxΔVT min–typ–maxVT+(max) − VT−(min)
2 V0.7 – 1.2 – 1.5 V0.3 – 0.6 – 1 V0.2 – 0.6 – 1.2 V1.20 V
4.5 V1.55 – 2.5 – 3.13 V0.9 – 1.6 – 2.45 V0.4 – 0.9 – 2.1 V2.23 V
6 V2.1 – 3.3 – 4.2 V1.2 – 2 – 3.2 V0.5 – 1.3 – 2.5 V3.00 V

The ranges are what matter. The datasheet's rule is "Input signals must cross Vt-(min) to be considered a logic LOW, and Vt+(max) to be considered a logic HIGH", so on 4.5 V a signal has to swing across a band of 2.23 V, the last column, to be certain of switching both ways, and the noise it can reject is set by the smallest hysteresis: "To know how much noise is too much, please refer to the ΔVT(min) … This hysteresis value will provide the peak-to-peak limit", 0.4 V at 4.5 V. A comparator with resistors puts its thresholds where they are needed, to the tolerance of the resistors and the comparator's offset: SBOA313's 1.7 V and 1.3 V hold within about ±21.1 mV with 1 % parts. The 74HC14 is the right part for cleaning up a logic-level edge, such as a debounced switch; a comparator is the right part for deciding whether an analogue voltage has crossed a particular value.

Where the resistor model stops being valid

The comparator's own offset and hysteresis. Both TI notes open with the same caution: "The accuracy of the hysteresis threshold voltages are related to the tolerance of the resistors used in the circuit, the selected comparator's input offset voltage specification, and any internal hysteresis of the device." Their TLV7041 lists an input offset of ±100 µV and internal hysteresis of 7 mV. Against SBOA313's 400 mV, 7 mV is 1.7 %; against a 20 mV design it is 35 %, and small external hysteresis has to be designed with the device's own figure in view. The calculator warns below 20 mV.

Input bias current. Nothing in the model draws current into the pins. A real comparator's bias current flows through whatever resistance its pin sees and shifts the threshold by the product. In the non-inverting circuit that works out, referred to the input, as IB·R1 on both thresholds, which is 273 µV for every nanoamp in SBOA313's circuit; its − pin sees R4∥R5, 502 kΩ. The large resistors TI picks to save power are exactly what make this term grow, so check the datasheet's bias current against them. The calculator lists the resistance each pin sees.

The output levels. The model's output sits exactly at VOL or VOH. A real output falls short of its rails by an amount that grows with the current it supplies; the 74HC14's own table, for instance, guarantees VOH of 3.98 V at 4 mA from 4.5 V at 25 °C. For a push-pull comparator, enter the high and low levels at the current the feedback path draws. For an open-drain one, the calculator already computes the high level from the pull-up.

Propagation delay. The thresholds are where the output starts to switch, not when. The TLV7041's propagation delay is listed as 3 µs in both notes, and SNOA997 lists its alternates, the TLV1701 and TLV7011, at 560 ns and 260 ns. On a fast input the signal has moved on by the time the output changes, and the feedback, which only acts once it does, arrives late too. Hysteresis cures chatter from noise; it does not make a slow comparator fast.

Supply current at the edge. TIDU020 simulates the circuit's current and warns: "Note that the device draws significant transient current when the output transitions state." Its remedy is local decoupling: "Use a 0.1 µF ceramic X7R capacitor connected closely to the power supply and ground connection."

Common comparator hysteresis mistakes

Further reading