Close

Simulation

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 21:090 Comments

In this log I'll describe the simulation Andrew and I created to verify our sampling technique. Simulation is powerful technique that allows us to create our circuit and see how well it works. It allows me to make changes to our system quickly and efficiently to see their effects. Even faster than breadboard testing.

To prove that our signal capture technique would work, a few different matlab simulations were created. The first simulated our entire system, allowing us to “probe” signals along the signal path. A second simulation was created to validate our idea about eliminating the second oscillator. The results of the second simulation were then integrated into the first to create a full system that tested the viability of our system. The simulation modeled our sampling method, analog manipulation, and FFT algorithms. In this simulation an input spectra (up to 100kHz) is created and the system breaks the spectra into ten windows of 10kHz each using our method. The bandpass filter implementation is with the actual transfer function of the filters, so it can realistically show how the filter will actually act in the circuit. The oscillators are perfect cosine waves, but can easily be modified to be not ideal in order to understand the effect of a real IC oscillator. The sampling is simulated by a function that only takes every few points from the output and then computes an FFT on that signal. The output of the simulation is included with analysis below.

Plots from Full System Matlab Simulation

The above waveforms shows (top) the input spectra into the system. This is a bit random but it is important to test frequencies near the edge of the window (at 10kHz increments). Below are ten smaller plots, which show the system’s response to the input at different frequencies of the first local oscillator. As the local oscillator decreases (in 10kHz steps) different sections of the original input spectra are pushed into the region of the bandpass filter and are thrown back into the baseband by two different means. The simulation does this by either using a second oscillator or through undersampling. Though some digital manipulation, these 10 windows are then spliced together to create our final window, a recreation of the input spectra. We see in this simulation that we are able to restore the original spectra with no aliasing. This was true for both the case using the second oscillator and that of undersampling. The only noticeable difference between the top spectra (input) and bottom spectra (output) is a scaling to the amplitudes, which can be corrected by inverting the transfer function of the bandpass filter in digital processing. The main takeaways so far are the relationship with the actual sampling frequency and the ability of the system to produce an output without any aliasing. So far we have found that a sampling frequency of 110kHz will produce these results. We are pleased with this result as we have read of methods to input data into the raspberry pi with sampling frequencies much higher than these. In addition, 110kHz is less than the 200kHz that would normally be required for a sampling frequency of a signal that extends to 100kHz. To further that goal of extending input frequency, not causing aliasing, and minimizing sampling frequency quadrature filters are considered and simulated.

As a final note on the simulation, it was determined that the band pass filter used in the simulation would actually distort the signal too much, was costly to build, and added a great deal of complexity. Instead, a pre-packaged band pass filter was found that was originally designed for radio at 455kHz. We knew that we could rearrange the oscillator and other spacing to make this frequency work. The added benefit is a near-brick-wall band-pass filter that is low cost and very reliable.

Our full matlab code can be found on github.

Discussions