Things Used In This Project
Digilent Analog Discovery 2
Software apps and online services:
Digilent WaveForms 2015
Spectrum analyzers are simple to use tools that take rather complex measurements and make it easier to understand what your electronic doo-dad is doing. Almost all electronic systems generate some form of electrical noise from the movement of electrons along the electrical pathways inside. Many are also susceptible to outside interference when an external frequency is intercepted. The spectrum analyzer on the Analog Discovery 2 can help you pinpoint both internal and external trouble spots to help fine tune your device for more efficient performance.
To complete this tutorial, you will need:
Analog Discovery 2*
Waveforms 2015 software
- A computer with USB port to run the software
- You may also use the original Analog Discovery or the Electronics Explorer Board with Waveforms 2015. There are some slight differences in functionality between the AD1, AD2, and EEBoard, but nothing that will prevent you from following along if you have one of the other tools.
Step 1: Why is there interference?
First, a quick physics review. We call the physical movement or flow of electrons from one location to another "current". This flow of electrons induces an electromagnetic field around the wire carrying the flow. ANY motion of ANY quantity of electrons will generate this field, though it makes sense that with more flow, you get a larger and stronger EM field. If the flow of electrons remains perfectly constant with absolutely no change, then the size, shape, and strength of the EM field will not change either. If the flow of current in the wire changes its direction back and forth according to a regular cycle, the EM field characteristics will also follow this pattern, most notably its polarity (think which way N and S point). As the EM field changes, energy is radiated out in all directions from the wire carrying the current. This radiated energy can be picked up and measured, and at this point the process is reversed and the intercepted EM energy actually induces a current in a wire, which can then be utilized for work.
This is the driving force behind how ALL wireless communication systems work. A small circuit generates a small current that rapidly changes direction based on a very precise base frequency. The information that is being sent out is also stored inside of this base current frequency in the form of small variations in frequency or amplitude. As the current travels through the wire, the EM energy is produced and radiated through a transmitting antenna, with all of the small variations related to the information still intact. The radiated EM energy is then intercepted by a receiving antenna. The resulting current that is induced in the internal circuitry is then filtered to remove the base frequency and extract the usable data.
Ideally your antenna will only pick up the exact signal that it is intended to pick up. But we don't live in an ideal world, and stray, random signals are all around us and inside of our electronic devices. As I said, every single device that is wireless either transmits or receives EM radiation. But remember that even if your device isn't designed to be wireless, it still has small currents running all through it, each one generating its own small amount of EM radiation signals. Most of these signals go unnoticed and have no noticeable effect on the physical world for various reasons. But sometimes they do, and the results can vary from obnoxious to disastrous.
On the obnoxious side, it's just simple interference. Imagine your parents buy and wrap an RC car and place it under the Christmas tree. For some unknown reason, it has batteries installed and is turned on while still in the package. At least twice a day for the two weeks leading up to Christmas morning, you get short random bursts of noise that sounds like a small motor coming from under the tree. It turns out the antenna is picking up stray EM radiation and it is just the right frequency and contains just the right information to make the motor spin up for a second or two. However on the disastrous side, a strong EM pulse, like from a high altitude nuclear explosion, can generate such a strong EM field over such a wide range of frequencies that nearly every wire and copper trace in nearly every electronic device within the effective radius will have so much current induced on it that your device is quite literally cooked on the spot. And it will never work again without replacing every single electronic component.
You would have a very hard time protecting your circuitry from a large EM pulse, but it is possible to keep the random, everyday signals from causing problems. (An example: Most of your electronic cables can double as very effective antennas, so they are often internally shielded from EM radiation that could interfere with the electronics they connect to.) This is where the spectrum analyzer comes in handy. You can see where you are getting the strongest stray signals for your area of application, and at that point you either protect against them with your circuit design, or determine that they are inconsequential and ignore them.
You can also use the spectrum analyzer to break down signals and see what fundamental frequencies are making up that single signal you are hearing or receiving. Since this is an easier example to demonstrate, let's break down some simple signals.
Step 2: What does the spectrum analyzer do?
You are most likely familiar with looking at signals on an oscilloscope image, which plots the magnitude of the signal on the y-axis (vertical) and the time on the x-axis (horizontal). With these plots, we see that as time passes, the strength of the signal changes. This should be no surprise.
1 kHz sine wave.
Another way to visualize a plot is in the frequency domain. We still have magnitude on the y-axis, but instead of time, we plot frequencies on the x-axis. Now we can see how the magnitude of a signal changes with the frequency of that signal, regardless of when in time we find ourselves interacting with that signal.
The spectrum analyzer simply reads every single frequency within the data acquisition window. It starts at the lowest frequency, reads the signal strength at that frequency, displays the value on the graph, then moves up just a little bit to the next frequency. It does this many, many, many times a second, so all you see is a constantly fluctuating image, with spikes where you have a stronger signal at that frequency. The number of samples it takes per second, the resolution of the data read, the span of the acquisition window, etc. are all variables that can be adjusted on the go so that you get the clearest data.
Step 3: Using the AD2 and spectrum analyzer
To use the spectrum analyzer with the AD2, you will need both the AD2 and the Waveforms software.
Plug in the AD2 and open Waveforms. Open the spectrum analyzer by clicking on the "Spectrum" tab on the left side of the window, toward the bottom.
The spectrum analyzer window will pop open.
We could go over all of the tools and options now, but it will be much easier to do that with some kind of data in the window so you can actually see what is going on, so let's get a signal in first. Go back to the Waveforms main welcome window and click on the "Wavegen" button.
This opens the waveform generator window.
The default setting should be a sine wave with 1 kHz frequency and 1V amplitude. This will work just fine for now.
We need to connect the waveform generator to the spectrum analyzer. Attach the wire harness to the AD2 and using the included pins, find the "1+" (orange with no white stripe), "1-" (orange with a white stripe), "W1" (yellow with not stripe), and any one of the black GND wires. Connect "1+" to "W1" and connect "1-" to GND. This connects the positive lead for channel 1 of the analyzer with channel 1 of the waveform generator. The negative lead for channel 1 of the analyzer connects to system ground so that the analyzer has a relative 0V reference point.
With the wires connected, turn on the waveform generator by clicking "Run" at the top of the window. Go to the analyzer window and click "Run" as well. Without changing any default settings, you should see something like this:
The image is constantly jumping around because the analyzer is constantly getting random amplitude readings at all of the frequencies between your lower and upper frequency limits. Also, the frequency we chose by default is difficult to see in this image. So let's make some adjustments so we can see it better.
The first thing I like to do is remove data that is not useful. On the right side of the window, you will see two boxes that correspond to the two analyzer channels. Since we are only using channel 1 at this point, click on the little check mark in the top left corner of the channel 2 box. This will remove the channel 2 readout from the window and we are left with only channel 1.
Next, at the top of the analyzer window you will see a small green arrow at the right hand side of the screen. Click this arrow and you will have some various options.
You can set the lower and upper window limits manually by entering in values into the "Start" and "Stop" boxes. You can also use the "Center" and "Span" boxes. We already know that we have a 1 kHz signal, so let's leave 0 Hz in the start box and put in 5 kHz in the stop box. You should see something like this:
You can also adjust the window size by deciding on what frequency you want the window image to be centered on, and then giving the window a span, or width. The span is divided in two, and then that resulting value is added or subtracted from your center frequency to give you your window max/min values respectively. Since we are looking at a 1 kHz signal, put 1 kHz in the center box and make your span 1 kHz. This will make the window center on 1 kHz and the x-axis scale will go from 500 Hz to 1.5 kHz.
You will also notice that the image doesn't appear to "run" as fast now. Go back up to the top of the window and click on the BINs drop-down arrow. By choosing a smaller value, you change the number of frequency BINs you are using. (Basically it divides up the window into that many slices and takes a sample at each one. It then just draws a straight line between each data point.) This will automatically adjust the sample rate as well as your resolution. The image will now run faster, but you don't have as much data to work with. Make adjustments as you see fit.
Ok, so now we have a pretty good view of what is going on. We can see that we have a solid spike at 1 kHz, and a ton of smaller spikes in the rest of the window. When we look at the magnitude axis (vertical) we see that it is set on decibels (dB). This is a very common way to measure signal strength. Most of the noise is centered right around -70dB, which is an extremely low value. This indicates that the noise is exactly that, just background noise in the system, but it is so low that it shouldn't have any effect on the system. It comes from transient signals generated by whatever interfering signals are around you, as mentioned previously. If we were in the radio frequency range with an antenna attached, you could pick up the background radio noise of space.
Now let's have some fun with this. One of the unique things about signals is that anything other than a pure sine wave is actually composed of multiple sine waves of various frequencies, all of which are integer multiples of the base frequency. They also vary widely in magnitude, with the base frequency having the highest magnitude. This idea was first posited by Joseph Fourier and the idea became known as the Fourier Transform.
We can see this breakdown of a simple square wave using the spectrum analyzer. Go back to your waveform generator window and click on the box to choose the type of signal. It should say sine, but when you click on it, you will get a bunch of different options. Click on "square" and set the frequency to 20 kHz.
Go back to the analyzer window. Set your center frequency to 20 kHz and span to 40 kHz. You will see a very clear spike at 20 kHz and then a bunch of noise. This makes sense since the square wave frequency is at 20 kHz.
Now let's expand our view and see what's really going on. Set your center to 500 kHz and your span to 1 MHz. You should see something like this:
Now let's see what frequencies are the strongest. You should be able to tell from the image, but if you play with your window start and stop values or the span value, you will see signal peaks at various places that won't be apparent with a different resolution. To see exactly which frequencies are strongest, click on "view" at the top of the window and then choose "components". A small side window will pop up showing all of the strongest frequencies that can be seen in the current window. By adjusting the window max/min values, these readings will change. Which frequency is the strongest? Does that make sense?
You can change the number of components displayed by clicking on the small gear in the component window and changing the value in the option box. If you click on the "stop" button at the top while the component window is open, you can click on any of the frequency values and a vertical red line will appear in the window at that frequency.
Click on "run" again and let the analyzer do its thing. If you look all the way to the right side of the screen, you will see the little box that gives you trace options. Click on the drop down menu beneath "type" and you will see several options. My favorite is "peak hold continuous" so click on that and see what happens in the window. This can be helpful to remove the noise and capture small peaks that are not noise but still rather weak and can be lost in the noise.
Now that we've looked at a square wave and most of the core analyzer options, let's take a look at how some other signals break down. Go back to your waveform generator and try the same type of wave at different frequencies. Then choose different wave types at the same frequency. See where you have similarities and differences. I've included a couple below.
20 kHz triangle, 1V peak
20 kHz ramp up, 1V peak
Now just for fun, let's see how random the noise generator is. Click on the "noise" option for wave type. If you want to hear it, make the frequency below about 15 kHz and plug some headphones into the audio jack on the AD2. (It would be a good idea to set the magnitude of the waveform at about 200 mV peak or less to keep from damaging your ear. Also, you are only using one channel, so you will only hear it out of one ear. This is normal.) Go back to your analyzer and set your window so that your base frequency is within the window. We chose a 5 kHz signal for the following image:
Not so random, is it? If you are familiar with computer programming, or even randomness in general, you know that it is extremely difficult to generate truly random results. Humans simply can't do it, and neither can computers. What is being generated here is a very set pattern of various magnitudes of nearly every frequency in the entire spectrum (zoom out with your start/stop values to see). But the pattern is close enough to random that we perceive it as such.
Step 4: Further investigation
You can use a spectrum analyzer to analyze any type of signal that you can convert to electrical impulses. Connect the analyzer channel to the output of a microphone circuit and sing a single note, or play one on an instrument (any of you ever use a guitar tuner? Guess how that works). It's not one single frequency, is it? the example of this is a YouTube video by Anna-Maria Hefele (see below or direct link here). She sings a constant fundamental tone, and by shaping her mouth she can filter and amplify the overtones that are always present in the sound, but are normally too weak to hear on their own when compared to the fundamental. In this way she can sing multiple notes at the same time. In the video she uses an audio spectrum analyzer to give a frequency breakdown of her voice to show the overtones present.
If you are getting unwanted, anomalous behavior in a circuit, you can connect the spectrum analyzer to different places in your circuit and see what frequencies are interfering and where. Most electronics already filter out the 50-60 Hz signal that leaches into them from the AC power from the wall. The generators at the power plant turn at that rate, and that frequency moves all the way down the line and into your device. But it often shows up in home built circuits, usually related to the power supply. By adding a capacitor across the power rails you can filter it out.
Fluorescent lights flicker at twice the frequency of the AC power supply, so in North America it's about 120 Hz. This EM energy can be picked up by the right type of antenna, intentionally or not, and may cause interference. Also, as mentioned before, cell phone, television, & WiFi networks, as well as devices like portable radios, all generate signals that can cause interference.