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.
Design: enter the two thresholds you want and get the resistors, rounded to a series, with the thresholds the rounded values really give. Check: enter the resistors already on the board and get the thresholds they set.
Non-inverting (TI SBOA313): the input goes through R1 to the + pin, R2 feeds the output back to it, and a reference sits on the − pin; the output goes high as the input rises past V_H. Inverting (TI SNOA997): the input goes straight to the − pin, and R1, R2 and the feedback resistor R4 set the + pin; the output goes low as the input rises past V_H. Changing this loads TI's worked example for that circuit.
Open-drain (or open-collector) outputs only pull low, so a pull-up resistor R3 to V_pu makes the high level, and R3 sits in the feedback path when the output is high. TI's examples use the TLV7041, which is open-drain. A push-pull output drives both ways; TI's notes model it as R3 = 0 with the output high at V_CC.
The comparator's supply. The thresholds of the inverting circuit are the + pin voltage, so they must lie inside it; so must V_TH on the − pin of the non-inverting one. Both TI examples use 3 V.
The voltage the reference resistors are fed from: the top of R4 in the non-inverting circuit, the top of R1 in the inverting one. Often the supply itself, as in both TI examples (3 V); a precision reference makes the thresholds independent of the supply.
The rail the pull-up resistor R3 goes to. It sets the output's high level. 3 V in both TI examples.
The open-drain output's pull-up resistor, in kilohms. It is in series with the feedback resistor whenever the output is high, which is why TI puts it in the equations. TI uses 100 kΩ. TIDU020 wants the feedback resistor above 100 times the pull-up for the error to be small.
The voltage the output sits at when low. TI takes 0 V. Enter the datasheet's V_OL at the sink current if it matters: with an open-drain output, that current is mostly V_pu/R3.
The upper threshold: the input voltage at which a rising input switches the output (high for non-inverting, low for inverting). SBOA313: 1.7 V. SNOA997: 2.5 V.
The lower threshold: the input voltage at which a falling input switches the output back. It must be below V_H; the difference is the hysteresis, which should be wider than the peak-to-peak noise on the input. SBOA313: 1.3 V. SNOA997: 2.2 V.
The feedback resistor, in kilohms, from the output back to the + pin. Choose it large to save power, as TI does, then the calculator finds R1 and R4. SBOA313 picks 2 MΩ (enter 2000).
The bottom of the reference divider, in kilohms, from the − pin to ground. Choose it; the calculator finds R4 to make V_TH. SBOA313 picks 1 MΩ (enter 1000).
Which values to fit. 3 significant figures is what TI does ("273.19kΩ ≅ 273kΩ"). E24 and E96 are the 5 % and 1 % series. Rounding follows TI's order: the first resistor is rounded and the second is solved from it, and the thresholds shown are what the rounded pair gives.
- 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
- 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.
- 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.
- 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.
- 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Ω).
- 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.
- 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
- An ideal comparator: no input offset, no internal hysteresis, no input bias current, and the output switches the instant the pins cross. SBOA313 names the offset and internal hysteresis, with resistor tolerance, as what the thresholds' accuracy depends on.
- The output as a voltage source: at V_OL when low and at V_OH when high (push-pull), or released to V_pu through R3 (open-drain). TI takes V_OL = 0 V and V_OH = V_CC; a real output falls short of both under load.
- Resistors at their nominal values, except in the ±1 % row, which evaluates every combination of each resistor at +1 % and −1 %.
- For the non-inverting circuit, a source with no resistance of its own at V_i: any source resistance adds to R1.
- DC only. Propagation delay and the speed of the input are not modelled.
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:
| Supply | Target VHYS | R1 | R4 | VH | VL |
|---|---|---|---|---|---|
| 3.30 V | 20.0 mV | 6.04 kΩ | 1.00 MΩ | 1.660 V | 1.640 V |
| 3.30 V | 50.0 mV | 15.0 kΩ | 1.00 MΩ | 1.675 V | 1.625 V |
| 3.30 V | 100 mV | 30.1 kΩ | 1.00 MΩ | 1.700 V | 1.600 V |
| 3.30 V | 200 mV | 60.4 kΩ | 1.00 MΩ | 1.750 V | 1.550 V |
| 3.30 V | 500 mV | 150 kΩ | 1.00 MΩ | 1.897 V | 1.403 V |
| 5.00 V | 20.0 mV | 4.02 kΩ | 1.00 MΩ | 2.510 V | 2.490 V |
| 5.00 V | 50.0 mV | 10.0 kΩ | 1.00 MΩ | 2.525 V | 2.475 V |
| 5.00 V | 100 mV | 20.0 kΩ | 1.00 MΩ | 2.550 V | 2.450 V |
| 5.00 V | 200 mV | 40.2 kΩ | 1.00 MΩ | 2.600 V | 2.400 V |
| 5.00 V | 500 mV | 100 kΩ | 1.00 MΩ | 2.750 V | 2.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:
| Supply | Target VHYS | R1 | R4 | VH | VL |
|---|---|---|---|---|---|
| 3.30 V | 20.0 mV | 100 kΩ | 8.25 MΩ | 1.660 V | 1.640 V |
| 3.30 V | 50.0 mV | 100 kΩ | 3.24 MΩ | 1.675 V | 1.625 V |
| 3.30 V | 100 mV | 100 kΩ | 1.62 MΩ | 1.699 V | 1.601 V |
| 3.30 V | 200 mV | 100 kΩ | 768 kΩ | 1.751 V | 1.549 V |
| 3.30 V | 500 mV | 100 kΩ | 280 kΩ | 1.900 V | 1.400 V |
| 5.00 V | 20.0 mV | 100 kΩ | 12.4 MΩ | 2.510 V | 2.490 V |
| 5.00 V | 50.0 mV | 100 kΩ | 4.99 MΩ | 2.525 V | 2.475 V |
| 5.00 V | 100 mV | 100 kΩ | 2.43 MΩ | 2.550 V | 2.450 V |
| 5.00 V | 200 mV | 100 kΩ | 1.21 MΩ | 2.599 V | 2.401 V |
| 5.00 V | 500 mV | 100 kΩ | 453 kΩ | 2.749 V | 2.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 goalR1 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 goalOne 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.
- Output sense. Non-inverting: a rising input drives the output high at VH. Inverting: a rising input drives it low at VH. Choose by what the output has to mean, or invert it downstream.
- Loading the source. The inverting circuit takes its input straight into the − pin, which draws only the comparator's input current. The non-inverting circuit takes it through R1 into a node the output is pulling on, so the source supplies current: in SBOA313's circuit, 746 nA at VH and 718 nA the other way at VL, which a high-impedance sensor has to be able to drive. Any resistance in the source adds to R1 and moves both thresholds.
- Input range. In the inverting circuit the thresholds are the + pin voltage, so they must lie inside the comparator's input range. In the non-inverting circuit the + pin stays between the input and the output, so the input can switch at a VH above the comparator's supply if the source can drive R1; the calculator flags it.
- Reference. The non-inverting hysteresis of a push-pull output is independent of the reference; the reference only moves the centre. In the inverting circuit the reference, the divider and the feedback all set both.
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:
| VCC | VT+ min–typ–max | VT− min–typ–max | ΔVT min–typ–max | VT+(max) − VT−(min) |
|---|---|---|---|---|
| 2 V | 0.7 – 1.2 – 1.5 V | 0.3 – 0.6 – 1 V | 0.2 – 0.6 – 1.2 V | 1.20 V |
| 4.5 V | 1.55 – 2.5 – 3.13 V | 0.9 – 1.6 – 2.45 V | 0.4 – 0.9 – 2.1 V | 2.23 V |
| 6 V | 2.1 – 3.3 – 4.2 V | 1.2 – 2 – 3.2 V | 0.5 – 1.3 – 2.5 V | 3.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
- Making the hysteresis narrower than the noise. TIDU020 is direct: "if the noise were larger than the hysteresis range (2.7V – 2.3V) it would generate additional transitions. Thus, the hysteresis range must be wide enough to reject the noise in your application." Measure the noise peak to peak at the comparator's input, then add margin.
- Leaving the pull-up out of the sums. With SBOA313's values the error is 9.80 mV on VL; with SNOA997's it is 5.58 mV on VH. Either include R3, as TI's equations do, or keep the feedback resistor over 100 times it, as TIDU020 advises.
- Reading VH and VL the wrong way round on the inverting circuit. A rising input past VH drives its output low, not high.
- Designing to the thresholds and forgetting the tolerances. With 1 % resistors the centre of a small-hysteresis design moves more than the hysteresis itself, as the table above shows. Use 0.1 % parts where the absolute threshold matters, as TIDU020's simulations do, or a precision reference for Vref.
- Using a Schmitt-trigger gate's typical thresholds. The 74HC14's VT+ can be anywhere from 1.55 V to 3.13 V on 4.5 V. Design the signal to cross VT+(max) and VT−(min).
- Driving the non-inverting circuit from a high-impedance source without counting it. Its resistance adds to R1, and the source has to supply the feedback current at each threshold.
Further reading
- TI SBOA313, Non-Inverting Comparator with Hysteresis Circuit — the non-inverting design: 1.7 V and 1.3 V on 3 V with an open-drain TLV7041, and the quadratic for R1.
- TI SNOA997, Inverting Comparator With Hysteresis Circuit — the inverting design: 2.5 V and 2.2 V on 3 V, Kirchhoff's current law at the + pin, and the quadratic for R4 with its push-pull modification.
- TI TIDU020, Comparator with Hysteresis Reference Design — why hysteresis, closed-form ratios for the push-pull inverting circuit with their proof, a Monte Carlo run on resistor tolerance, current consumption, bench measurements and the open-collector pull-up rule.
- TI SN74HC14 datasheet (SCLS085L) — VT+, VT− and ΔVT at 2, 4.5 and 6 V, and how to read them.
- Switch debounce calculator — the RC ahead of a Schmitt-trigger input, using the 74HC14's thresholds.
- Voltage divider calculator — the reference divider on its own, with its source impedance.
- E-series calculator — the nearest stocked value, pair or divider ratio for any of the resistors here.
- Pull-up and pull-down resistor calculator — sizing the open-drain pull-up against leakage, rise time and sink current.
- Op amp error calculator — offset and bias-current errors through a resistor network, the terms this page leaves to the datasheet.