How exactly are the IQ channels supposed to be calculated/processed?

Show off any of your RTL-SDR or cheap SDR related projects.
Post Reply
Posts: 20
Joined: Wed Feb 15, 2017 9:52 am

How exactly are the IQ channels supposed to be calculated/processed?

Post by Ben321 » Fri Feb 15, 2019 1:30 am

I had assumed that it worked like this. A radio signal from the antenna if split into identical copies. One is then multiplied by a Cosine wave, and is called the I signal. The other is multiplied by a Sine wave, and is called the Q signal. The 2 sinusoidal waves are described by the equations Cos(2*Pi*F*T) and Sin(2*Pi*F*T), where T is the analog time in seconds since the SDR receiver was turned on, and F is the frequency (in Hz) that the SDR is tuned to. The signals are then filtered to half the sample rate (LPF is at 500kHz if the sample rate is at 1MHz, for a total IQ bandwidth of 1MHz, but each channel only has 500kHz bandwidth), and then saved as a stereo (2 channel) WAV file.
In other words:
I = RF * Cos
Q = RF * Sin

Going based on this assumption, I realized that to reconstruct a full bandwidth 1-channel signal, I would need to first resample it to twice the original sample rate (2MHz, if the original was 1MHz), which I did. Then I multiply each channel with a sinusoidal wave who's frequency is equal to half of the full IQ bandwidth (500kHz if the full bandwidth is 1MHz). To properly reconstruct it in this case, I figured I'd multiply the I channel by a Cos wave, and the Q channel by a Sin wave, and then add them together to get the full bandwidth 1-channel signal. In other words RF=I*Cos+Q*Sin.

However, I found something was wrong when I processed the signal based on this assumption. The spectrum of the resulting signal was inverted. What should have been at the upper end of the band ended up at the lower end, and what should have been at the lower end was at the upper end. I figured out 3 ways to correct this:
Multiply I by Sin and Q by Cos, instead of multiplying I by Cos and Q by Sin. (RF = I * Sin + Q * Cos)
Multiply I by -Cos instead of by Cos. (RF = I * -Cos + Q * Sin)
Multiply Q by -Sin instead of by Sin. (RF = I * Cos + Q * -Sin)

Using any one of these 3 techniques produced a signal who's spectrum is correct. This means that my assumption as stated in the first paragraph is apparently wrong. The original IQ signal from the SDR must instead be calculated in one of the 3 following ways:
I = RF * Sin
Q= RF * Cos
I = RF * -Cos
Q= RF * Sin
I = RF * Cos
Q= RF * -Sin

And I'm not sure which way it is. While I can use any of the 3 techniques mentioned 2 paragraphs ago to correct the inverted spectrum, there's no way to know that it's generating a signal identical to the original. For example, it could be that the values in the RF waveform would be inverted (output=-1 when input=1). To get an unaltered output waveform, I must know the exact way that an SDR generates the IQ signal to start with, and then I must also know the correct way of reconstructing the RF signal, given an IQ signal that was generated with a certain calculation.

My hunch is that the IQ generating mechanism must exactly match the RF reconstruction algorithm, such that:
If IQ is generated by
I = RF * Cos
Q= RF * -Sin
then the RF must be reconstructed by RF = I * Cos + Q * -Sin

Could somebody here fill me in on this? And what is the equation for the most common way that RTL-SDR devices generate an IQ signal?

Posts: 66
Joined: Sat Jan 14, 2017 11:07 pm

Re: How exactly are the IQ channels supposed to be calculated/processed?

Post by hotpaw2 » Wed Feb 20, 2019 12:54 am

Note that:
(x+iy)*(x-iy) = x^2 + y^2
a * (cos(w) + i*sin(w)) * (cos(w) - i*sin(w)) = a * (cos(w)^2 + sin(w)^2) = a * 1 = a
w = 2 * pi * f * t

Both e^iw and e^-iw are used to get e^0, which leaves the original RF signal unchanged.

Note that simple multiplication can be used for the first heterodyne from RF to IQ,
But simple multiplication rather than complex multiplication can only be used for the second conversion, from IQ to strictly real RF, only if you know you are going to throw away the imaginary component, or you know the imaginary component is going to be zero.
Last edited by hotpaw2 on Wed Feb 20, 2019 5:03 pm, edited 1 time in total.

Aussie Susan
Posts: 33
Joined: Sun Jul 31, 2016 1:55 am

Re: How exactly are the IQ channels supposed to be calculated/processed?

Post by Aussie Susan » Wed Feb 20, 2019 1:40 am

Just a point of clarification between the two posts (so far).
The first post uses 'I' to refer to the 'in phase' component of the original signal.
However the 2nd post uses 'i' as the imaginary number (sqrt(-1)).
On a screen and reading quickly it is easy to confuse 'I' and 'i' so be careful when reading these formula.
(Personal opinion - as an Electrical Engineer, I always use 'j' instead of 'i' because 'i' - or more correctly 'I' - is used for current. It also makes this sort of discussion a bit clearer.)

Post Reply