Comparing two comparators

Thread Starter

cmartinez

Joined Jan 17, 2007
8,786
AAAARRRRGHHHH why are ordinary trimpots so freakeashly expensive? ... I'd like to buy 20 or 30 of them (through-hole, top adjustment, at least 10 turns, either 1k or 5k) ... but the lowest price I've found is at least $3.00 bucks ... I ain't pay'n ninety hard earned aces for something as mundane as this!
 

Wolframore

Joined Jan 21, 2019
2,619
There’s always SOP to DIP adapters if you cant find a replacement. Why change what works. These days a simple button costs more than precision IC’s.
 

TeeKay6

Joined Apr 20, 2019
573
AAAARRRRGHHHH why are ordinary trimpots so freakeashly expensive? ... I'd like to buy 20 or 30 of them (through-hole, top adjustment, at least 10 turns, either 1k or 5k) ... but the lowest price I've found is at least $3.00 bucks ... I ain't pay'n ninety hard earned aces for something as mundane as this!
If you can purchase from www.jameco.com, there are many trimpots listed for less than $1.50 each. You can also get good pricing on Chinese trimpots via eBay.
 

MrAl

Joined Jun 17, 2014
13,720
About a year ago, I built a circuit whose output I plugged into a comparator, and the comparator's other input was connected to a pot configured as a voltage divider. The intention of the circuit was to alert an MCU when a certain amount of current exceeds the pot's adjustment, and the circuit has been working beautifully ever since.

However, for my second build I had to replace the LM193N that I originally used on the first version because that chip has been declared obsolete. The one I'm using now is the LM2903P, and of course it's pin compatible and has similar characteristics with the previous one. I am, however, noticing differences in their behavior. Mainly in their hysteresis, if I'm correct. The LM193N seems to have a larger one, and that proved beneficial for my purpose. But the LM2903P seems to be a bit too sensitive, and runs a little unstable, or jittery, compared to the other one, for lack of a better word.

Questions, What would the main reason for their differences in behavior be? ... And is there a better replacement for the LM193N than the one I chose for this purpose?
Hi,

Even on the LM139 data sheet one of the first things they say is to use hysteresis. This is a given with comparator circuits because without hysteresis even a tiny bit of noise on the input will cause the output to fluctuate when the two input voltages are near to each other.

An interesting difference might be that the LM139 is spec'd down to -0.3v for any input while the new one seems to be spec'd only down to 0.0v for any input. That could mean a change in input ESD diode protection.

But to solve the problem once and for all add some hysteresis. Because you use a pot however that may not be easy unless you also add a resistor in series with the pot arm. That way the hysteresis resistor has some impedance to work into even if the pot is near the lower end of its travel.
 

danadak

Joined Mar 10, 2018
4,057
The Aol (Forward gain with no feedback, normally used in OpAmp specs) is
essentially the same as the Avd spec in the datasheet shown here.

1579609000643.png

So if your signal differential V between inputs is, for example, 1 uV then using min Avd
the output would become 1 uV x 50,000 = 50 mV. So that tells you there may not be a valid logic
level out of part. If we drive it with a differential of 1 mV we would get 50V which of course this comparator
cannot generate outside its power supply rails, so you would get the spec output voltage limits. This is
normally referred to as "overdrive" in a comparator circuit, where we give it more V in differential than needed
to get it to swing from one rail to the other. Overdrive also impacts comparator speed.

Not to ignore that 1 uV in a system is usually swamped out by noise (thermal, coupled, switching)
and offsets and PSRR (power supply rejection ratio).

Some comparator basics -

https://www.st.com/content/ccc/reso...df/jcr:content/translations/en.DM00050759.pdf

http://www.ti.com/lit/an/snoaa35/snoaa35.pdf

http://www.mit.edu/~6.331/an47fa.pdf This is more indepth than you need, just good ref material.


Here is a hysteresis calculator - http://sim.okawa-denshi.jp/en/compkeisan.htm

And help - https://www.analog.com/en/analog-di...-comparator-instability-with-hysteresis.html#


Regards, Dana.
 
Last edited:

ebeowulf17

Joined Aug 12, 2014
3,307
One more vote for adding your own hysteresis. It's just one resistor, and it's a solution you can trust.

Relying on some trace amount of hysteresis that happens to exist in one particular sample of an op amp is sketchy. A comparator with no feedback wants to be an oscillator. It's pure luck if you previously found one that doesn't oscillate. If you add the resistor, you can take luck out of the equation.

That said, I'll admit that I don't fully understand the significance of the forward gain specs here, so I can't personally claim that adding a feedback resistor will solve all your problems. It will definitely address at least one though.
 

danadak

Joined Mar 10, 2018
4,057
The significance of Avd is to insure designer understands what will generate a
legit comparison, and if Avd too low it will not function as desired., eg. speed,
achieving actual trip.... Also to force one to deal with overall system noise
versus overdrive, and of course it affects accuracy of hysteresis calculations,
especially when dealing with low level signals. Most ap notes assume Avd is
infinite in hysteresis calculations, which of course it is not.


Regards, Dana.
 

AnalogKid

Joined Aug 1, 2013
12,158
Maybe there's a better way (preferably solid state, and galvanically isolated) to monitor if the motor is indeed turned on?
Current transformer. It requires feeding one of the AC power wires through a closed hole, but the output is completely isolated and scalable from mA to kA.

This might have been covered above, but - the input stage to the comparators you are using is very similar to the input stage of an opamp. As such, it has a common mode voltage range. This is the input voltage range for linear operation of the amplifier, and is defined in terns of how close the input voltage peak amplitude can get to the power rail voltages. It varies significantly from one comparator chip design to another. The LM339/LM393 family was super-astounding back in its day (early 1970's) because its input range included voltages *below* its negative power rail. This was only 1/2 of what we now call "rail-to-rail", but a big deal at the time.

ak
 

MisterBill2

Joined Jan 23, 2018
27,664
OK, I see a whole lot of responses that ignore the reality that just adding a small bit of hysteresis will stop the oscillation as well. And adding one resistor is not a redesign of the whole circuit. And no consideration that just because one maker has declared a part obsolete that it may still be available from others.
 

MrAl

Joined Jun 17, 2014
13,720
The Aol (Forward gain with no feedback, normally used in OpAmp specs) is
essentially the same as the Avd spec in the datasheet shown here.

View attachment 197319

So if your signal differential V between inputs is, for example, 1 uV then using min Avd
the output would become 1 uV x 50,000 = 50 mV. So that tells you there may not be a valid logic
level out of part. If we drive it with a differential of 1 mV we would get 50V which of course this comparator
cannot generate outside its power supply rails, so you would get the spec output voltage limits. This is
normally referred to as "overdrive" in a comparator circuit, where we give it more V in differential than needed
to get it to swing from one rail to the other. Overdrive also impacts comparator speed.

Not to ignore that 1 uV in a system is usually swamped out by noise (thermal, coupled, switching)
and offsets and PSRR (power supply rejection ratio).

Some comparator basics -

https://www.st.com/content/ccc/reso...df/jcr:content/translations/en.DM00050759.pdf

http://www.ti.com/lit/an/snoaa35/snoaa35.pdf

http://www.mit.edu/~6.331/an47fa.pdf This is more indepth than you need, just good ref material.


Here is a hysteresis calculator - http://sim.okawa-denshi.jp/en/compkeisan.htm

And help - https://www.analog.com/en/analog-di...-comparator-instability-with-hysteresis.html#


Regards, Dana.

That's interesting too because it makes us aware that the input changing slowly could have dramatic effect on the output logic state, and of course the output logic state is very important as it must be stable.

With a tiny change from 0v to 10uv and back to 0v we could see the output go up and down from one logic state to another and then back again. So even a real tiny change even without noise could cause big problems. So hysteresis is a necessary and probably sufficient requirement.
 

Thread Starter

cmartinez

Joined Jan 17, 2007
8,786
I've just acquired 100 LM293P comparators (which have not yet been declared obsolete) for 12 dlls at Newark. They seem to have the same properties as the LM193, but with a narrower temperature working span, which my design will never exceed anyway.

I have not ignored the possibility of adding an hysteresis resistor, Bill. It's just that for now I don't want to dive into modifying the PCB I've already built, if I can avoid it.
 

MrAl

Joined Jun 17, 2014
13,720
OK, I see a whole lot of responses that ignore the reality that just adding a small bit of hysteresis will stop the oscillation as well. And adding one resistor is not a redesign of the whole circuit. And no consideration that just because one maker has declared a part obsolete that it may still be available from others.
I am starting to wonder if this might be a case of "detail-itis maximus circumstantialis".
In other words, "i was forced to look and that's the only reason i see now even though it happened before."
So could it have been happening all along and after changing the part that was the only time it was noticed so it appears to be the fault of the part rather than the circuit. We know hysteresis is always necessary when a stable logic state is required, so this problem may have always been present but just recently had been noticed.
 

MrAl

Joined Jun 17, 2014
13,720
I've just acquired 100 LM293P comparators (which have not yet been declared obsolete) for 12 dlls at Newark. They seem to have the same properties as the LM193, but with a narrower temperature working span, which my design will never exceed anyway.

I have not ignored the possibility of adding an hysteresis resistor, Bill. It's just that for now I don't want to dive into modifying the PCB I've already built, if I can avoid it.
That sounds good but are you sure the circuit is ok as it is anyway? It could be that this was happening all along maybe to a lessor degree. Comparators down usually work well at all if there is no hysteresis and we need a stable logic output. It may be wise to take this recent discovery as a warning and do something about it.
 

OBW0549

Joined Mar 2, 2015
3,565
I've just acquired 100 LM293P comparators (which have not yet been declared obsolete) for 12 dlls at Newark.
The LM393 is not obsolete. One manufacturer may have stopped making it, but that doesn't mean it's obsolete.

Right now Digi-Key has nearly 40,000 LM393s in stock just in DIP package; all of them are marked as "Active," not "Obsolete" or "Not for new designs."

LM393's are like LM324's: they will still be manufactured, and our descendants will still be designing them into new products, long after you and I are dead and gone.

Mark my words.
 

Thread Starter

cmartinez

Joined Jan 17, 2007
8,786
That sounds good but are you sure the circuit is ok as it is anyway? It could be that this was happening all along maybe to a lessor degree. Comparators down usually work well at all if there is no hysteresis and we need a stable logic output. It may be wise to take this recent discovery as a warning and do something about it.
This is my second version of the circuit, in which everything is exactly the same, except for the specific comparator being used. The first circuit is working perfectly alright, and the second one is the only one showing the symptoms. What's more, there are two identical circuits in each PCB, and the two present in the first version are behaving "as they should" whilst the other two at the second version are both oscillating.

What I think is happening is that my design is not perfect, and it definitely needs a feedback resistor so as to add hysteresis to it, But somehow the LM193 has been put in a borderline situation and somehow it manages to work the way I want it to.

So, yes, I will be adding a feedback resistor to my next build, and I'll also be changing the pot from 50k to 5k to minimize the possibility of oscillations.
 
Last edited:
Top