DSPRelated.com
Forums

BPSK Simulation problems

Started by apierce June 6, 2008
Hey everyone,

So I have a BPSK simulation running in MATLAB. I plot the constellation
and I get two perfect dots representing my bits. One located at 1 on the
x-axis and one located at -1 on the x-axis.

I modulate the signal by multiplying by a cosine. I then convert to
baseband by mixing with a complex exponential e^jwt. 

Now, when I low pass filter and replot the constellation...I get a mess. I
get globs of points around the 1 and -1 on the x-axis but I also get a
trail of dots that go from the 1 to the -1. 

Shouldn't I be getting perfect reconstruction of the constellation? Does
it have something to do with the filter I am using? (I tried using both
butter and fir1 from the signal processing toolbox and both gave me the
same weird result). 


>Now, when I low pass filter and replot the constellation...I get a mess.
I
>get globs of points around the 1 and -1 on the x-axis but I also get a >trail of dots that go from the 1 to the -1. > >Shouldn't I be getting perfect reconstruction of the constellation? Does >it have something to do with the filter I am using? (I tried using both >butter and fir1 from the signal processing toolbox and both gave me the >same weird result).
No, you shouldn't. By applying a low-pass filter you've introduced a mess of inter-symbol interference (ISI), which spreads your constellation. More than likely your filter is very tight (which means long), and the "trail of dots" is the beginning and end of the filter convolution with small values. Typically data is match filtered before transmission with a root-raised cosine filter. Then the same filter is applied at the receiver which provides an overall raised cosine response, and minimizes ISI (not counting problems from a channel other than AWGN). Mark

markt wrote:

> By applying a low-pass filter you've introduced a mess > of inter-symbol interference (ISI), which spreads your constellation. More > than likely your filter is very tight (which means long), and the "trail of > dots" is the beginning and end of the filter convolution with small > values.
For a simple binary modulation, one can get by pretty much any lowpass filter with the cutoff down to 0.5 of the baud rate. The performance degradation due to ISI can be neglected.
> Typically data is match filtered before transmission with a root-raised > cosine filter. Then the same filter is applied at the receiver which > provides an overall raised cosine response, and minimizes ISI (not counting > problems from a channel other than AWGN).
There is a whole area of PRML modulations made by lowpassing a signal by a filter and demodulation using ML or DFE. Generally, this approach works well until the cutoff is above ~0.2 of the baud rate. Vladimir Vassilevsky DSP and Mixed Signal Design Consultant http://www.abvolt.com
>For a simple binary modulation, one can get by pretty much any lowpass >filter with the cutoff down to 0.5 of the baud rate. The performance >degradation due to ISI can be neglected.
For BPSK, if the filter is wider than the bit rate, than there won't be a problem, but he's obviously using a filter that's too tight.
>There is a whole area of PRML modulations made by lowpassing a signal by
>a filter and demodulation using ML or DFE. Generally, this approach >works well until the cutoff is above ~0.2 of the baud rate.
Given the OP, he's not doing anything complex enough to require this. He's simply mixing and then doing a down-conversion (noise isn't mentioned?). A matched filter is optimal so complex demodulation techniques are unnecessary. Mark
You are correct. This is entirely simulation: no noise, nothing complex. I
simply convert to baseband by mixing with an exponential and then LPF the
data. When I plot the constellation I get a bunch of points all over the
place. Nothing near the input data...
>You are correct. This is entirely simulation: no noise, nothing complex.
I
>simply convert to baseband by mixing with an exponential and then LPF
the
>data. When I plot the constellation I get a bunch of points all over the >place. Nothing near the input data...
Not even around the original points? Are you oversampling the data? Is your detection centered in your eye (mid-point of your symbol) if so? Is this being done in MATLAB? If so, post your code... Mark
Here is my code..

the only function I use is "pskmod" and I have it commented in the code so
you can see what it does.


%configurable items
bits = 1E4; %number of bits to simulate
Rb = 1E6; %bit rate (bits/s)
Fs = 110E6; %sample rate (samples/s)
Fc = 21.4E6; %carrier frequency (Hz)
Fco = 3E6; %receiver carrier offset (Hz)
chip_rate = 11E6; %chips per second

barker = [1 -1 1 1 -1 1 1 1 -1 -1 -1]; %barker code

data = [ones(1,128) 0 0 0 0 0 1 1 0 1 1 1 0 0 0 1 1 1 0 0 0 1 0 1 0 0 1 1
1 1 1 1 1 0 0]; % bits to be sent
data(find(data == 0)) = -1;


% 3. Convert Data 2 Barker Chips
datai = [];
for i=1:1:length(data)
    if(data(i) == 1)
        stream = -1*barker;
    else
        stream = barker;
    end
    for l=1:1:length(stream)
        datai = [datai repmat(stream(l),1,Fs/chip_rate)];
    end
end
    

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%
%%%%            BPSK modulate the data
%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

y = pskmod(datai, 2, pi/4);
tt = 0:1/Fs:(length(y)-1)/Fs;
figure;
plot(y, '.'); % constellation plot
axis([-1.1 1.1 -1.1 1.1]);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%
%%%% Heres what my PSK modulation function looks like:
%%%%
%%%% function y = pskmod(x, M, phi)
%%%% x(find(x == -1)) = 0;
%%%% m = 0:M-1;
%%%% constellation = exp(j*2*pi*m/M+j*phi);
%%%% y = constellation(x+1);
%%%% end
%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%
%%%%            Carrier modulation
%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

y = y.*cos(2*pi*Fc*tt);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%
%%%%            Demodulation
%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% 1. Convert to Baseband

y = y.*exp(j*2*pi*Fc*tt);

% LPF
coef = fir1(100, 0.3);
xbb = filter(coef,1,xbb);

% derotate constellation
p = polyfit(real(xbb), imag(xbb),1)
xbb = xbb.*exp(-j*atan(p(1)));

% Plot Constellation - notice how the dots are everywhere no matter what
cutoff frequency is used in the filter
figure;
plot(xbb,'.')

oh and if you throw that into matlab all the "xbb" variables at the bottom
should be "y"....sorry about that
First of all, not many people are willing to debug pure code.
Second, you have aliasing all over the damn place.  You have
to oversample your symbols and you don't seem to have any
pulse shaping.  Take a step back and think about your simulation.
What is the simulation's sampling rate?  What should the
rates of the other parts?
>First of all, not many people are willing to debug pure code. >Second, you have aliasing all over the damn place. You have >to oversample your symbols and you don't seem to have any >pulse shaping. Take a step back and think about your simulation. >What is the simulation's sampling rate? What should the >rates of the other parts? >
I know people don't like to debug code, I am not trying to get people to write the simulation for me. I am trying to understand where and why the simulation is wrong. Thanks for your response, I will look into it.