Correctedreport EXP 3
Correctedreport EXP 3
Correctedreport EXP 3
REPORT
Experiment 3
Objectives
Simulate a digital communication system that uses coherent BPSK with antipodal signaling and BCH code in the presence of Rayleigh fading channel and
white noise and plot BER curves.
Implementation of BPSK modulation with Error Control Coding
Synthesizing a frequency flat Rayleigh fading channel and plot its PDF.
Understanding the BER performance of uncoded digital modulation scheme
in the presence of Rayleigh fading channel and AWGN channel
Implementation of (15,7,5) BCH encoding.
Analysis of BER performance of the modulation scheme with BCH code
in the presence of Rayleigh Fading Channel
Plotting of Ideal and Practical BER curves
1
Find the Eb/N 0 required for achieving a BER performance of 103 in all
comparisons
Theory
2.1
(1)
(2)
(3)
z z22
e 2 , z 0
2
(4)
) = erf c( )
(5)
Pb = erf c(
2
N0
2
In the presence of the Rayleigh Fading Channel, the effective bit energy to
2
b
. Hence, to find the bit error probability is determined
noise ratio is |hN|E
0
by evaluating the conditional probability density function Pb|h over the
probability density function of :
Z
1
Pb =
erf c( )p()d
(6)
2
0
This can be reduced to yield the following result:
v
u Eb
u
1
Pb = (1 t EbN0 )
2
N0 + 1
2.2
(7)
Error detection and correction or error control are techniques that enable
reliable delivery of digital data over unreliable communication channels.
A code is a mapping that takes a sequence of information symbols and produces a (larger) sequence of code symbols so as to be able to detect/correct
errors in the transmission of the symbols.
The simplest class of codes is the class of binary linear block codes. Here
each vector of k information bits xi = [xi,1 ... xi,k ] is mapped to vector of
n code bits ci = [ci,1 ... xi,n ], with n >k.
2.3
BCH Code
The BCH codes form a class of cyclic error-correcting codes that are constructed using finite fields.
There is a precise control over the number of symbol errors correctable by
the code. In particular, it is possible to design binary BCH codes that can
correct multiple bit errors.
They are easy to decode, using the algebraic Syndrome method.For any
positive integers m >= 3 and t < 2m1 , there exists a binary code with
block length n = 2m 1, number of parity-check digits n k <= mt with
a minimum distance dmin >= 2t + 1, called the t-error correcting BCH
codes. The generator polynomial of this code is specified in terms of its
roots from the Galois field GF (2m ).
Implementation
3.1
(8)
received symbol
complex scaling factor corresponding to Rayleigh fading channel
transmitted symbol
Additive White Gaussian Noise (AWGN)
In this experiment, we have assumed that the Rayleigh fading channel has
only two multipath components, X(t) and Y(t).
Rayleigh fading can be obtained from zero - mean complex Gaussian processes (X(t) and Y(t)).
In order to get the Rayleigh fading channel envelope, we add the two Gaussian random variables and take its absolute value (equivalent to squaring
and adding the two random variables and then taking its square root).
This gives a Rayleigh distributed process. The phase follows uniform distribution.
3.2
BCH Code
The entries of H are elements from GF (2m ). Each element in GF (2m ) can
be represented by a m-tuple over GF (2). Then we get the binary parity
check matrix for the code. Therefore H for our above problem is :
BCH decoding
For a t error correcting BCH code, the syndrome is a 2t-tuple, S =
(S1 , S2 , ..., S2t ) = rH T , where r is the received code vector.
The ith component of the syndrome is Si = r(i ).
The decoding procedure for 2-error correcting code is as follows:
Compute S1 and S3 .
If S1 = 0 and S3 = 0 , then assume no error.
If S1 6= 0 and S3 = S13 , then assume 1 error. Error location is i1
satisfying X1 = i1 .
MATLAB Code
clear all;ctr=0;
n=15; k=7; t=2;
N=k*1000;
ebyn0db = 0 : 2 : 20;
ebyn0 = 10.^(ebyn0db/10);
ip=rand(1,N)>0.5;
si=2*ip-1;
g=[1 0 0 0 1 0 1 1 1 0 0 0 0 0 0];
gen=[];
for i=0:k-1
gg= circshift(g,i);
gen=[gen gg];
end
gen=gen;
a=0:15;
b=gf(a,4);
alpha=b(3);
A=[];
for i= 0: 15
aa= alpha^i;
A=[A aa];
end
s=reshape(ip,N/k,k);
coded = mod(s*gen,2);
code = reshape(coded,1,(N/k)*n);
BER = zeros(1,length(ebyn0db));
nn = randn(1,N) + 1i*randn(1,N);
nn1 = randn(N/k,n) + 1i*randn(N/k,n);
for ii=1: length(ebyn0db)
rxd1 = si + 10^(-ebyn0db(ii)/20)*nn;
rxd = real(rxd1)>0;
coded_n = (2*coded-1) + 10^(-ebyn0db(ii)/20)*nn1;
coded_n = real(coded_n) >0;
rcv=[];
for i=1:N/k
pos=find(coded_n(i,:));
for m=1:length(pos);
if m==1
s1= A(pos(m));s3= A(pos(m))^3;
else
s1=s1+A(pos(m));s3=s3+(A(pos(m)))^3;
end
end
s1d=double(s1.x);
s11=de2bi(s1d,2*t);
s3d=double(s3.x);
if (s1==b(1)) && (s3==b(1))
rcv=[rcv coded_n(i,:)];
elseif (s1 ~= b(1)) && (s3 == s1^3)
e=s11;
im = find(A(1:15) == s1);
rr=xor(coded_n(i,:),[zeros(1,im-1) 1 zeros(1,n-im)]);
rcv=[rcv rr];
elseif (s1 ~= b(1)) && (s3 ~= s1^3)
pr=(s3+s1^3)/s1;
er=[];
for f=1:length(b)
if (b(f))^2 + s1*b(f) + pr == b(1)
er = [er b(f)];
end
end
if isempty(er)
rcv=[rcv coded_n(i,:)]; ctr=ctr+1;
else
e1 = find(A(1:15) == er(1));e2 = find(A(1:15) == er(2));
if(e1>e2)
xx= [zeros(1,e2-1) 1 zeros(1,e1-1-e2) 1 zeros(1,n-e1)];
elseif(e1<e2)
xx= [zeros(1,e1-1) 1 zeros(1,e2-1-e1) 1 zeros(1,n-e2)];
else
xx= [zeros(1,e1-1) 1 zeros(1,n-e1-1)];
end
rr= xor(coded_n(i,:),xx);
rcv=[rcv rr];
end
else
rcv=[rcv coded_n(i,:)];
end
end
rcv=reshape(rcv, n, N/k);
y= length(find(xor(rcv,coded)));
BER(ii)= y/(n*(N/k));
7
y1= length(find(xor(rxd,ip)));
thber(ii) = y1/N;
end
%thber = 0.5*erfc(sqrt(10.^(ebyn0db/10)));
%Rayleigh channel
variance=0.2;
X = randn(1, N)+1i*randn(1,N);
Y = randn(1, N)+1i*randn(1,N);
R = sqrt(variance*(real(X).^2 + real(Y).^2));
range = 0:0.1:3;
%Get histogram values and approximate it to get the pdf curve
h = hist(R, range);
approxPDF = h/(0.1*sum(h)); %Simulated PDF from the x and y samples
%Theoritical PDF from the Rayleigh Fading equation
theoretical = (range/variance).*exp(-range.^2/(2*variance));
figure;
plot(range, approxPDF,b*, range, theoretical,r);
title(Simulated and Theoretical Rayleigh PDF for variance = 0.5)
legend(Simulated PDF,Theoretical PDF)
xlabel(r);
ylabel(P(r));
grid;
BERr=[]; BERu=[];
nn = randn(N/k,n) + 1i*randn(N/k,n);
hn = randn(N/k,n) + 1i*randn(N/k,n);
for ii=1:length(ebyn0db)
rxd1 = Y.*si + 10^(-ebyn0db(ii)/20)*X;
rxd11 = rxd1./Y;
rxd = real(rxd11)>0;
coded_nr1 = hn.*(2*coded-1) + 10^(-ebyn0db(ii)/20)*nn;
coded_nr11 = coded_nr1./hn;
coded_nr = real(coded_nr11) >0;
rcv=[];
for i=1:N/k
pos=find(coded_nr(i,:));
for m=1:length(pos);
if m==1
s1= A(pos(m));s3= A(pos(m))^3;
else
s1=s1+A(pos(m));s3=s3+(A(pos(m)))^3;
end
end
8
s1d=double(s1.x);
s11=de2bi(s1d,2*t);
s3d=double(s3.x);
if (s1==b(1)) && (s3==b(1))
rcv=[rcv coded_n(i,:)];
elseif (s1 ~= b(1)) && (s3 == s1^3)
e=s11;
im = find(A(1:15) == s1);
rr=xor(coded_nr(i,:),[zeros(1,im-1) 1 zeros(1,n-im)]);
rcv=[rcv rr];
elseif (s1 ~= b(1)) && (s3 ~= s1^3)
pr=(s3+s1^3)/s1;
er=[];
for f=1:length(b)
if (b(f))^2 + s1*b(f) + pr == b(1)
er = [er b(f)];
end
end
if isempty(er)
rcv=[rcv coded_nr(i,:)];ctr=ctr+1;
else
e1 = find(A(1:15) == er(1));e2 = find(A(1:15) == er(2));
if(e1>e2)
xx= [zeros(1,e2-1) 1 zeros(1,e1-1-e2) 1 zeros(1,n-e1)];
elseif(e1<e2)
xx= [zeros(1,e1-1) 1 zeros(1,e2-1-e1) 1 zeros(1,n-e2)];
else
xx= [zeros(1,e1-1) 1 zeros(1,n-e1-1)];
end
rr= xor(coded_nr(i,:),xx);
rcv=[rcv rr];
end
else
rcv=[rcv coded_nr(i,:)];
end
end
rcv=reshape(rcv, n, N/k);
y= length(find(xor(rcv,coded)));
BERr(ii)= y/(n*(N/k));
y1= length(find(xor(rxd,ip)));
BERu(ii) = y1/N;
end
thray = 0.5.*(1-sqrt(ebyn0./(ebyn0+1)));
figure;
semilogy(ebyn0db,BER,md-,Linewidth,3);hold on;
semilogy(ebyn0db,thber,b.-,Linewidth,3);hold on;
9
semilogy(ebyn0db,BERr,rs-,Linewidth,3);hold on;
semilogy(ebyn0db,BERu,go-,Linewidth,3);hold on;
semilogy(ebyn0db,thray,b.-,Linewidth,3);grid on;
axis([0 20 10^-5 0.5]);
title(BER of BPSK with BCH coding in Rayleigh channel); legend( BCH CODED-AWGN,THEORETI
ylabel(BER);
MATLAB Simulation
The BER plots of BPSK modulation scheme- theoretical and practical scenarios
with and without BCH error coding and Rayleigh fading channel were obtained
10
as follows:
Results
BPSK modulation scheme was implemented in the presence of AWGN
noise and Rayleigh fading channel
BCH code was implemented for error detection and correction of the BPSK
modulated signal.
BER plots for ideal and practical scenarios were obtained for BPSK modulation scheme, BPSK modulation in the presence of Rayleigh fading channel, and also when implementing error detection and correction using BCH
code.
The performance of the various schemes were analyzed.
The required SNR for BER of 103 was obtained as follows:
11
References
[1] Simon Haykin, Communication Systems, John Wiley & Sons, Inc., 4th Edition
[2] Ken Gentile, The care and feeding of digital, pulse-shaping filters
[3] Wikipedia, the Free Encyclopedia
http://en.wikipedia.org/wiki/
[4] Gaussian Waves
http://www.gaussianwaves.com/
12