Using Your PC As A Simple Signal Generator


[Debraj] needed a simple signal generator for a project he was working on, but didn’t have one handy. He found that the easiest and cheapest way to get clean, reliable signaling was by using something that was already sitting on his desk – his PC.

He found that the tone generator built into Audacity was quite useful, at least for generating waveforms at less than 20 KHz or so. Upon plugging his scope into his sound card’s audio jack, he observed that the PC had good frequency fidelity, though it required an additional DC offset as most cards are built to remove that offset from the waveform.

Using a LM358 as a non-inverting summing amplifier, he was able to apply a steady DC offset and generate usable signals for his micro controller projects. A schematic for his offset circuit is available on his site, should you wish to build one of your own.

[Debraj] also notes that though Audacity is a cheap free way to generate simple signals, any number of complex signals can be generated using MATLAB if you happen to own a copy.

29 thoughts on “Using Your PC As A Simple Signal Generator

  1. Try looking up Stomper Hyperion. It is an old drum sound synth with 512 stackable oscillators that you can tweak to you liking and then export to wav. I have also used Analog Box with some success (depends on the sound card) and Stomper As usual, when possible disable your PC’s midi synth chip to remove insane background noise and yes a DC offset as the poster has done :) PCs are an amazing tool and so versatile! Best of luck to all :)

  2. Really simple concept used within software defined radio for generating/decoding downshifted signals.
    DReaM is an open source DRM and SDR software for transmitting via audiocard. Might be worth hacking together some code from there to produce an open source signal genetator.

  3. I really enjoy this kind of projects.
    I suppose that using matlab or scilab will have the same 20000hz limit.
    I’m planning on building my own workshop and you (HaD),are plenty of really cool ideas.

  4. Block the DC offset with a cap?
    Any reason why he isn’t doing this instead. It would be a 10c fix. It doesn’t isolate the computer from the circuit, but neither does an op amp. an optical isolator or transformer should be used if galvanic separation of the circuits is desired. Sure the cap will have some LF roll-off, but with a properly sized cap you can have it low enough as to not affect anything adversely.

    I would just solder a 1uF polypropylene cap in between a male and female 1/8″ stereo jack. This is what I use for testing amplifiers etc. With the fairly low (5 ohms? IIRC) of my laptop it blocks the DC while letting my play the necessary tones to test the amp. It was actually DC from the amp I was blocking, as it was for a car amplifier and the input floats at 6VDC. For tones I use winISD, but audacity is probably just as good.

  5. Going to be honest. . .if you knew anything about sound card outputs, you’d realize that he didn’t quite figure out what was going on.

    Typically your el-cheapo sound card will probably use cheap high voltage offset op amps (which turns into something significant). It all boils down to having a significant DC offset on the output, which can damage headphones and other loads connected to it. The easy, brute force (but often cheapest) way of solving this problem is to throw the biggest, cheapest output capacitor in series on the output which won’t filter out too much of the low end of the audio spectrum when you form the RC high pass filter with the impedance of your headphones (or audio load).

    So what’s happening here? When he says that the DC offset is being slowly “cancelled” out by the sound card, he actually means that the output capacitor I mentioned above was being charged by the oscilloscope input impedance. I admit the numbers from his waveform don’t seem to quite add up (I would have expected it to take VERY long to discharge given the 1M impedance of the scope probe, beyond what’s even observable at his timescale), but this could be due to leakage in the craptastic capacitor they usually use or more likely just that I haven’t crunched the numbers at all out of that waveform.

    Anyway, when it comes down to it, there is really no need for whatever nonsense he did here with an active op amp. If you run into this problem, the easiest way to deal with it is wire a resistor in parallel (basically load the output with something small, like 1k or 100 ohm resistor). Remember, headphones are usually <32 ohms, so this (should be) easy as pie for the output stage of the sound card. This resistor will keep the output capacitor charged to the correct offset voltage. If that didn't work, you'd stick another DC blocking cap of a lower value depending on what you want to load it with (and higher quality, i.e. lower leakage current or just a more expensive electrolytic) and another loading resistor to keep that cap charged.

    And if that didn't work, well, this circuit's pretty darn silly by almost any standard. Why? you have to manually trim the DC offset! WHAT??? You can block DC using a cap and then an op amp, if loading becomes an issue (the input impedance of an op amp is so large that you get limited by your bias resistor, so the numbers usually work out to you being able to use either a low-uF range ceramic or plastic capacitor) If that doesn't work sufficiently for whatever reason I can't even imagine, you can have a two op-amp DC servo design, but I don't know why you'd ever have to go so far for some silly audio frequency amplifier.

    In short, there are SO MANY easier ways to solve this problem. . .and needing a trimpot to "cancel out DC offset" of this scale (100s of mV) is just really silly. It certainly makes sense when you're trying to cancel out the DC offset of the op amp, but that's on the order of mV and you wouldn't configure the circuit like this. . .

    1. It’s not a matter of trimming away VDC. His circuit is there to be able to add a VDC to the signal, to be able to shift it up or down as desired. The soundcard won’t give you anything that is not centered around 0V, so if you would want a biased signal swinging from, say 0-1V instead of -0.5-0.5V, you’d need to add that voltage yourself.
      It’s a summing amplifier which he uses to DC-bias and attenuate the signal to fit his microcontroller projects. Not to block DC, of which there is none on soundcard outputs.

  6. I could be wrong for most uses of a PC software sound card generator, would work fine without this circuit. How often is a rectified AC output is need from a signal generator?

    Again I could be wrong this circuit is is not to block DC from the sound card as other comments suggest, but to add positive DC voltage for digital controller purposes.

    This is the first read the term DC offset. After doing some brief reading on it, I think the use of the trm here is mis use

    1. This would most certainly affect impedance, and load down the soundcard output. But then again, if you use the headphone output, it is designed to be loaded with an impedance in the 100’eds range of ohms. The op-amplifier has really high input impedance, which is probably what the soundcard line outputs would want to see.
      With a resistive network, the signal would see an impedance of R1//R2//Rload, with R1 and R2 being your voltage divider, and Rload being whatever you hook it up to. This amounts to an input signal impedance of less than the smallest of R1,2,load, and could potentially draw more current from the soundcard than it was designed for.

  7. I love how Fallen and threepointone completely missed the point. He’s trying to ADD a DC offset to the output of his AC-coupled soundcard, guys. Anyone who has any actual experience with electronics probably knows that generating a periodic signal centered around something other than 0 V is a pretty common feature on function generators.

  8. Does anybody know of a multi output version signal generator – like 5 channels of analog out via a pc with DC to 1KHz response. I figure you could hack the sound card and short the out put caps on a 5.1 (cheap) sound card…
    Nice job by the way :-)

  9. @Parcanman,

    I can see where the confusion might come from, I had to do a double take the first time he contacted us and linked a video. His name is indeed Debraj, not Debra.

  10. @Aron not sure what you’re asking for really? Are you trying to do 5.1 SPL/tuning or multichannel input tracking on another unit? My quick and dirty answer is to simply generate the signal in an audio program (still a cool edit pro man myself), do your dc offsetting and/or bandpass filtering, and use a 5.1 output plugin (matter of taste) to check your timing/phase/etc. Otherwise I always enjoyed “el-cheapo” surround sound or quad-like where you take both A/B speaker sets on an old amp, set A as front field and wire normally. For the rear two on B, only plug in the two positive leads and simplt twist the two negative leads on the rear speakers together :) I’ve done this countless times with old stereo units when I was much much younger :) SNES in surround when you are 14 and only have the family’s old Symphonic stereo? yep lol. Hope this helps ya or maybe sparks another step for ya. I wasn’t really sure what you were asking, so sorry if I totally missed the point and feel free to clarify :)

  11. I would suggest getting matlab. The program is very powerful and can do all sorts of data manipulation. I go to Georgia Tech E.E major nothing better for signal processing.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.