Close

Testing out the Spectrum Analyzer and Getting Results

A project log for Affordable Spectrum Analzyer

Analyze electrical signals using a raspberry pi with a user interface designed for students, hobbyists, and other beginners.

dan-kislingDan Kisling 07/10/2016 at 23:590 Comments

It's the log we've all been waiting for. I've been hand wavy all this time. Does any of this stuff actually work?

Of course, at first, no. None of it worked. Everything was broken. Or maybe that's just how it seemed. But by the second revision of the board and the um-teenth revision of the software we got somewhere. Here's one of the first tests we did of the spectrum analyzer. I did it in my dorm room late one night. Since it was just my room, we improvised for a few things. Instead of a nice lab grade function generator, we used a function generator app on my cheap tablet using the headphone port. The D/A on that tablet is kind of crappy, so were not paying that much attention to every detail, we are most interested in seeing if the frequency that tablet says close to that of the spectrum analyzer. You can't tell that much from the video, especially due to the lighting, but you can see the peak frequency move from right to left as the frequency increases on the tablet (and is simultaneously being shown on an oscilloscope on the right).

From there we did a few improvements, and more tests - this time using a lab grade function generator. Here's a video using our superheterodyning technique signal path. In this setup our maximum frequency we can see is 100kHz.

Here's another video, this time bypassing the multiplier and bandpass filter for a simpler input scheme. This design allows us to see signals up to 500kHz.

We have tested the alternate design with signals up to 500kHz with large success. Below are plots made and saved by our spectrum analyzer for different signals provided by the signal generator in lab. Sine wave inputs give us a good view of how accurate our frequency measurements are. In each of these tests, we have the spectrum analyzer determine the frequency, which should be accurate to 124Hz (1MHz / 8092 Samples). Square wave inputs give us a good idea of signals with a wider spectrum and allow us to see if there are any aliasing problems. In the alternate design, this should not be an issue as the signal is just fed from an input amplifier straight to the analog to digital converter. The square wave test (which is done without changing the frequency setting on the signal generator) also allows us to see the consistency of the determined fundamental frequency by the spectrum analyzer. The square wave test will become more important in the full system design.

Spectrum Analyzer Capture: 5kHz Sine Wave Input

Spectrum Analyzer Capture: 5kHz Square Wave Input

Spectrum Analyzer Capture: 20kHz Sine Wave Input

Spectrum Analyzer Capture: 20kHz Square Wave Input

Spectrum Analyzer Capture: 56kHz Sine Wave Input

Spectrum Analyzer Capture: 56kHz Square Wave Input

Spectrum Analyzer Capture: 450kHz Sine Wave Input

We have also tested the full design with similar success. One issue that arose during test of the full signal path design is the accuracy of the frequency reading. The reading was pretty consistently off by about 2kHz. Since we knew the alternate design was performing correctly, the 2kHz offset must be created by an element introduced in the full system design: the multiplier, the oscillator, or the band pass filter. The band pass filter and multiplier options did not make much sense, so the oscillator looked like the culprit. Looking in the data sheet, we realize that the oscillator has 0.5% initial accuracy, which seems low until you realize that 0.5% of 455kHz is 2.275kHz.

To test our suspicions, we used the alternate design to probe the output of the oscillator. This would allow us to see the spectrum of the oscillator and easily determine exactly what frequency it was operating at. The oscillator is supposed to operate at 360kHz, 370kHz, 380kHz, 390kHz, 400kHz, 410kHz, 420kHz, 430kHz, 440kHz, and 450kHz. Below are select captures of the spectrum when varying the frequency setting on the oscillator.

Spectrum Analyzer Capture: Oscillator set to 360kHz

Spectrum Analyzer Capture: Oscillator set to 390kHz

Spectrum Analyzer Capture: Oscillator set to 450kHz

Finally, we propose a table summarizing our results of this test.

Table summarizing error in set frequency vs. measured frequency without correction

To prove that initial accuracy causes the inaccuracy, we introduce a correction factor. The correction factor is added to the frequency sent over SPI to the local oscillator, but then is interpreted in the rest of the code as if we didn’t introduce that correction. So the local oscillator is set 2kHz under its intended frequency, and the program treats it as if we used the intended frequency. The table below shows us testing the same local oscillator values, now with the correction factor. The difference in frequency is so low most of it can be accounted for in frequency resolution, which was only tested at 150hz resolution. We find that the frequency error was caused by initial accuracy of the oscillator.

Table summarizing error in set frequency vs. measured frequency with correction

We also verified through a series of tests that our system could handle voltages as low as 5mV and as high as 5V with good accuracy. Some issues arise when the signal gets close to 500kHz and higher gains are used, as the LTC6910-1 does have a somewhat limited gain bandwidth product.

After calibration was complete, we tested our spectrum analyzer in full signal path mode. In this mode we are able to see inputs up to 100kHz. Listed below are captures from our spectrum analyzer in this functionality.

Spectrum Output in Full Signal Path Mode: 10kHz Sine Wave Input

Spectrum Output in Full Signal Path Mode: 14Hz Square Wave Input

Spectrum Output in Full Signal Path Mode: 45kHz Sine Wave Input

Spectrum Output in Full Signal Path Mode: 63kHz Sine Wave Input

Spectrum Output in Full Signal Path Mode: 98kHz Sine Wave Input

We were very satisfied with these results. They show there is still more work that can be done, but by golly we got a working spectrum analyzer built on the raspberry pi, running on code that we wrote using a board we created!


Discussions