DSP Spreadsheet: Talking to Yourself Using IQ
We’ve done quite a bit with Google Sheets and signal processing: we’ve generated signals, created filters, and computed quadrature signals. We can pull all that together into an educational model for two SDRs talking to each other, but it’s going to require two parts: modulation and demodulation. Guess what? We can do that with a spreadsheet.
The first step is to generate a reference clock for the carrier. You’ll need a cosine wave (I) and sine wave (Q). Of course, you also need the time base. That’s columns A-C in the spreadsheet and works like other signal generation we’ve seen.
The Plot Thickens
Think about the IQ plot of what we have so far. Plotting IQ means putting I on the X axis of a graph and Q on the Y axis. When I=1, Q=0. That’s a spot right on the X axis at X=1. The same thing happens, but flipped around when I=-1. It also happens when I=0 and Q=1, but rotated 90 degrees. The key is that, in each case, the length of the vector is 1. Every spot, in fact, will have a length of 1 because sin2(x)+cos2(x)=1. If you look at the first 12 rows of the spreadsheet with default values, you’ll see that X and the Y move between 1 and -1 in such a way that the sum of their squares is always 1.
What does that mean? It means the IQ reference signal will draw a circle of radius 1 on the IQ plot. If we multiply both by the same amount, the radius will change, but you’ll still get a circle. That’s AM or amplitude modulation. You can think about a few other things, too. For example, if I and Q were exactly the same (an easy change to make in the spreadsheet; just set both columns to the sine or cosine), the phase angle will always be 45 degrees or 225 degrees. and the amplitude would always be the square root of two (assuming the original signals go from -1 to 1). Multiplying both by the same number will change the amplitude of the signal, but not the phase.
Multiplying one part of the IQ by some number and not the other will cause a change in phase. Imagine the part of the graph where I and Q make a 45-degree angle — that is, I=Q. If you make Q bigger, it must change the angle of the vector. So by manipulating the reference IQ signal we can create amplitude modulation or phase modulation and changing phase can also create frequency modulation.
Put it to the Test
In real life, you might have two stations both using DSP techniques to transmit and receive. In that case, the transmitter generates a reference IQ signal, manipulates it, and winds up putting out a single RF signal to the antenna.
The receiver can’t know for sure if the sending station is using DSP or not, but it doesn’t matter. The signal is the same either way. The receiver will generate its own IQ reference signal and reverse the transformation. Sort of. The problem is, there’s no way to know if the transmitter’s reference signal is in phase with the receiver’s. However, the relative phases will be the same and that’s all you care about if you even care about the phase at all.
There’s one other issue. When you recover the signal it will ride with a higher frequency signal that you’ll need to filter out. Luckily, we already know how to do that.
In the Sheets
Here’s how to read the spreadsheet. The main tab is where most of the action is. You can set the usual parameters at the top. The first three columns are the time base and the IQ reference signal. I’ll cheat and reuse these on the receive side, too. If you wanted to prove it would still work if the reference signals were out of phase, you could easily make the modification.
The rest of the columns up to column G are modulating the IQ reference. The resulting “radio” signal is in column G. This is both the output of the transmitter and the input to the receiver.
The receiver is in columns H and I because I reused the time base and the reference signal. If you look at the plot of the input signal and the output, you’ll see the high frequency component I mentioned.
Note that the modulating signal on I and Q are the same, so you only see the Q signal (the blue I signal is directly underneath it). Although you can see the low frequency matches the modulation signal, you can switch to the second tab to filter the high frequency component out.
That sheet uses the FIR filter technique we talked about before. The filter has a passband from 0 Hz to 60 Hz and the stopband starts at 100 Hz. You can see a partial gain vs frequency plot. There are 57 taps, so we will miss the first 57 samples as the algorithm loads itself with data.
Of course, the filter shifts the phase of the signal and misses the first few samples, so the time axis doesn’t align, but that doesn’t matter. Without a synchronized IQ reference, there wouldn’t be any hope of phase alignment anyway.
Final Tab
The final tab takes the data and allows you to do a vector plot against any of the samples. I cheated and used a script to enable the big arrow buttons, so you may have to grant permission before that will work. However, you don’t need the buttons if you don’t mind manually changing cell E1. It takes a little work to get the spreadsheet to make nice vector diagrams:
Honestly…
In a way, it is amazing you can do this much modeling in a spreadsheet. If you were serious, you should really think about using something like Juypter or — honestly — anything else. However, if you want to learn DSP concepts, having to learn a new tool first can be pretty daunting.
Using nothing more than a spreadsheet, you can use this model to think about what happens under certain circumstances. Once you outgrow it, you can move to something like MATLAB or any of the numerous clones of it, or tackle your code in C, Python, or whatever your language of choice happens to be.
from CommaFeed - Real Time Trends Network https://ift.tt/2XY6FOO
via IFTTT
Comments
Post a Comment