Can you give a circuit that would clean up noisy audio signal?

Audio signal

Basically, I have created a square wave from a software (Real Time Analyzer) at certain frequency to the audio jack port of the computer.

The output of the oscilloscope yields the signal as shown on the top part of the image above. The signal I created from the software is similar to the bottom part of the image. There is no problem with the software. My problem is how to clean the noisy signal from the audio jack? That is, how to make the output from the circuit created similar to the bottom part of the image?

I want to have a circuit that would clean the signal.

  • \$\begingroup\$ What is the frequency of the square wave? \$\endgroup\$ Dec 3, 2011 at 4:31
  • \$\begingroup\$ Actually, it can be any frequency. But most probably I go for 1 to 100 Hz. It is only used to convert the serial signal into parallel in that case to control the movement of my robot. \$\endgroup\$ Dec 3, 2011 at 4:34
  • \$\begingroup\$ It is not clear but this seems to be similar to what modems do when they convert digital signals to analog ones for transmission over phone lines. If that is what you are attempting to do you should read about modems aka modulator/demodulator. \$\endgroup\$
    – JonnyBoats
    Dec 3, 2011 at 8:26
  • \$\begingroup\$ Use an approach that generates a clean signal in the first place! \$\endgroup\$ Dec 3, 2011 at 13:29
  • \$\begingroup\$ You can't expect a sound card to do anything useful at 1 Hz. In fact, your trace is about expected if you were to try to make a sound card produce a square wave below its lower limit. Try at 100 Hz. That should look a lot better. However, if you want digital out use RS-232 or USB. That's what they are for. \$\endgroup\$ Dec 3, 2011 at 16:11

2 Answers 2


The simplest way would be to simply feed it through any logic IC which features Schmitt Triggering.

A Schmitt trigger has what is called input hysteresis.

This includes many of the 7400 series of logic ICs. There is a list Here, just Ctrl+F for "schmitt".

Alternatively, if you really want to do it yourself, it's pretty simple to achieve with an Op-Amp.

enter image description here

The way this circuit works is fairly simple.

  • Take the above schematic, and imagine the "input" pin is at -V.
  • Since the voltage at the "+" input is less then the voltage at the "-" input, the value of "Output" will be Low (in this case, approximately -V).
  • Now, "Input" begins to rise. However, notice that there are two resistors. To cause the output to change to High, the voltage at the "+" input has to increase until i is greater then the voltage at the "-" input. This means that the value of input has to increase above the value of the negative input by an amount determined by the ratio of the resistor divider.
  • Now, as soon as the "+" input is higher then the value of the "-" input, the value of output will go High (in this case, it will be approximately the value of +V).
  • Since the output is also fed into the input through the resistor divider, once the output has gone positive, the threshold to cause the output to go negative changes as a function of the resistor divider.
  • When the Voltage at input decreases, the same happens in reverse: Because the end of the voltage divider is now at +V, the value of input has to go below the value of the - input to cause the output to become low.

All together, this is called positive feedback (as you can see, the output is connected to the positive input. As a result, the transition threshold is affected by both the output state and the input state

The term for this, e.g. the output as both a function of the input and the previous output is Hysteresis.
When hysteresis is implemented in a circuit like this, it is called input hysteresis.


I think that you don't understand the nature of digital audio and the limitations of what you are trying to do, so here goes...

A perfect square wave is made up of an infinite number of frequencies, called the Fourier series. Here is a link to the wikipedia page. The math on that wiki page isn't important, but the pictures will show you what an imperfect square wave will look like and the text of that page is good. So even if your square wave is at 1 Hz, it has frequency content to well past 1 GHz (in a perfect world).

Digital audio and your sound card, has a limited frequency range. Most sound cards can do about 20 Hz to 20 KHz. Some sound cards will be more limited than that. There is no way that your sound card can output a perfect square wave-- and depending on the frequency of the square wave it is possible that what it spits out doesn't even closely resemble what you are trying to achieve.

This has nothing to do with "removing noise". The sound card is outputting what you want, to the best of its ability-- it is just leaving off the parts that it can't do. What remains just doesn't resemble a square wave very much. Remember that you have problems on both ends of the frequency range. The high frequencies are getting cut off, causing the ringing effects. But you are also going to square wave frequencies that are lower than what your sound card can do, which will cause lots of problems too.

I honestly don't know if you can make this approach work. @FakeName has proposed one method, which might work, or might not (not enough info to really know). You might also be able to modify that approach and come up with something else that works. In my opinion, you would be better off asking a different question. Rather than asking, "how do I remove the noise?" you should ask "how do I control my robot?". Of course you also need to get a lot more specific about the exact device that you want to control (make & model + web link) would be required.

  • 1
    \$\begingroup\$ A 100 Hz square wave gives you 99 harmonics up to but not including 20 kHz. Out of just about any reasonable sound card the square wave should look a hell of a lot better than that mess! \$\endgroup\$
    – MattyZ
    Dec 3, 2011 at 8:42
  • \$\begingroup\$ @bitrex we can't tell much from the hand drawn waveform. Especially since we don't know the frequency. All we can conckude us that there is some ringing. \$\endgroup\$
    – user3624
    Dec 3, 2011 at 14:04
  • \$\begingroup\$ I guess almost everyone knows that. Given that that is really the noisy output signal. How do you make it into a square wave such that for a time frame (t/2), it is logic-1 and doesn't ripple 1-0-1-0. The next time frame ((t+1)/2), it is logic-0 and doesn't ripple. \$\endgroup\$ Dec 4, 2011 at 2:03
  • \$\begingroup\$ @neigylnoval simple. Dont use an audio output. It's kinda like using a sports car to move a house full of stuff. You can do it, but you won't like it. \$\endgroup\$
    – user3624
    Dec 4, 2011 at 4:50
  • \$\begingroup\$ Sadly, I need to use the audio output. Nothing else. \$\endgroup\$ Dec 4, 2011 at 8:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.