Op-Amps and Comparators

Discussion in 'General Electronics Chat' started by adam555, Dec 5, 2013.

  1. adam555

    Thread Starter Active Member

    Aug 17, 2013
    858
    39
    I'm currently doing some practices based on the Positive Feedback page from the Operational Amplifiers chapter of this website's ebook, and I'm getting the opposite result in some circuits when using Op-Amps and Comparators.

    This particular circuit, in which a comparator is used, works perfectly well when I try it in a simulator. But when I try it in real life, it doesn't work with comparators; it only works with Op-Amps. :confused:

    [​IMG]

    I tried it with a sine wave in ranges between 0 to 10 volts, and 50 Hz to 1 KHz; and with 2 different comparatos: the LM393 and the AZ339. In both cases I got the graph bellow. But with the Op-Amp (an AD822) I get the exact result previewed in the ebook for the comparator.

    What's going on?

    [​IMG]
     
  2. crutschow

    Expert

    Mar 14, 2008
    13,019
    3,235
    Those comparators need an output pull-up resistor to the plus supply. Do you have that?
     
  3. adam555

    Thread Starter Active Member

    Aug 17, 2013
    858
    39
    Thanks.

    No, I don't; I just replicate it as it is in the schematic.

    I know exactly what you mean; I saw those pull-up resistors in the schematic for the function generator I just finished. But, could you explain why are those needed with the comparators and not in the Op-Amps, and why the circuit works well as it is with Op-Amps when it's supposed to be for comparators?
     
  4. tshuck

    Well-Known Member

    Oct 18, 2012
    3,531
    675
    The AZ339 are open collector outputs, meaning they can not supply current, only sink current or make a high-Z output. The pull up resistor is to pull the high-Z output to Vcc...

    The op amps can supply current (they would be fairly useless in a lot of their main applications otherwise), and running them without any feedback causes them to operate in open-loop mode, applying the op amp gain to the difference of the two inputs as Vout =A(V+ - V-), where A is the open loop gain for the op amp, meaning the op amps are saturating - something they aren't designed for, they have a slow saturation recovery time as opposed to comparators.
     
    Last edited: Dec 5, 2013
  5. adam555

    Thread Starter Active Member

    Aug 17, 2013
    858
    39
    Thanks; I think I understand it now.

    Tried the comparators with the pull-up resistor and they work perfectly well.

    The simulation with the Op-Amp didn't work though; even though in real life it works with and without pull-up resistor.
     
  6. tshuck

    Well-Known Member

    Oct 18, 2012
    3,531
    675
    Try the op amp simulation with a slower input signal, it may not have time to recover from saturation... also be sure your simulation isn't trying to use a dual supply only op amp with a single supply...
     
  7. adam555

    Thread Starter Active Member

    Aug 17, 2013
    858
    39
    I think it's a problem with that particular simulator. I tried it in LTSpice and it works perfectly well with Op-Amps, but not with Multisim using the virtual Op-Amp.
     
  8. tshuck

    Well-Known Member

    Oct 18, 2012
    3,531
    675
    Hmmm, that's odd. I don't use Multisim, so I'm at a loss for other suggestions...
     
  9. adam555

    Thread Starter Active Member

    Aug 17, 2013
    858
    39
    It usually works more or less like LTSpice; I normally get similar results. I chose Multisim for this particular test because you can adjust the potentiometer while running the simulation and see the results in real-time.
     
  10. adam555

    Thread Starter Active Member

    Aug 17, 2013
    858
    39
    By the way; I noticed that that simple circuit doesn't only transform a sine wave into a square wave, but is also a simple way to change the duty cycle. So, I was thinking that I could modifying the function generator I just finished, and incorporate that circuit to add that option to the square wave output.

    Would this be the right way of doing it?
     
  11. crutschow

    Expert

    Mar 14, 2008
    13,019
    3,235
    Comparators have open collector outputs so they can drive loads that can be supplied from a higher voltage than used for the comparator power. You can't do that with an op amp.
     
  12. w2aew

    Member

    Jan 3, 2012
    219
    64
    Remember, simulators are only as good as the models. If you ask the simulator to do something that the model wasn't designed to cover (like op amps being driven to saturation with no negative feedback), then they will lie to you. No model is perfect. They're designed for typical operational conditions, and will fail or behave strangely when asked to go outside of this. It is up to YOU to be smarter than the simulator.

    Remember, a simulator will have no problem putting 1000 amps through a 1N914A diode, it doesn't know that you'd let the smoke out of it.
     
    #12 likes this.
  13. adam555

    Thread Starter Active Member

    Aug 17, 2013
    858
    39
    I'm just starting with op-amps;so, I'm still not familiar with the different specs. I'm also not completely sure of all the differences between op-amps and comparator.

    By the way, your video was really helpful.
     
  14. krb686

    New Member

    Mar 2, 2013
    8
    0
    For what it's worth, there's another great real-time simulator that you don't even need to download anything to use (besides Java), over here. It's all in browser, and there's a TON of prebuilt circuits.

    http://www.falstad.com/circuit/
     
  15. crutschow

    Expert

    Mar 14, 2008
    13,019
    3,235
    The main difference is that an op amp has internal frequency compensation so that it remains stable with simple resistive feedback, but this makes it operate slowly when used as a comparator. A comparator has no compensation for much greater speed, but if you apply negative feedback it will oscillate.

    The other difference is that many (but not all) comparators have an open collector output.
     
    adam555 likes this.
  16. adam555

    Thread Starter Active Member

    Aug 17, 2013
    858
    39
    I use that one too; but mainly when I need to understand how a circuit works by looking at the current flow.

    It's usually no good for circuits that need specific models of the components; e.g. I wouldn't be able to use it for this experiment, as it doesn't have comparators -just op-amps.
     
    Last edited: Dec 6, 2013
  17. nigelwright7557

    Senior Member

    May 10, 2008
    487
    71
    Op amps make poor comparators.
    The op amp will get upset if the input voltages get near the rails unless it is a rail to rail op amp.
    Also the output will not go all the way up to the supply rails again uless it is a rail to rail op amp.
    Some op amps also invert the output if the input is driven to far one way.
     
  18. adam555

    Thread Starter Active Member

    Aug 17, 2013
    858
    39
    I've been looking at and testing these differences, and not I'm clear with this...

    ... which I understood by looking at the internal diagrams of Comparators and Op-Amps. I saw that the output of comparators is the collector of a transistor, while the op-amps have a two pull-push NPN and PNP transistors. And I also see now why, comparators cannot supply current, only sink it; as tshuck said.

    What I'm not clear is about this part...

    I read that internal frequency compensation means that op-amps have slow slew rates as compared with comparators, but apart from that I wasn't able to recreate an example where I could clearly see what else would this mean in practice.

    I did test how comparators oscillate when used as an op-amp voltage follower (with just a direct negative feedback and the pull-up resistor); but again, I don't have clear why this happens and how it is related to the internal frequency compensation and the slew rate.
     
    Last edited: Dec 7, 2013
  19. crutschow

    Expert

    Mar 14, 2008
    13,019
    3,235
    Your test clearly shows what this means in practice. Comparators oscillate when you attempt to use them as op amps with negative feedback. This is because, due to internal phase-shifts at high frequency, the feedback becomes positive, thus forming an oscillator. To prevent this in op amps, the frequency response is rolled off (compensated), typically by a single-pole low-pass internal filter, so that the phase-shift never becomes positive until the open-loop gain is less than 1 (a gain of greater than 1 is required for oscillations). If you look at the open-loop frequency response (Bode) plot in an op amp data sheet you will see this rolloff. A side-effect is that this filter also reduces the slew-rate of the op amp output, which is undesirable but unavoidable.
     
  20. ian field

    Distinguished Member

    Oct 27, 2012
    4,415
    784
    You can get up to all kinds of mischief with comparators - especially the one hidden inside the TL431 programmable zener.

    The TL431 is a comparator with its own 2.5V reference built in and encapsulated in a TO92 package - as with any comparator, if you roll it off with enough negative feedback, you can use it in the linear region as an amplifier.

    With Vcc=12V; you could start off with a cathode resistor somewhere between 220R and about 2k2. Now if you add a pot from cathode to GND with the wiper to control input (pot from 100k to 1M) you can adjust the pot to set the cathode voltage operating point.

    Now the top arm of the pot; from wiper (control input) to top (cathode) provides DC nfb which stabilises the operating point - but it also provides just as much AC nfb, which cancels out most of the gain.

    Now if you disconnect the top of the pot from the cathode and put in a fixed resistor (at least as high as the cathode resistor) you now have a tap point between the top of the pot and the added resistor - you can put an electrolytic from this tap to GND to shunt the nfb and get pretty huge gain!

    You may actually end up with too much gain! - you can experiment with adding some resistance in series with the AC nfb shunt capacitor to moderate the gain. Some of the prototypes I built were plagued by breakthrough of local radio, a choke in series with the AC nfb shunt will cure this (those wire ended chokes that look like fat resistors). 470uH was way over the top, 220uH noticeably stunted the top of the AF range - 100uH pretty much did the job of keeping radio stations out.
     
Loading...