Random Quote Board
Understanding IQ Signals
The genesis of this post was a question from a student years ago. While discussing complex signals and samples and I and Q and all that those terms entail, he asked the question, "Why can't we just process signals in real-only form?" He expanded on his question by stating he thought that real-only processing would be easier than complex processing.
First, we do process signals in real-only form. These signals are (typically) the ones that we obtain after we've demodulated some RF signal. The output of the demodulation circuit is almost always a real-only signal. So, again, we do process signals in real-only format.
The basic answer is that it makes the processing not necessarily easy, but it does make it easiER.
It's primarily modulated signals, whether in transmission (modulation) or reception (demodulation) where we're dealing with complex signals. That's because we tend to think of modulation as the process of varying some parameter of a sinusoid in order to convey information from one point to another. When dealing with the parameters of sinusoids, complex is easier, even if it is not necessarily easy. We need to discuss a few things to understand why this is.
What is IQ?
First, we need to talk about IQ signals. What is IQ? We're not talking about the now-debunked concept of "intelligence quotient". We're talking about "in-phase" (I) and "quadrature" (Q). Those are the terms used to describe the real and imaginary signals, respectively, that, together, create complex signals. "IQ signals" is synonymous with "complex signals". And once digitized, they become complex samples. It's complex samples that come out of pretty-much every SDR in existence. These are the samples that represent whatever portion of the spectrum we've chosen.
Why represent and process signals this way? Here's why. As stated, modulation talks about how we vary one of the parameters of a sinusoid. A sinusoid has three parameters that we're interested in here. These parameters are:
- Amplitude
- Frequency
- Phase
Measuring amplitude and frequency (again, inverse of the period) are straightforward. Measuring amplitude is something you could do with just a multimeter.
If you had a multimeter that could measure a signal millions of times a second.
And if you could write down the results that fast.
Frequency is somewhat similar, except you're measuring time, not amplitude. Find the point where the waveform repeats, and measure the time difference. This is the period. The inverse of this is the frequency. A common method for measuring frequency is the zero crossing method. I've even used this for demodulating FM signals. But its rather coarse. The zero crossing demodulator required operating at a much higher sample rate than is needed with other methods, such as the polar discriminator. What would be better is if we could measure frequency literally on a sample-by-sample basis.
Hold that thought.
What if we used the phase? Frequency and phase are related. Frequency is the change of phase over time, which mathematically looks like:
\( \LARGE f = {\Delta \theta \over {\Delta t}} \)
The only issue is that we need some way to measure the phase. If we can measure the phase, we can use the equation above to calculate the frequency. Plus measuring the phase would be useful in its own right. But how do we measure the phase?
How to Measure Phase
If we wanted to measure the phase of a sinewave, we'd need another sinewave to use as a reference. That's what makes measuring phase different from measuring the amplitude or frequency. Let's assume we have two sinewaves. Let's assume each sinewave is the same amplitude and frequency as the other. In other words, two, identical sinewaves. Let's assume that one of these sinewaves represents our signal-of-interest. The other represents our reference, and is generated in our receiver. It's one of the local oscillators. If we multiply these two sinewaves together, we wind up with yet another signal. That signal will also be a sinewave, but with twice the frequency of the original sinewaves, plus it will have a DC offset.
If we create a phase shift between the two sinewaves before multiplying them together, we still wind up with a sinewave that is 2x the original frequency. The only difference is that the DC offset isn't as high. And as the phase shift increases, this DC offset changes.
This leads to the two insights. The first is that, when the phase difference between our sinusoids is π/2 radians (90 degrees), the DC offset value is zero. That's because two sinewaves that are offset in phase by 90 degrees are said to be orthogonal. Orthogonal refers to when you multiply two signals together, sum up the products, and the sum is zero[2]. The cosine and sine functions create sinusoids that are 90 degrees (π/2 radians) apart. This will become important in a moment.
The second insight is that the phase difference causes a DC offset. Which means we can use the DC offset to determine the phase difference. It turns out that the amplitude of this DC offset is equal to the cosine of the phase difference. This explains why its maximum at a phase difference of 0, and 0 at a phase difference of π/2 radians (90 degrees). Now we need a method to separate the sinewave and DC offset. If we look at the spectrum of the multiplied sinewaves, we get this:
Which leads to the solution. If we use a lowpass filter to filter out the 2x tone, we're left with the DC offset. The amplitude of this DC offset is a measure of the phase difference.
Phase can be drawn on a polar plot, with the positive x-axis as the reference (0 radians). Plotting the phase difference this way, we have the horizontal side of a triangle displaying the DC offset. Again, this tracks with the DC offset being equal to the cosine of the phase difference.
But this leads to the next problem. The DC offset from our circuit will be the same whether our phase shift is positive or negative. Phase is typically measured from -π to +π. This circuit we've shown above will only show us the phase difference for half of this. We can only measure from 0 to either +π or from 0 to -π. The offsets will be the same either way. But we have no way to determine if we're on the positive or negative side.
How do we tell the difference between these two regions? The answer is: We use a second sinewave that is offset from the first by 90 degrees (π/2 radians). In other words, we use two sinewaves that are orthogonal from each other. Another way to state this is that we use two sinewaves that are in quadrature from each other. If we look at the first sinewave as allowing us to measure the DC offset on the horizontal axis, we can look at the second sinewave as allowing us to measure another DC offset on the vertical axis. To do this, we set up a separate circuit similar to the first one. The only difference is the 90 degree (π/2 radian) phase shift between the two sinewaves generated as part of our local oscillators. Because we're using two oscillators that are in quadrature, and due to the fact that each circuit is similar to an amplitude demodulator, this type of circuit goes by the term quadrature demodulator.
Plotting these two DC offsets as an XY plot, we get something similar to this. If we have a sinusoid that is the same frequency as our two reference signals, but with a 45 degree (π/4 radians) phase difference, we'll wind up with a diagram such as is shown below.
We can implement a quadrature demodulator in Gnu Radio Companion to demonstrate the concept.
We've taken our original signal and turned it into two signals. Each one was created using orthogonal signals. You know what type of math uses two orthogonal values? Complex math. What we've just created is a complex signal. Note that "complex signals" does not mean "digital signals". Complex signal processing has been around for over seven decades. Color television required phase modulation (and demodulation), and the demodulator circuit in televisions had something similar to this.
There's one aspect to this that we skipped over. We were focusing on the phase. But the amplitude of the two multiplied signals also affects the amplitude of the DC offset. Thus, if we have an input signal whose phase is not changing, but whose amplitude is, then we would see this as a variation of the magnitude, as opposed to a variation of the phase.
Creating Complex Samples
But we're aiming to create digital signals that a computer, of some form, can process. This requires some form of an analog-to-digital converter (ADC). This can occur before or after the quadrature demodulation. Most of the low-cost SDRs, such as the HackRF One and HackRF Pro, Airspy R2, SDRplay RSP1A, and Ettus Research USRP B200 mini, perform quadrature demodulation first. All of these SDRs perform the real-to-complex conversion using analog signals. Then they have dual ADCs (one each for the I and Q) following the quadrature demodulator. The rest, such as the RTL-SDR and Signal Hound's BB60C, perform ADC on a low frequency IF, then digitally perform the quadrature demodulation[3].
Again, complex signals does not mean digital. These are two, separate things. That's why these two things occur in two, different circuits in the SDR.
Regardless, at the output of these two circuits, the quadrature demodulator and the ADC, you wind up with complex samples. It doesn't matter which comes first, quadrature demodulation or ADC. You wind up with the same complex samples either way. It's these complex samples, which are nothing more than numbers representing the amplitudes of the real (in-phase) and imaginary (quadrature) components of those DC offsets, that are what come off of whatever SDR you're working with. We tend to call these samples "IQ samples" or sometimes just "the IQ".
Measuring the Parameters
We're now at the part where we can talk about how using complex signals makes the processing easier, even if it is not necessarily easy. The fact that these signals are in digital format, meaning they're complex samples, makes it even easier. We started this discussion by creating a circuit to measure phase. Unlike our original sine wave, where it was straightforward to measure amplitude and period (the inverse of frequency), but more difficult to measure phase, we now have a circuit that makes it easier to measure amplitude and phase, and frequency is one, extra step. Amplitude and phase can be calculated directly from each sample as follows:
\( \Large A = \sqrt { I^2 + Q^2 } \)
\( \Large \theta = atan ( Q / I ) \)
where:
- I = in-phase (real) sample
- Q = quadrature (imaginary) sample
- atan: arctangent (aka "argument") function
This leaves the last parameter, frequency. As stated, frequency is the change of phase over the change in time. We can do this by calculating the phase of two, consecutive samples, finding the phase difference between them, then dividing by the time difference[4].
\( \LARGE f = \frac { \theta_2 - \theta_1 }{ \Delta t } \)
Thus, with complex samples and basic math, we can calculate all three parameters. Not only that, but we can do so on a sample-by-sample basis.
That "Negative Frequency" Concept
Let's talk about another area that causes confusion. Now that we (hopefully) have some understanding of how we create complex samples and the constellation diagram, we can add the concept of "negative frequency". To be clear, we're not talking "negative frequency as in the inverse of negative time". No. This concept applies when we're looking at a constellation diagram and the IQ samples plotted on it. If the incoming signal and oscillators are perfectly in phase and at the exact, same frequency, then the plotted points will not move. But if the frequency is different between them? Then the points will circle the center of the diagram. Whether the frequency is positive or negative is dependent on whether the plotted points circle clockwise (negative frequency) or counter-clockwise (positive frequency). The frequency itself is the same either way.
Again, when we're talking "positive frequency" and "negative frequency" here, we're simply talking about whether that phasor is spinning clockwise or counterclockwise.
How Can the Sample Rate Match the Bandwidth?
Just as the frequency is the same whether its positive or negative, this also applies to the Nyquist limit. Sampling and the Nyquist limit only cares about the absolute value of the frequency. Whether it's "positive" or "negative" is irrelevant. Further, because the positive and negative frequencies of a complex signal can be unique, we can literally center the bandwidth of our signal at 0 Hz. For example, if we have a signal with a bandwidth of 1 MHz centered at 0 Hz, the maximum frequency, positive or negative, will be 1/2 of 1 MHz, or 500 kHz. The minimum sampling rate for 500 kHz is 2 x 500 kHz = 1 MHz. Thus, with complex signals, our sample rate can equal our bandwidth.
Note that we've not violated Nyquist. Our sample rate still must be twice the maximum frequency. It's just that, thanks to complex math, we can fit more signal into the same sample rate. This is also why, when you look at a spectral display on one of your favorite programs, the span will typically be the the sample rate centered on whatever center frequency your SDR is tuned to.
Summary
I realize this is a lot of information. Let me try to summarize why processing samples in complex form is a better way to go.
- Lower sample rate. Because of the unique nature of the positive and negative frequencies, we can use the lowest, possible sample rate. This means we can use a sample rate roughly equivalent to our signal bandwidth. If we used real-only processing, our sample rate would have to be at least 2x as high.
- Covers all parameters. We arrived at complex signals by explaining how to measure phase. What we wound up with was a way to measure all three basic parameters on a sample-by-sample basis.
- Easier frequency shift. If we want to frequency shift a signal, even if it is real-only, doing so with a complex sinusoid requires far less processing than does a real-only frequency shift. Real-only requires careful mixing to ensure no overlaps between mixing products. Complex mixing does not require this careful attention.
In my next post, I'm going to go into IQ file formats. See you then!
Footnotes
[1]: You may be wondering, "If you can calculate the frequency from the phase, why can't you calculate the phase from the frequency?" Good question. The answer is that, frequency is the derivative of phase. Which means phase is the integral of frequency. When you integrate, you need a constant. That constant is unknown in this instance. Regardless, this would still be a coarse method and there's a better way to do it anyway.
[2]: B.P. Lathi, "Modern Digital and Analog Communication Systems (Third Edition)", Oxford University Press, 1998, p. 33.
[3]: When performed digitally, the quadrature demodulator can be combined with a downsampler (decimator). Together, this circuit is called a "digital downconverter" or "DDC".
[4]: The actual method by which frequency is measured typically involves multiplying consecutive samples together before the actual phase is calculated. This is the basis of the frequency discriminator known as the polar discriminator.