shubhs9
Newbie level 4
hi.
I have written a code which emulates a qpsk tx n rx system. it works perfectly and i'm getting the BER curve exactly.
As my next task i have been asked to design an fir low pass filter through which i am to pass the qpsk signal. i'm not getting much assistance from the guide and i'm pretty much on my own. I would really appreciate it if someone could help me out.
thanks.
-shubro
the code for qpsk:
nr_data_bits=100000; %number of bits to be generated
b_data = (randint(1, nr_data_bits)); %random 1's and 0's
b = (b_data);
s = length(b); %length of sequence
d=zeros(1,length(b)/2); %initializing a variable with all zeros
for n=1:length(b)/2
imp=b(2*n-1); %selecting one bit
p=b(2*n); %selecting consequent bit
if (imp==0)&&(p==0)
d=exp(j*pi/4); %45 degrees
end
if (imp==1)&&(p==0)
d=exp(j*3*pi/4); %135 degrees
end
if (imp==1)&&(p==1)
d=exp(j*5*pi/4); %225 degrees
end
if (imp==0)&&(p==1)
d=exp(j*7*pi/4); %315 degrees
end
end
qpsk=d;
figure(1);
plot(d,'o'); %plot constellation without noise
axis([-2 2 -2 2]);
grid on;
xlabel('real'); ylabel('imag');
hold on;
SNR=0:10;
de1=[];
de=[];
BER1=[];
SNR1=[];
for SNR=0:length(SNR);
de1 = [];
sigma = sqrt(10.0^(-SNR/10.0)); %No/Eb = sqrt(antilog(snr/10))
sigma = sigma/2; %noise spectral density = No/2
corrupt = sigma.*(randn(1,length(b)/2)+j*randn(1,length(b)/2));
r = qpsk + corrupt;
for n=1:length(b)/2
g=r;
imp=b(2*n-1);
p=b(2*n);
if (real(g) > 0)
if (imag(g) > 0)
de = [0 0];
end
end
if (real(g) < 0)
if (imag(g) > 0)
de = [1 0];
end
end
if (real(g) > 0)
if (imag(g) < 0)
de = [0 1];
end
end
if (real(g) < 0)
if (imag(g) < 0)
de = [1 1];
end
end
de1=[de1 de];
end
ne=sum(b~=de1)
BER=ne/nr_data_bits;
BER1=[BER1 BER]
SNR1=[SNR1 SNR]
end
figure(1);
plot(r,'x'); %plot constellation with noise
axis([-2 2 -2 2]);
grid on;
xlabel('real'); ylabel('imag');
figure(2);
semilogy(SNR1,BER1,'o');
grid on;
xlabel('SNR'); ylabel('BER');
I have written a code which emulates a qpsk tx n rx system. it works perfectly and i'm getting the BER curve exactly.
As my next task i have been asked to design an fir low pass filter through which i am to pass the qpsk signal. i'm not getting much assistance from the guide and i'm pretty much on my own. I would really appreciate it if someone could help me out.
thanks.
-shubro
the code for qpsk:
nr_data_bits=100000; %number of bits to be generated
b_data = (randint(1, nr_data_bits)); %random 1's and 0's
b = (b_data);
s = length(b); %length of sequence
d=zeros(1,length(b)/2); %initializing a variable with all zeros
for n=1:length(b)/2
imp=b(2*n-1); %selecting one bit
p=b(2*n); %selecting consequent bit
if (imp==0)&&(p==0)
d=exp(j*pi/4); %45 degrees
end
if (imp==1)&&(p==0)
d=exp(j*3*pi/4); %135 degrees
end
if (imp==1)&&(p==1)
d=exp(j*5*pi/4); %225 degrees
end
if (imp==0)&&(p==1)
d=exp(j*7*pi/4); %315 degrees
end
end
qpsk=d;
figure(1);
plot(d,'o'); %plot constellation without noise
axis([-2 2 -2 2]);
grid on;
xlabel('real'); ylabel('imag');
hold on;
SNR=0:10;
de1=[];
de=[];
BER1=[];
SNR1=[];
for SNR=0:length(SNR);
de1 = [];
sigma = sqrt(10.0^(-SNR/10.0)); %No/Eb = sqrt(antilog(snr/10))
sigma = sigma/2; %noise spectral density = No/2
corrupt = sigma.*(randn(1,length(b)/2)+j*randn(1,length(b)/2));
r = qpsk + corrupt;
for n=1:length(b)/2
g=r;
imp=b(2*n-1);
p=b(2*n);
if (real(g) > 0)
if (imag(g) > 0)
de = [0 0];
end
end
if (real(g) < 0)
if (imag(g) > 0)
de = [1 0];
end
end
if (real(g) > 0)
if (imag(g) < 0)
de = [0 1];
end
end
if (real(g) < 0)
if (imag(g) < 0)
de = [1 1];
end
end
de1=[de1 de];
end
ne=sum(b~=de1)
BER=ne/nr_data_bits;
BER1=[BER1 BER]
SNR1=[SNR1 SNR]
end
figure(1);
plot(r,'x'); %plot constellation with noise
axis([-2 2 -2 2]);
grid on;
xlabel('real'); ylabel('imag');
figure(2);
semilogy(SNR1,BER1,'o');
grid on;
xlabel('SNR'); ylabel('BER');