Need assistance in demodulation

Discussions related to embedded firmware, driver, and user mode application software development
Post Reply
Michael
Posts: 4
Joined: Tue Dec 02, 2014 11:05 am

Need assistance in demodulation

Post by Michael »

Hi everybody,
I use one bladeRF for transmitting a signal and another one for receiving.

I want to transmit a bit stream in DBPSK modulation.

The transmission Matlab-code is following:

Code: Select all

Preamble = (PLCP_Preamble()' + 1) ./ 2;
for i = 1 : 15
    Preamble = [Preamble; Preamble];
end
 
freq = 868.9e6;
 
bladerf_find_devices
handle = bladerf_dev(device);
bw = 100; %Hz
bitSpeed = 100; %bps
samplerate = 200e3;
gain = 0;
 
hModulator = comm.DBPSKModulator(0);
modData = step(hModulator, data);
 
modData(1) = complex(1, 0); %If real part of modData is negative, for some reason bladeRF rejects a transmission.
 
res = bladerf_dev(handle, 'TX', samplerate, bw, freq, gain, modData);
PLCP_Preamble is following:

Code: Select all

function Preamble = PLCP_Preamble()
    SFD = de2bi(hex2dec('F3A0'));
    SFD = SFD .* 2 - 1;
    a   = [1,  1,  1,  1,  1,  1, -1, -1,  1, -1,  1, -1,  1, -1, -1,  1];
    sync = [a,  a,  a, -a, -a,  a, -a, -a]; 
    Preamble = [sync, SFD];
end
Receiving code is following:

Code: Select all

sendFreq = 868.9e6;


begFreq = 868.7e6;
endFreq = 869.2e6;


handle = bladerf_dev(0);
dFreq = endFreq - begFreq;
freq = (begFreq + endFreq)/2;
sr = 0.75e6;
bw = dFreq;

rcvData = bladerf_dev(handle, 'RX', sr, bw, freq, 10, sr*3);
bladerf_dev(handle);

%Filter out DC and show the spectrum
hDC2 = dsp.DCBlocker('Algorithm','FIR','Length', 100);
y0 = step(hDC2, rcvData);
hpsd0 = psd(hp,y0,hpopts);
figure;
plot(hpsd0);
ylabel('y0', 'FontSize', 14);

%Shift sent signal to center
df = (begFreq + endFreq)/2 - sendFreq;
iExp = 1 : length(y0);
shiftSig = exp(-1i*2*pi*df*iExp/sr)';
y1 = y0 .* shiftSig;
hpsd1 = psd(hp,y1,hpopts);
figure;
plot(hpsd1);
title('y1');

%Filter out others using lowpass filter
lpOrder = 150;
Fp = 5e3/sr;
Fst = Fp*4;
Ap = 0.06;
Ast = 60;
lpfd = fdesign.lowpass('Fp,Fst,Ap,Ast',Fp,Fst,Ap,Ast);
lpf = design(lpfd,'equiripple');
y2 = filter(lpf, y1);
hpsd2 = psd(hp,y2,hpopts);
figure 
plot(hpsd2);
title('y2');
scatterplot(y2);

%Remove linear trend
yy1 = y2(250:length(y2));
phases = atan2(imag(yy1), real(yy1));
linp = unwrap(phases);
figure; plot(linp);
dtp = detrend(linp);
figure; plot(dtp);
ampl = abs(yy1);
yy2 = complex(ampl .* cos(dtp), ampl .* sin(dtp));
figure; scatterplot(yy2);
I expect that constellation of yy2 is BPSK, but it is looking like a noised dot:

Image

What I'm doing wrong? How can I verify that I transmit what I want?
Post Reply