I have been spending way too much time playing with the new 3D printer, so have to get back to some electronics. Since the next CWTD.ORG episode is coming up, I decided to build another ‘Test Gadget’. This time it is a Signal Generator based on the SI5351 clock generator. I had purchased a couple Chinese versions of the Adafruit 5351 module when I was working on the ‘Sweeperino Jr. ‘ and wanted to see how well they worked.
After getting the sketches written for the SI5351 board written to support multiple display types, I decided I need to write one more. Now that Pete is moving the Simpleceiver to a single conversion super-het, I will have to worry about the BFO as well as VFO frequency. Since I will probably use a different crystal frequency than Pete for the IF filter, I need to have a way to find the correct BFO frequency for both upper and lower side band. The easiest way to do that is to write a sketch that uses the 5351 as a two channel signal generator,with independent control of both frequencies.
If you are interested in electronics or engineering, you’ll have noticed a host of useful-sounding apps to help you in your design and build work. There are calculators, design aids, and somewhat intriguingly, apps that claim to offer an entire instrument on your phone. A few of them are produced to support external third-party USB instrument peripherals, but most of them claim to offer the functionality using just the hardware within the phone. Why buy an expensive oscilloscope, spectrum analyzer, or signal generator, when you can simply download one for free?
Those who celebrate Christmas somewhere with a British tradition are familiar with Christmas crackers and the oft-disappointing novelties they contain. Non-Brits are no doubt lost at this point… the crackers in question are a cardboard tube wrapped in shiny paper drawn tight over each end of it. The idea is that two people pull on the ends of the paper, and when it comes apart out drops a toy or novelty. It’s something like the prize in a Cracker Jack Box.
Engineering-oriented apps follow this cycle of hope and disappointment. But there are occasional exceptions. Let’s tour some of the good and the bad together, shall we?
Of course, it’s not that simple. Modern phones have plenty of processing power, but when it comes to analogue input and output they are restricted to only the hardware they need to make a telephone call. A single microphone input, and a stereo output that can drive a line input on an amplifier, or a set of headphones. Unless you have spent a lot of money on a very high-end phone targeted at audiophiles these will not be served by particularly high-end silicon, the ADC and DAC will top out at somewhere just above the CD sample rate of 44.1kHz and will not have the quietest noise performance. They will not be in any way calibrated, so the best you can hope for from your hardware in terms of measuring ability will be a bandwidth of somewhere just above 20KHz with no ability to produce or measure quantifiable voltages. To give some context, even a 5-dollar USB sound card for your PC will be capable of a higher bandwidth than that you’ll find in your phone.
Our question posed earlier in this piece then becomes “Why buy an expensive oscilloscope, spectrum analyzer, or signal generator, when you can simply download one for free that only has a 20KHz bandwidth and can’t accurately measure or produce a known voltage?” It doesn’t sound very encouraging, does it.
But looking at it another way, you can’t argue with free. If you are working at audio frequencies then perhaps they can offer something useful. Even with their limitations perhaps there are still areas in which they can deliver useful insights, and that’s what we’ll now investigate.
We’ve looked at the shortcomings of a mobile phone as an instrument platform, but does it have any strengths? In one respect here we are fortunate. A phone may not be able to measure voltages accurately, but it should be able to do so when it comes to frequencies and timing. All the actions of its microprocessor will be governed by a crystal oscillator, which while it won’t be calibrated to an incredible standard will still be good enough for the purposes of a free mobile phone instrument.
Even if we can’t entirely trust our phones on matters of amplitude we can do so in this field, if it returns a frequency or period reading we can believe it. Another area in which we can place some trust in our phones lies with waveform generation. Within the limitations of its DAC we know that it is designed to reproduce whatever waveforms a piece of music can supply it, so for the purposes of a very simple audio benchtop instrument we can trust it to produce the sine, square, and triangle waves we’d expect from a basic signal generator.
Having considered the likely usefulness of a mobile phone app instrument and thus having an idea of what to expect, it’s time to sit down at the bench with a phone and try a few for real. This isn’t a review of the apps themselves but a look at the feasibility of an app as an instrument, so we’ll mention a few apps but not review their individual features in detail. Our device for these tests is a Moto G4 running Android 6.0.1.
We started by looking at the performance of a phone as a signal generator. There are a lot of results for a search on “signal generator” or “function generator”, one of the ones near the top was keuwlsoft’s offering, capable of producing sine, triangle, and square waves from 22kHz down to an improbable-sounding 471.16mHz, as well as a selection of noise sources and modulation effects.
Installed on the phone, it rewarded us with a tone in the speaker after the usual moment to decipher its UI. Plugging in a 3.5mm jack with a lead to our ‘scope, and we could see the three types of waveform as expected. The frequency was measured as exactly the figure in the app. At the upper end of the frequency range above 20KHz it became obvious that the waveform was diminishing and distorting, however that is probably a feature of the Moto’s audio hardware. Otherwise the amplitude stayed pretty constant over the audio range.
On the subject of amplitude, these apps are usually calibrated in percentage of the maximum amplitude they can serve, there is no voltage reading. However to give an idea of the output level, with both the in-app gain and the device volume set to maximum we measured 945mV RMS for a 1KHz sinewave. Knowing that figure it was a simple matter of setting the in-app gain to a calculated percentage to give a lower figure, for example to achieve a 500mV RMS reading we set it to 52.91%. It’s not perfect by any means, but if you have measured the output at full volume it is possible to impose some level of calibration.
Having exercised the phone’s capabilities producing waveforms, it’s time to consider its abilities measuring them. There are a variety of apps freely downloadable that offer either oscilloscope, spectrum analyzer, or a combination of both functionalities.
The first thing we encountered when installing these apps was the nature of Android’s approach to audio hardware. By default these apps take their input from the microphone. Everyone who installs them probably spends a while whistling at their phone to see a nice waveform or spectrum peak appear, but sadly for our purposes a microphone is no use. We need a physical input, and you might think that could be served by the microphone input on the device’s 3.5mm jack plug. Unfortunately a modern phone is not the same as a cassette recorder of old, so we quickly discovered that simply plugging in the appropriate TRRS lead did not magically switch over from the microphone.
Instead that changeover is handled by software, and whether it works for you will depend on how lucky you are in your combination of phone, OS version, and app. We did not find any apps that recognized an audio source plugged into the jack socket by default on the Moto, though a couple of spectrum analyzer apps offered a source selection option in their settings between the built-in microphone, and the line input.
Happily there is an alternative that shouldn’t cost too much if your phone is a fairly recent one. Since version 5 there has been support in Android for USB sound cards, so if you have an OTG cable you can plug one in and reboot the phone to find its default audio input and output now come through the sound card. To test the oscilloscope apps we did this with the Moto and a cheap no-brand USB audio dongle, and it performed very reliably. It’s important to reboot the phone with it plugged in, we found it wasn’t always recognized when plugged in after reboot. It’s also worth noting that even though our USB card is capable of more than CD-quality sample rates there was no provision to enable these in any of the software.
Whichever way you get your working input to your phone, there is one further thing to beware of. A mobile phone input is designed only for use with a headset microphone for making calls, thus it expects a microphone level signal. It will top out somewhere well under 100mV, and anything above that (such as line level audio) will push it into distortion. Further, it does not have anything like the resilience of a real ‘scope input so unless you are only measuring up to about 50mV you will have to build some form of protection circuitry. Have a look at this preamplifier project for an example. For the purposes of our tests when using the Moto’s input jack we wound down our signal generator to an appropriate level for the input.
Having now dealt with the prerequisites of getting a signal into our phone, it’s time to look at some apps to use it. Starting with a spectrum analyzer, we found that Vuche labs’ Advanced Spectrum Analyzer offered the ability to select the Moto’s 3.5mm jack as an input, and presented an interface that was easy to get working. When presented with a sine wave it obligingly produced a single peak, and on changing to a square wave it showed the harmonic content as you might expect. It consistently identified the fundamental frequency on the low side by a few Hz, for example showing a verified 1KHz as 990Hz.
On the Y axis it returns a figure in dB. As always the question is “dB relative to what?”, and the answer here appears to be relative to the maximum level quantifiable by the device. So if you have time to calibrate it against a known instrument as described above and do some calculations you could get some idea of a real figure, however in the majority of cases this scale can at best be considered as indicative only for relative quantization of peaks.
When looking at oscilloscope apps we tried almost every one that the Google Play Store could find for us, and none of them offered an ability to select the Moto’s 3.5mm jack that would work. It’s not to say that none of them support it on other phone and OS combinations, merely that none of them worked for us. So when testing these apps we had to resort to the USB sound card mentioned above, a mild inconvenience but one that a subset of the apps had no problems recognizing.
SmartScope Oscilloscope from LabNation is a companion app to their oscilloscope peripheral which gives the features you’d expect from a “proper” ‘scope, but it also has a mode that supports the phone’s audio input. We liked it because unlike many other ‘scope apps it has a user interface allowing easy pinch-and-zoom selection of timebase period and voltage. In the time domain it’s extremely easy to measure period with this app, but the amplitude domain like those on the other apps can not be trusted when not using their peripheral and would need calibration against a known instrument. It does however handle different waveforms as you’d expect from a conventional oscilloscope, and provides a handy way to look at the shape of an audio waveform.
Cracker Or Bench? Our Conclusions
So after several hours at the bench installing and trying test equipment apps, what do we think? The overwhelming impression is that none of these apps could replace the real instrument on their own using just the phone’s hardware. It’s quite possible that with a dedicated peripheral they could provide a good instrument, but that is beyond this article.
That said, do these apps offer any useful functionality, and is it worth keeping them on your phone? We’d say yes in that a not very good instrument is better than no instrument, but we’d like to qualify that by looking at each case individually.
Signal generators, at least in the audio range, are something at which the apps do a passable job. If your voltage requirements extend only to audio line level and below, and you have no wish to venture above 20kHz, they make a useful audio source that is capable of delivering a variety of combinations of waveform. Definitely useful.
Spectrum analyzers though are not a field in which the phone performs as well as signal generation. These apps are fine in the frequency domain so as long as you stay within the voltage range of the input you can use them to gain a view of what frequencies are present, however the lack of intensity calibration is an Achilies’ heel. It’s probably best to consider these as half-useful, half-novelty.
Oscilloscope apps are sadly closer to the Christmas cracker. Yes, you can see the shape and period of the waveform, but there is only a certain amount of information to be gleaned from these readings. The most useful feature of an oscilloscope as we see it is as an accurate time-domain voltmeter, and without that ability the app becomes significantly less useful. Three-quarters-novelty, quarter-useful.
Could these apps be improved? Definitely if their developers took the time to incorporate input selection to ensure that all users could force them to listen to the microphone jack. Unfortunately the feature that would be most useful, calibration in the voltage domain, is probably beyond the capabilities of a phone’s hardware without buying extra peripherals, which rather defeats the object.
After all, the one thing these apps have going for them is that they cost nothing, and that’s more than you can say for a Christmas cracker. Do you have suggestions for useful instrument apps? Let us know in the comments below.