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

Posted:

**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

or

I = RF * -Cos

Q= RF * Sin

or

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?

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

or

I = RF * -Cos

Q= RF * Sin

or

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?