# Decent opamp for comparator?

#### spinnaker

Joined Oct 29, 2009
7,835
I am just getting into the use of opamps with my mcu design.

I was wondering which general purpose op amp to go with for compartors. My supplies are typically 3 to 5v. Single supply. My input signals are typically from a few hundred mv to 5V.

Radio Shack has 741s on hand so they are accessible. Was wondering if this is a good way to go. I plan on sourcing additional chips elsewhere.

I may not have provided enough information for an answer through my ignorance so just ask followup questions if needed.

Joined Jan 15, 2015
5,776
When it comes to Voltage Comparator Information And Circuits this is one of my favorite sites.

NOTE: Operational Amplifiers (OPAMPS) such as LM324, LM358 and LM741 are not normally used voltage comparator circuits due to their bipolar outputs. However, OPAMPS can be used as voltage comparators if a diode or transistor is added to the amplifiers output to create and open collector type output. A diagram showing this addition is further down this page.

This page provides basic information about voltage comparator integrated circuits and is to act as reference material for other circuits. The circuits shown are based on the LM339 Quad Voltage Comparator chip or the LM393 Dual Voltage Comparator chip. These devices are functionally the same. The LM311 Voltage Comparator can be used for these applications as well but it also has a number of unique features.
I like and have used the ancient LM 339 Quad, LM 393 Dual and LM 311 Single comparators over the years with very good results. Just to recap, I would not use the LM 741 Operational Amplifier as a comparator as there are much better choices out there.

Ron

#### OBW0549

Joined Mar 2, 2015
3,566
I was wondering which general purpose op amp to go with for compartors. My supplies are typically 3 to 5v. Single supply. My input signals are typically from a few hundred mv to 5V.
Forget about using an op amp. Op amps are usually way too slow to be used as comparators, except in applications where response time is completely irrelevant.

Radio Shack has 741s on hand so they are accessible. Was wondering if this is a good way to go.
No, that would be an extremely poor choice; aside from the response time issue, a 741 won't operate off 3-5 volt single supplies-- it probably won't even twitch, much less do anything useful.

If you want a comparator, use a comparator: an LM393 is a good choice, they operate on single supplies as low as 2 volts and as high as 36 volts, and they're cheap.

#### spinnaker

Joined Oct 29, 2009
7,835
Forget about using an op amp. Op amps are usually way too slow to be used as comparators, except in applications where response time is completely irrelevant.

No, that would be an extremely poor choice; aside from the response time issue, a 741 won't operate off 3-5 volt single supplies-- it probably won't even twitch, much less do anything useful.

If you want a comparator, use a comparator: an LM393 is a good choice, they operate on single supplies as low as 2 volts and as high as 36 volts, and they're cheap.

Thanks that is sort of what I thought that there were better choices out there. I sure wish there was an electronics supply nearby. Hosfelt was the closest about 20 miles from here. They closed shop but sold a lot of out dated stuff anyway.

#### crutschow

Joined Mar 14, 2008
26,321
There are few brick & mortar electronic supply shops anymore.
Easiest is just to buy online such as from Digikey, Mouser, or Jameco.
If you want to take a chance on quality (i.e., counterfeit parts), you can also order from Ebay.

#### OBW0549

Joined Mar 2, 2015
3,566
I sure wish there was an electronics supply nearby. Hosfelt was the closest about 20 miles from here. They closed shop but sold a lot of out dated stuff anyway.
Why not just order from Digi-Key? I buy stuff from them all the time over the Web; AFAIK they don't have any minimum order quantity or minimum order $$, and you can get darned near everything from them. Amazon.com is also a decent supplier for some things, though their selection is limited and you take a chance on possibly dodgy Chinese stuff sometimes. Thread Starter #### spinnaker Joined Oct 29, 2009 7,835 Why not just order from Digi-Key? I buy stuff from them all the time over the Web; AFAIK they don't have any minimum order quantity or minimum order$$\$, and you can get darned near everything from them. Amazon.com is also a decent supplier for some things, though their selection is limited and you take a chance on possibly dodgy Chinese stuff sometimes.
No problem ordering but it does not get here today.

#### Phil-S

Joined Dec 4, 2015
180
I'm currently dabbling with window comparators.
As said by others, don't use an op amp, comparators are op amps optimised (is that double-Dutch?) for just one job as the name suggests.
For no other reason than a helpful datasheet, voltage etc., I chose the Microchip MCP6542. A dual comparator, runs nicely on 5-V. The dual is ideally suited to checking if a voltage is within two levels set by external references (just voltage dividers).
I had little success with trying to set up external hysteresis (working with a noisy input) as even after calculating the resistor values, there was too much interaction if resistor values are changed.
Having said all that, I'm drifting towards the idea of just using a microcontroller instead (AtTiny85) - it will do everything the comparator will do, smoothing, comparator, hysteresis, etc. - it's a lot easier to work with numbers. Although I haven't tried it yet, the Atmel MCUs have comparators built-in

Joined Jan 15, 2015
5,776
No problem ordering but it does not get here today.
Today? Today is late, I wanted it yesterday.

Never thought I would admit it but I miss Radio Shack. I will say I like Amazon Prime which the wife is a master of using. Two day shipping works for me most of the time.

Ron

#### GopherT

Joined Nov 23, 2012
8,012
No problem ordering but it does not get here today.
If you don't mind driving up to GopherT's shop, can meet up and give you a few LM393, LM339 and LM311 to play with.

#### KL7AJ

Joined Nov 4, 2008
2,229
I am just getting into the use of opamps with my mcu design.

I was wondering which general purpose op amp to go with for compartors. My supplies are typically 3 to 5v. Single supply. My input signals are typically from a few hundred mv to 5V.

Radio Shack has 741s on hand so they are accessible. Was wondering if this is a good way to go. I plan on sourcing additional chips elsewhere.

I may not have provided enough information for an answer through my ignorance so just ask followup questions if needed.
If you don't need super high speed, a plain vanilla 741 works just fine.

Joined Jan 15, 2015
5,776
If you don't mind driving up to GopherT's shop, can meet up and give you a few LM393, LM339 and LM311 to play with.
Just getting ready to go out of town for 3 weeks but when I get back I can mail you some. Then too, there is the world famous Gopher T's shop right up the road for your shopping pleasure with reasonable prices like free to a good home.

Ron

#### KL7AJ

Joined Nov 4, 2008
2,229
My shop is just as famous as Gopher T's but for some reason folks don't want to visit often.

#### spinnaker

Joined Oct 29, 2009
7,835
Just getting ready to go out of town for 3 weeks but when I get back I can mail you some. Then too, there is the world famous Gopher T's shop right up the road for your shopping pleasure with reasonable prices like free to a good home.

Ron

Thanks. Took a chance and ordered from ebay. But I might hit up Gopher too. He did time me a LM311. Haven't checked the datasheet on it. It looks like it might be about a 100 years old.

#### spinnaker

Joined Oct 29, 2009
7,835
If you don't need super high speed, a plain vanilla 741 works just fine.

Maybe I will pick one up then. No super speed. Just trying to do an tachometer. I want a nice clean square wave out not getting that from the ir sensor.

#### GopherT

Joined Nov 23, 2012
8,012
My shop is just as famous as Gopher T's but for some reason folks don't want to visit often.
View attachment 119050
I passed by about a year ago. Unfortunately, that 6 miles was straight up and a couple miles south - I was on my way from Chicago to Tokyo. The pilot pointed out Fairbanks and North Pole. I didn't get a weather report for that day.

Thanks. Took a chance and ordered from ebay. But I might hit up Gopher too. He did time me a LM311. Haven't checked the datasheet on it. It looks like it might be about a 100 years old.
And you're considering a 741 instead?
A 741 will not survive on a 5V supply.

The LM311 is still made today- Although not in the fancy metal can!

#### GopherT

Joined Nov 23, 2012
8,012
@spinnaker
Note that there is a comparator on your PIC (most PICs). If not, I can give you a PIC16F690 (SOIC-20 OR DIP-20)

#### RichardO

Joined May 4, 2013
2,271
My shop is just as famous as Gopher T's but for some reason folks don't want to visit often.
View attachment 119050
Is that -50 degrees in F or C?

Never mind. I don't think it really matters.

I worked with a fellow that went to the South Pole. He described becoming a member of the 200 club. To become a member you had to get in a hot shower and then run outside in just your sneakers. You then had you picture taken. Of course the temperature difference had to be at least 200 degrees.

#### spinnaker

Joined Oct 29, 2009
7,835
@spinnaker
Note that there is a comparator on your PIC (most PICs). If not, I can give you a PIC16F690 (SOIC-20 OR DIP-20)
I thought about that but wanted to make my "sensor" standalone.

And I am running out of pins! I might be able to move a couple of things around but it will be tight.

Can I somehow configure the comparator out so the pic sees it as an "external" interrupt?

#### spinnaker

Joined Oct 29, 2009
7,835
There is:

"The comparator interrupt flag can be set whenever
there is a change in the output value of the comparator."

Not sure if I can make use of that.