# Hysteresis of a voltage comparator

• akaliuseheal

#### akaliuseheal

Hello,
I am designing a circuit which basically takes two voltages (V1,V2) and based upon which one of the two is greater, turns corresponding LED. So, I have got to the part where I have output from differential op amp that is the input of the inverting voltage comparator with hysteresis. Comparator compares that voltage with ground, which tells me whether that voltage is positive or negative or V1>V2 , V1<V2 . Comparator is shown bellow. Minimal input voltage is ±0.72V, voltage used to power the comparator is 12V, resistors are not known.

Questions:

1. What is the ideal hysteresis voltage, a little less than minimal input voltage?
2. I have found some expressions in the book and if someone is willing to clarify them( which value is which apart from the resistors ) it would help.
It says:
Output voltage will change based upon voltages given by these expressions. #### Attachments

It takes very little hysteresis to switch cleanly. 5 mV was built into many comparators in the good old days.
The hysteresis should be greater than (Output voltage swing) / (open loop gain).

A voltage comparator can operate with a big differential input voltage. But an Op-amp is designed to operate in a closed loop with very low differential input voltage. You will need to check that your selected op-amp behaves well as a comparator.

• akaliuseheal and Tom.G
What is the ideal hysteresis voltage, ...?

I'd say a little bit more than the peak-to-peak noise content of your Vin signal.

• sophiecentaur and akaliuseheal
I'd say a little bit more than the peak-to-peak noise content of your Vin signal.
For experimenting that's fine, and you can always increase it if needed.

For a production circuit in a moderately quiet environment, I would say three to five times the standard deviation of the noise to handle its random nature. In a noisy environment, three to five times the highest peak noise you have observed (and add some filtering).

• akaliuseheal
Also, what do you mean, or how do you define “minimal input voltage” = ±0.72V.

When the comparator switches between low and high output voltages, that voltage swing appears at the non-inverting input, attenuated by the R1 + R2 potential divider.

Also, what do you mean, or how do you define “minimal input voltage” = ±0.72V.
Input comes from differential op amp which takes two fixed values of voltage(14 total fixed values that originate from representation of resistance as voltage in the first step of the device). ±0.72V being the closest to 0.
About the noise, this won't be commercial product and I'm a beginner in this. I have no information about noise.

When the comparator switches between low and high output voltages, that voltage swing appears at the non-inverting input, attenuated by the R1 + R2 potential divider.

But, what is the purpose of R3?

But, what is the purpose of R3?
R3 is called a "Pull Up Resistor".
Its purpose is to "pull" the output pin to a high state.
That let's you use the comparator to drive logic level circuits where the maximum permissible voltage might be 5 or 3.3 volts not the 12 used by your analog circuitry.

Many comparators are built with no internal output current (high) drive for their output pin, they can only sink current to pull the pin low.
That's on purpose so you can use them to interface between analog and logic circuits that use different supply voltages , and to let you connect several outputs in parallel for "wired or" logic.
It's called "Open Collector" or "Open Drain" .
here's the inside of a TI LM139 comparator , from http://www.ti.com/lit/ds/symlink/lm239a.pdf So, to your question - R3 provides current to drive the output to its high voltage state, ie "Pull it up" .

What comparator are you using ?

old jim

#### Attachments

here's a tutorial on comparators
https://www.electronics-tutorials.ws/opamp/op-amp-comparator.html

here's a tutorial on comparators
https://www.electronics-tutorials.ws/opamp/op-amp-comparator.html

Okay, so, if I were to use lm393 and if I wanted UTP = 0.6, LTP = -0.6

±(R1 / R1 + R2 ) * V
±( 56 / 56 + 1000 ) * 12 ≈ 0.6
R1 = 56Ω
R1 = 1000Ω

How would I calculate R3?
I don't really know how to read datasheet and on the output I need voltage of 5V.

How would I calculate R3?
I don't really know how to read datasheet and on the output I need voltage of 5V.
Recalculate R1 and R2 using Vout of 5 volts
Then calculate R3 to make a voltage divider with your new R1 & R2 to give 5 volts at Vout.

old jim

Recalculate R1 and R2 using Vout of 5 volts

100 / ( 100+140 ) * 12 = 5
R1 = 100Ω, R2 = 140Ω

Then calculate R3 to make a voltage divider with your new R1 & R2 to give 5 volts at Vout.

How do you mean?

How do you mean?

5 volts across (100 + 140 )ohms = 5 / 240 = 0.02083 amp,
and when output is 5 volts that current must all flow down through R3 because the open drain can't source current It can only sink ..
So,
What value of R3 would drop the remaining 7 volts between your Vo pin and your 12 volt VDD source ?

R = E/I = 7 / 0.02083 = 336 ohms

That of course neglects any current required by whatever the Vo pin drives.
And one should check the datasheet to make sure the device is rated to sink those 20.83 milliamps.

• akaliuseheal
LM393 datasheet says, in line "Output Sink Current" the chip will sink at least 6 milliamps and typically 16 milliamps.
So good design using that comparator would suggest use of higher values for R1 R2 and R3.

Can you find three resistors that give your desired trip and reset points yet only require the IC to sink 6 ma ?

That would be a good design.

• Tom.G
Can you find three resistors that give your desired trip and reset points yet only require the IC to sink 6 ma ?

That would be a good design.

Well, R1 = 342 and R2 = 480
Gives:
I = 5 / ( 342 + 480 ) = 0.006 amps
R = 7 / 0.006 = 1167 ohms

• jim hardy
You're catching on quick !

Study the application hints in datasheets
and become familiar with device ratings.

• akaliuseheal
You're catching on quick !

Study the application hints in datasheets
and become familiar with device ratings.

Huge thanks to you, thank you for your time.

Edited

• jim hardy
I hope you build one and it works great...

old jim

• dlgoff and akaliuseheal
I hope you build one and it works great...

old jim

Sorry to bother you, I was away for 3 days and I wanted to look over this thread again and I have also seen that you answered on that "reading datasheet" thread so thank you for that also.
Now, going thru it again, what confuses me is when we recalculated values of R1 and R2. Are those the new values of R1 and R2 and if not, why was that step necessary.

To sum it up:
R1 = 56 Ω
R2 = 1000 Ω
R3 = 1167 Ω
or
R1 = 342 Ω
R2 = 480 Ω
R3 = 1167 Ω

i was away too , will have to get back up to speed. I don't think i checked your calculations - would you show them ?

i was away too , will have to get back up to speed. I don't think i checked your calculations - would you show them ?
I figured out the correct values but I still don't see the point in this:
Recalculate R1 and R2 using Vout of 5 volts
Then calculate R3 to make a voltage divider with your new R1 & R2 to give 5 volts at Vout.

That was to calculate resistance of a pull up resistor so that logic 1 has value of 5V.
Why that step? When R = V / sink_current, where V = Vdd - voltage_wanted_on_the_output

but I still don't see the point in this:
That was to calculate resistance of a pull up resistor so that logic 1 has value of 5V.
Why that step? When R = V / sink_current, where V = Vdd - voltage_wanted_on_the_output

Look back at post #1 where you were uncertain about those equations from your book.

I just wanted you to start from scratch and figure out how to calculate the resistors , independently.

I hadn't checked those formulas myself so didn't trust them.
As you point out it's not a difficult calculation.

old jim