Ringing in comparator circuit.....

Thread Starter

slowfuse

Joined Sep 7, 2010
16
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!
 

Attachments

Dyslexicbloke

Joined Sep 4, 2010
566
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)]
 

Thread Starter

slowfuse

Joined Sep 7, 2010
16
Try adding 100K between the output and + you will see what I mean.
(In practice you will probably want to go biger than this)
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).
 

t06afre

Joined May 11, 2009
5,934
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.
 

Dyslexicbloke

Joined Sep 4, 2010
566
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
 

Thread Starter

slowfuse

Joined Sep 7, 2010
16
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.
 

eblc1388

Joined Nov 28, 2008
1,542
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).
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.

 

Attachments

Last edited:

Dyslexicbloke

Joined Sep 4, 2010
566
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
 

eblc1388

Joined Nov 28, 2008
1,542
Problem is, at the leading and trailing edges of most of the pulses, there is a ringing happening.
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.
 

Thread Starter

slowfuse

Joined Sep 7, 2010
16
May be you can try the following circuit.
@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?)
 

eblc1388

Joined Nov 28, 2008
1,542
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).
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.
 
Top