Laptop Signal Generator

Introduction

Testing and debugging circuits is a crucial part of working on my hardware projects, especially my ambitious Modular Synthesizer project. This process involves using a variable power supply, oscilloscope, and signal generator. A signal generator is a machine which can output voltage waveforms and allows control over waveform parameters, such as frequency and amplitude.

Signal generators can be expensive, along with a variable power supply and oscilloscope. Fortunately, Georgia Tech’s Hive Makerspace has many high quality electronic bench-tops, where I can test and debug my circuits for free. I spend most of my time working on hardware projects here, but sometimes I would like to work at home while the Hive is closed. To save myself from buying a signal generator, I wrote a MATLAB program to use my laptop as one.

PCB for accessing TRS voltage signals

How does it work?

Your laptop’s audio output, often referred to as “headphone jack”, is a female jack for 3.5mm TRS audio cables. This means it can output 3 voltage signals: stereo left channel, stereo right channel, and ground reference. As long as you can control your audio output and access the voltage signals on your connected TRS cable, you can use your laptop as a signal generator - with some limitations.

I first began this execution by designing and fabricating a tiny PCB that would allow me to access the voltage signals with ease. Thanks to the LPKF machines at the Hive, I was able to do this in one day, rather than waiting for a fab house service + shipping. After soldering, I generated some sinusoids in MATLAB, outputted them to laptop audio, and displayed the result on a Hive oscilloscope, as can be seen in the video below.

Generating sinusoids in MATLAB, and viewing their output on Hive oscilloscope.

Final Product

After confirming it works, I made a GUI in MATLAB that would allow someone to use the laptop as a signal generator. The GUI allows you to choose 6 different waveforms: DC, square, sinusoid, triangle, sawtooth, and white noise. In reality, only 5 waveforms work, since the DC waveform will only output its transitory response. My suspicion is there is likely a blocking capacitor on the audio output inside the laptop, which removes any DC offset from the signal.

The GUI also allows the user to change waveform amplitude and frequency, sample rate, and play duration. You can also program and output two different waveforms at once. Below is a video of me testing the program in my dorm, using my own oscilloscope.

I also designed an enclosure for the PCB and 3D printed it. Here is the final product.

Here are the downloads for both the MATLAB script and the MATLAB GUI. To run, have both fgen.m and fgenui.m in the same directory, and then type “fgenui” in the MATLAB command window.

Next
Next

Practice Pedal