|Turn a Smart Phone into a Signal Generator|
|Written by Jacob Beningo|
Signal generators are a handy thing to have around the lab. They are perfect for testing inputs on a new hardware design and verifying the behavior of a circuit before connecting all the pieces together. In recent years these lab tools have shrunken in size and many portable versions now exist on the market. This is very convenient for an engineer on the road but often times having to bring one more piece of equipment seems to put an engineer’s bag over the 50 pound limit. This is one reason why it is becoming popular to design lab equipment that can be plugged into a smart phone. Rather than carry around another device with a computer in it, utilize the computing power and capabilities of the phone allows the device to be smaller, cheaper and weigh less!
So how can someone turn their smart phone into a signal generator? The simplest way is to utilize the headphone jack that is already present on the phone! There is no need to get fancy and try to interface to the onboard USB! Now this does of course come with limitations. A standard headphone jack will typically only cover the frequency ranges that a human can hear (20 – 20,000 Hz) in addition to getting down to about 1 Hz. This seems like a limited range but for most sensors and applications this is actually a pretty wide range. A great example application is for medical sensors such as EKG, EEG and EMG. These signals don’t have components much over 100 Hz at the most!
The signal generator can be built for less than $15! The hardware consists of a single stereo 3.5 mm headphone plug, some wire and then optionally three alligator clips to connect the signal generator to the test device. The headphone jack consists of a right and left channel in addition to a ground. Since the headphone jack includes a left and right channel two independently controlled signal generators can be made! Figure 1 shows an image of the headphone jack being soldered with three wires. The big metal tab on the bottom is the ground with the green and red wires being attached to the left and right channels. Once the headphone jack is soldered, it can be closed up and the alligator leads can be connected either through solder or the set screw depending on the type of connector chosen. The final piece of hardware can be seen in Figure 2.
There are a number of software options available for both iOS and Android operating systems. For iOS Sig Gen seemed to be the best option available on the market and for a cost of less than $3! Figure 3 shows an example of how the application looks on the phone. For Android there were far more choices than for iOS. The best looking option that was tested was called Waveform and literally was designed to look like the front panel of a signal generator! It can be seen in Figure 4. Both of these applications provided the ability to change common functions such as the output signal level, the waveform and frequency. Because this is a phone, the applications also include the ability to generate different waveforms on left and right channels of the headphone jack; each of which is independently controlled!
Now this all looks really cool so far but the real question is does it work? For a simple test, the hardware was connected to a resistive load and later on to a medical device that was in development. Setting the signal generator for a sine wave at 12 Hz, the resultant waveform can be seen in Figure 5. It worked!
There was just one small problem. Varying the output amplitude allowed for a signal of 0 to about 50 mV! Quite the curious problem! This doesn’t seem like the maximum voltage that could be driven to a pair of headphones. One would expect 3.3 volts to be the peak-to-peak voltage. It turned out that despite changing the amplitude in the application, the volume setting of the phone was determining the maximum output voltage. Changing the volume of the phone to the maximum then allowed for the expected range of voltage. This can be seen in Figure 6. Figure 7 then also shows a sawtooth output waveform just for fun.
There was only one other problem encountered with the iPhone version. If the phone went to sleep the signal generator application stopped outputting the waveform! So in order to use the signal generator the phone has to be kept from going to sleep. This is a slightly annoying problem especially since with the display on the phone battery will drain much quicker. The only solution I have at the moment for this is to simply plug the phone into a charging cable. What can be expected from a $15 dollar signal generator anyways?
This simple trick for creating a signal generator has come in quite handy! It fits a variety of applications and so far has kept my travel bag weight down considerably. There are occasions where this simple signal generator doesn’t fit the bill and a higher end portable unit is required. Commercial portable units cost around $150 and can handle frequencies upwards of 1 MHz. At a tenth of the cost though it’s amazing just how useful this little cable really is and how often it is used.
Monthly Embedded Newsletter
Sign-up for our monthly embedded newsletter with free training, labs, white papers, embedded basics, tips, tricks, tools, industry news and more! Everything you need to stay current!