To generate I & Q samples from data samples S

I = S(1:2:length(S)-1) * cos(2*pi*f*t) ;
Q = S(2:2:length(S)  ) * sin(2*pi*f*t) ;

I & Q to integer arithmetic

I = I * (2^16) ;
Q = Q * (2^16) ;

I Q combined

y = bitshiftleft(Q, 16) ; 
y = bitor(y, I);

and mixed with carrier fc

y = y * cos(2*pi*fc*t) ;

To recover the I & Q, we do:

after mixing y with the carrier fc to get baseband y, we do

Q = bitand(y, 0xFFFF0000) ;
Q = bitshiftright(Q, 16) ;
I = bitand(y, 0x0000FFFF) ;

I am assuming dividing is the reverse of the above multiplication

I = I / cos(2*pi*f*t) ;  
Q = Q / sin(2*pi*f*t) ;

My question is the above correct especially dividing by cos and sin? I am not sure how to calculate t in all the above.

Please help.

  • 1
    $\begingroup$ Hi Adam! What's the origin of this processing chain ? Where did you get the idea from ? $\endgroup$ – Fat32 Aug 8 '18 at 10:05
  • $\begingroup$ a special data communication system, not following any standard. $\endgroup$ – Adam Aug 9 '18 at 10:53

Your approach is putting the I and Q samples on a "sub-carrier" at frequency f. If that is really what you wanted to do, the typical demodulation approach is to multiply by the sub-carrier again and low pass filter to get I or Q. Dividing by cosine or sine creates time samples that go to infinity since you will divide by zero with those functions. The multiplication operation produces a baseband component and a component at twice the carrier frequency; this is made clearer with a quick refresh of the following trigonometric identities:

$cos(\alpha)cos(\beta) = \frac{1}{2}cos(\alpha-\beta)+\frac{1}{2}cos(\alpha+\beta)$

$sin(\alpha)sin(\beta) = \frac{1}{2}cos(\alpha-\beta)-\frac{1}{2}cos(\alpha+\beta)$

$sin(\alpha)cos(\beta) = \frac{1}{2}sin(\alpha-\beta)+\frac{1}{2}sin(\alpha+\beta)$

So in your case:

$cos(2\pi ft)cos(2\pi ft) = \frac{1}{2}cos(0)+\frac{1}{2}cos(2\pi ft) = \frac{1}{2} +\frac{1}{2}cos(4\pi ft)$

The $\frac{1}{2}$ represents the amplitude of I and the $\frac{1}{2}cos(4\pi ft)$ is the doubled frequency component that is removed with a low pass filter.

However I am not sure that you intended or need to have such a "sub-carrier"? If you were going to simulate QPSK modulation for example, you can modulate directly to your final carrier as in:

$I_t = I cos(2\pi f_c t)$, where $I = {1,-1}$

$Q_t = Q sin(2\pi f_c t)$, where $Q = {1,-1}$

And further the I and Q samples are sent simultaneously by adding the modulated outputs $I_t$ and $Q_t$ above (hence the increased data rate; we send two bits in each "symbol).

To demodulate, assuming we have done the carrier recovery work to have a good estimate of $f_c$ with all phase offsets removed, we can multiply the received sequence by $2cos(2\pi f_c t)$ and low pass filter to recover I, and multiply the received sequence by $2sin(2\pi f_c t)$ and low pass filter to recover Q:

Noting the demodulation steps below where LPF() denotes removing the $2f_c$ frequency component with a low pass filter:

$ I = LPF(2 I_tcos(2\pi f_c t))$ $ Q = LPF(2 Q_tsin(2\pi f_c t))$

The Q component goes to zero on the I output since the result is in the $sin(\alpha)cos(\beta)$ form resulting in $sin(0) = 0$:

$ 0 = LPF(2 Q_tcos(2\pi f_c t))$

And similarly the I component goes to zero on the Q output:

$ 0 = LPF(2 I_tsin(2\pi f_c t))$

Therefore we can "multiplex" I and Q together given this ability to separate the two that operate simultaneously and independently in time.

Note I highly prefer to think and model using exponential frequency terms instead of sines and cosines - it is so much simpler! In fact this best explains implementations with I and Q paths as well, since to implement a complex signal you will need two real sequences $(e^{j\omega t} = cos(\omega t) + jsin(\omega t))$. Please see Frequency shifting of a quadrature mixed signal for more details on that.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.