0
$\begingroup$

Despite reading various answers on this site and on other sites I am still confused about how to convert a real-valued signal back down to its original IQ baseband values. Note I am still a beginner at this.

I have a very minimal prototype in Matlab but I'm getting stuck. I begin by generating some IQ data and modulating it onto a carrier signal, ready to be sent as a stream of real valued numbers.

% constants
f = 100; % carrier frequency
Fs=500; % sampling frequency
t=(1/Fs:1000)*T; % time domain

% generate 1000 raw I/Q values to *transmit*
I=randi([0 1],1000,1)';
Q=randi([0 1],1000,1)';

% modulate I/Q values onto a carrier wave
Iwave = I.*cos(2*pi*f*t);
Qwave = Q.*sin(2*pi*f*t);

I assume that adding the two waves together is correct (and not subtracting them like I've seen in some notations)

% add up I/Q. and transmit this stream of real-valued numbers
tx=Iwave+Qwave;

Now the receiver mixes the signals with cos and sin waves

rxI = tx .* (cos(2*pi*f*t));
rxQ = tx .* (sin(2*pi*f*t));

Below is an FFT of the received real-valued signal in black peaking at 100Hz. And the mixed I and Q signals on the receiver, peaking at 200Hz (I know the red peak is hard to see, but it's there at 200Hz).

Now comes the tricky part. Every resource I've read mentions I should low pass filter this I and Q, and I'll be able to get back my baseband data.

cutoff=200/Fs;
order=32;

% a 32 order low-pass FIR filter with cutoff at 200Hz
filter=fir1(order,cutoff);

filtI=filter(filter,1,rxI);
filtQ=filter(filter,1,rxQ);

Here's the FFT of the I and Q signals after low-pass filtering enter image description here Now the sent and received I channel as shown below obviously look nothing alike and simply cannot be demodulated. enter image description here

What am I doing wrong here? The ideal answer would specify exactly what filter I need to get back my baseband data in Matlab. This I think is reasonable since the example I provided is ideal and simple.

Please also correct any misunderstandings in this post aside from the obviously incorrect filter I am using.

$\endgroup$
  • $\begingroup$ Try with a less ugly signal as original. Randi is a really bad choice - take a pencil, sketch its spectrum. Shift that spectrum. Shift it back. Low-pass filter the result. Is it the same spectrum? Note that you need to bandlimit your signals to a bandwidth much smaller than the carrier frequency before mixing. $\endgroup$ – Marcus Müller Aug 15 '17 at 8:11
  • $\begingroup$ Can you provide a concrete example or refer me to a resource with a concrete example, and not just general advice/equations? A concrete example speaks a 1000 words. I ultimately want to transmit random bits. Presumably it is possible to transmit random bits. How would I make this work? $\endgroup$ – user2562609 Aug 15 '17 at 8:37
  • $\begingroup$ As I said, your baseband signal needs to be band-limited. Yours isn't. Change that. $\endgroup$ – Marcus Müller Aug 15 '17 at 11:20
  • $\begingroup$ The example you're looking for is really the drawing I asked you to make - when you make that drawing, you should see multiple ways of solving your problem. You must take care when drawing a discrete signal's spectrum - they are periodic! $\endgroup$ – Marcus Müller Aug 15 '17 at 11:22
  • $\begingroup$ As I said, I am a beginner, it would be much more illustrative if you could explain in greater detail or with code how to band-limit baseband signals, and what shift you're referring to exactly. I asked this question for an expert to sketch out an example, if I knew how to do that I would have done that already. $\endgroup$ – user2562609 Aug 15 '17 at 22:47
1
$\begingroup$

The allowed bandwidth of the data created and used to modulate the IQ signal needs to be below the cutoff frequency of the receiver post-heterodyne low pass filter, which needs to be below the carrier frequency, which needs to be below half the HF sampling rate to avoid aliasing.

So try a lower data rate and/or a much higher frequency carrier, with a suitably corresponding higher frequency sample rate. You can lower your data rate by using a slower changing rand statement, and filtering that to remove harmonics of the squarish pulses.

$\endgroup$
  • $\begingroup$ Baseband data (0,1 bits) does not have a frequency associated with it. Can you explain how I would generate an IQ signal of a particular bandwidth? Something in Matlab or something concrete is preferable. $\endgroup$ – user2562609 Aug 15 '17 at 22:45
  • $\begingroup$ If you send 1000 bits of data (your 0,1 bits array) in 2 seconds, your data rate or frequency is 500 bits per second. You seem to be sending too many bits spread over too short a time span for your given carrier frequency and filter cut-off. Try spreading out less bits over a longer time interval of modulation. Or use a higher carrier frequency. You might also want to first low-pass filter the waveform of your (0,1 bits) data. $\endgroup$ – hotpaw2 Aug 16 '17 at 20:22

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.