Ringing in comparator circuit.....

Discussion in 'The Projects Forum' started by slowfuse, Sep 7, 2010.

  1. slowfuse

    Thread Starter New Member

    Sep 7, 2010
    16
    0
    Hi all. I am trying to take the output of a frequency generated by a sound card, and make a 5v pulse out of it. For this purpose I am passing it through a comparator circuit using a LM393. Problem is, at the leading and trailing edges of most of the pulses, there is a ringing happening. Why is that so and how do I get rid of it?

    I have attached the schematic/circuit, as well as the logic capture of what actually is happening.

    Thanks!
     
  2. Dyslexicbloke

    Active Member

    Sep 4, 2010
    420
    19
    You will probably find that the output from the soundcard isnt clean to start with.
    but whatever the problem if you add a small hystoreesis to the amp it should cure your problem.
    Think of it like this ....

    You want the output to only be 5 or 0. although your amp has a huge gain in that config it isnt infinate so there is a transition to considder.

    Arrange it so when the output slightly modifies your set point at + using a feedback resistor.

    That way when the output starts to swing, the swing will be 'reinforced' by the 'new' change in input on the + which will be inverse to your input at -.

    - becomes slightly below + >
    output starts to swing high >
    + is increesed, by the feedback resistor, the amp is forced fully on.

    - becomes slightly above + >
    output starts to swing low >
    + is decreesed, by the feedback resistor, the amp is forced fully off.

    Try adding 100K between the output and + you will see what I mean.
    (In practice you will probably want to go biger than this)

    I would also buffer the output through a second voltage follower so the load cant affrect the level of feedback

    I am sure all this could be calculated, I would probably muck about on bread board untill I got it to work as needed, its how I learn.

    Hope this helps you a bit,
    Al

    [The opamp tutorials on this site are graet by the way (VolIII at the top)]
     
  3. slowfuse

    Thread Starter New Member

    Sep 7, 2010
    16
    0
    Hi. Actually I did this with several 100K's (adding as I go) but no visible change, it's still there.... :-( (the ringing that is).
     
  4. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    I think that a common input impedance in sound equipment is 10Kohm. But sound card are often made to drive headphones so down to 32 ohm is not a problem. A 10Kohm resistor from the input to ground should not do any harm. But in any case I think you will see some unwanted signals the sound card start and stop to play sound. Do you have any picture of these signals.
     
  5. Dyslexicbloke

    Active Member

    Sep 4, 2010
    420
    19
    Have you got a scope?
    The sine wave from the soundcard / sym software is probably actually in tiny steps.
    You need a hystoreesis bugger than the step and the maximum offset of the amp / comp (I think thats the thory.)

    Have you tried this in practice or just as a symulation?

    You will always see a rise time, at best it will be the max slew rate of the amp, but it will be very short and you should be able to get it clean (square) easily.

    Smaller feedback resistor = bigger hystoreesis you could set several volts, although I suspect you dont want that. several mV will do the job.

    Have a look at my post on generator control, U1a works exactly like this, the output both modifies the the comparison point, set by the 5v zenner and the resistive devider, discharges the cap.

    It produces a sawtooth wave, all be it slightly asymetrical.

    In my diagram, test circuit as is, U1b dosn't have, and will need, some hystoreesis to avoid the issue you are discribing, it only works now because the amplitude of the sawtooth is big circa 2.5V swing at 200Hz or so.
    I have much bigger issues with that circuit than a little instability producing noisy edges.

    Al
     
  6. slowfuse

    Thread Starter New Member

    Sep 7, 2010
    16
    0
    Sorry, no, I don't have a scope (at least not here where I am doing this...). Only the logic analyzer which is how I saw the result (cool thing: www. saleae.com)

    I will look at your schematics.

    But one thing I don't understand. OK, I guess maybe there might be some jitter in the output of the sound card, but to get it to generate pulses, wouldn't that jitter have to be above and below my reference voltage? That's one hell of a swing if it is and unless you are talking about tiny spikes, I don't understand how a sine wave can generate that.
     
  7. eblc1388

    Senior Member

    Nov 28, 2008
    1,542
    102
    You are feeding voltage <0.3V into the voltage comparator LM393 which cannot accept voltage on its input lower than -0.3V.

    May be you can try the following circuit.

    [​IMG]
     
    Last edited: Sep 7, 2010
  8. Dyslexicbloke

    Active Member

    Sep 4, 2010
    420
    19
    Ooops ...
    I didnt check your comparator specs sorry.
    I agree last post should fix the issue, feedback and adiquate input voltage.
    Now I feel silly.
    You'r right by the way I would have been suprised if the soundcard output had been that dirty but due to my not checking things, the input voltage, I couldnt think of anything else plausable.
    We live and laern ...
    Al
     
  9. eblc1388

    Senior Member

    Nov 28, 2008
    1,542
    102
    Besides the lacking of hysteresis would cause such problem, you would also need to have good supply bypassing capacitors. E.g. a 0.1uF ceramic in parallel with a 10uF capacitor, mounted very close to the LM393.
     
  10. slowfuse

    Thread Starter New Member

    Sep 7, 2010
    16
    0
    @eblc1388 - right on! Much better when adding those modifications. Thank you.

    I am trying out a number of sound generators, my frequency range of interest is 0 to 200Hz. I noticed that in the lower frequencies, ringing still takes place when using some (by the way I am using a sine wave as output and not a square wave).

    This program I found to be good, but will not go below 10Hz:
    http://www.nch.com.au/tonegen/index.html

    This one is problematic:
    http://slatecreekengineering.com/SoundArb.htm

    And this I did not try yet....
    http://www.multi-instrument.com/page2.html#Signal Generator

    There are few more that I did not try out yet (any recommendations?)
     
  11. eblc1388

    Senior Member

    Nov 28, 2008
    1,542
    102
    Reducing the hysteresis resistor value should help with the slower frequency.

    Another possibility is your sound card output level drops with lower frequency. In this case, increasing both the 20K resistors to 47K or more can cure your problem.

    BTW, you also need to act on the suggestion of post#9 of adding bypass capacitors.
     
  12. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    You're going to have a mighty hard time getting below about 10Hz; that's the low limit for many sound cards.
     
Loading...