matlab – LPF implementation for demodulation of a BPSK signal
I am currently trying to filter my BPSK demodulated signal to cut the extra two frequencies(left and right) and to estimate the BER, but i am stuck on the filtering part. I have errors in decision and estimation block, because I think i implemented a wrong filter.
First, i modulate the signal with a cosinus carrier and then i demodulate the signal by multiplying the modulated signal with the cosinus carrier. Then, it comes the part when the LPF is needed and I don’t know exactly how to implement this.
clear; close all; clc;
beta = 0.35; %Factor roll-off
span = 6; %
sps = 4; % Number of samples/symbol
% ordin filtru = span*sps = 24;
h = rcosdesign(beta,span,sps,'normal'); % RRC filter
up = 256; % oversample rate
bits = 200; %Number of bits
input = 1 - 2 * randi([0,1], 1, bits); % Binary sequence to NRZ
figure(1), stairs(input), ylim([-1.2 1.2]),
title('Input sequence'),
xlabel('No'),
ylabel('Amplitude');
input_filtered = upfirdn(input,h,up); % Oversampling and filtering RRC
[S1,w1]=pwelch(input_filtered,[],[],[],[],'twosided'); % PSD
figure(2)
plot(w1-0.5,10*log10(fftshift(S1)));
title('PSD in BB'),
xlabel('Normalized Freq');
w0 = 0.3; % Normalized freq
t = 0:length(input_filtered)-1;
purt = cos(2*pi*w0*t);
sgn_modulat=input_filtered.*purt;
[S2,w2]=pwelch(sgn_modulat,[],[],[],[],'twosided'); % PSD
figure(3)
plot(w2-0.5,10*log10(fftshift(S2)));
title('PSD of modulated signal'),
xlabel('Normalized freq');
sgn_demodulat = sgn_modulat.*purt;
[S3,w3]=pwelch(sgn_demodulat,[],[],[],[],'twosided'); % PSD
figure(4)
plot(w3-0.5,10*log10(fftshift(S3)));
title('PSDof demodulated signal'),
xlabel('Normalized freq');
% LPF
lung=120;
n=lung-1;
ft=0.48;
f=[0 ft ft 1];
m=[1 1 0 0];
h=fir2(n,f,m,hanning(lung));
Nfft=4096;
fn=-0.5:1/Nfft:0.5-1/Nfft;
H=fft(h,Nfft);
sgn_demodulat_filtrat = filter(h,1,sgn_demodulat);
[S4,w4]=pwelch(sgn_demodulat_filtrat,[],[],[],[],'twosided'); % PSD
figure(5)
plot(w4-0.5,10*log10(fftshift(S4)));
title('PSD of filtered demodulated signal'),
xlabel('Normalized freq');
output_filtered = decimate(sgn_demodulat_filtrat,256);
biti_neg = output_filtered < 0;
biti_poz = output_filtered > 0;
output_filtered(biti_neg) = -1;
output_filtered(biti_poz) = 1;
figure(6), stairs(output_filtered), ylim([-1.2 1.2]),
title('Estimated output'),
xlabel('No'),
ylabel('Amplitude');
Read more here: Source link
