help calculating feedback resistors for opamp hysteresis

Thread Starter


Joined Nov 19, 2010
i'm having a bit of troubles calculating an adecuate resistor for this opams

here's my schematic. asume potentiometers are set to 50-50, vcc is 5V, R42 = R43 and R14 = R15. lets call the line that gets lost to the left X and REG goes to a microcontroller

with this, I'm monitoring X: if X goes out of a range set by the pots, the opams are supposed to set REG to high. but the current values i calculated for the resistors set a very wide histeresis window for both opams that overlap so the signal is ALWAYS set to 1 xept when i'm from 2.8 to 3.2 V aprox (VERY narrow acceptance margin) and i need to set this values farther appart!

lets say, the lower opam should turn on below 1.5V and off at 1.8V, while the upper opam should turn on avobe 4.5V and off at 4.2V (this ARE NOT accurate values, i must be able to adjust them with the pots; i just wrote them as an example)

i want the equation to get the resistors, not quite the values the resistors must have

can anyone help me figuring this out??


Joined Apr 20, 2004
Some difficulty comes from trying to use an op amp as a voltage comparator. An op amp is meant to be used as an amplifier. Deliberately driving the output into saturation is not reccommended.

This link goes to a lengthy article on the us of voltage comparators. One section deal with making a "window comparator", which is the circuit you are trying to get to work -

Thread Starter


Joined Nov 19, 2010

i looked at the site you sugested.

they are doing sort of the same i do at the "adding hysteresis to a comparator circuit" section. I'm just using two of them to make a window comparator: checks against the upper level, checks agaist the lower level. in the end, the diodes are the ones generating the OR between both output signals so my micro reads the alert right

the circuits in the site are based upon a lm339 i think, while i'm using a lm324.
i checked out both datasheets and, while there're a few important differences between them, still the 324 seems more suited to my needs. (please correct me if i'm wrong and i missed something else!!)


i'm checking out the equations in the site (sorry, i'm rather slow at math magic, my attention tends to drift a lot). I'll write back if i still havent figured out some useful values for my design

still, if someone else has some other suggestions, i'll really appreciate them, so feel free to post them! :D


Joined Mar 6, 2009
Your pots give you an adjustment range of 0.452Vcc to 0.795Vcc.

So if Vcc=5V you have a range of 2.26V to 3.98V

Perhaps you should re-jig that part of the circuit first.

The notional comparator hysteresis voltages wil be




Where Voh is the high output voltage and Vol is the low output voltage for the op amp.

With the LM324 op-amp powered between 0V and +12V the likely values would be of the order Voh=10.5V and Vol=1.5V

You require a hysteresis of 0.3V so




If R14=6k2 with R42=180k you have some preferred values.


I checked the LM324 data sheet. It seems Vol=0V. So that would change the aforementioned calculations somewhat.

Namely, R42=34*R14.

With R14=2.2k, R42=75k is a possible selection. Or R14=22k & R42=750k.
Last edited:


Joined Nov 28, 2008
with this, I'm monitoring X: if X goes out of a range set by the pots, the opams are supposed to set REG to high.
Your current circuit will NOT do that, because of the diode AND gate at the opamp outputs. Both opamps need to NOT operate(high) at either ends of the voltage range for this to happen and so it won't.

However, it will do the reverse of setting REG to LOW just fine if the voltage X goes out of range.

A quick simulation proves the circuit will give that result with roughly the hysteresis you required.

I have left out the two fixed resistors(R10 & R13 in your original circuit) for the 5K variable resistors or else the Hi/Low trip settings adjustment will interact with each other.