Lab 5
Lab 5
EEE353
Lab Manual
RegistrationNumber FA14-BET-089
Class BET-7B
OBJECTIVES:
To assist the students in developing an understanding of Base band systems and awgn channel.
The students will be able to develop codes to study the behavior of signals in awgn channels and
to model baseband systems.
PRE-LAB:
The above block diagram represents a complete baseband system. The data generator and pulse
shaping filter combined, model the transmitted pulse train. The output of the data generator is a
train of impulses with different amplitudes corresponding to different data bits (e.g. 1 and -1 if a
polar scheme is utilized). The pulse shaping filter is designed i.e. the impulse response of the
filter matches the desired shape of the pulse i.e. rectangular, nyquist etc.
Channel Filter:
A baseband channel acts as a low pass filter of some bandwidth. The filtering smears the data
pulses in time and cause Inter Symbol Interference.
AWGN:
The combined effect of all noise sources (particularly thermal noise) is modeled as a zero mean
additive white Gaussian noise (AWGN).
Matched Filter:
Matched Filter is a special receiver filter which ensures maximum peak signal to noise ratio at
the sampling instant. If the impulse response of the pulse shaping filter (Transmit filter) is h(t)
then the impulse response of the matched filter would be kh(t-T) i.e. the impulse response of
transmit filter is inversed and shifted by time T to create a matched filter and ’k’ is any integer.
Use of matched filter makes the value of the sampled output independent of the pulse shape. The
sampled output only depends upon the energy contained in the pulse. If the received pulse is
perturbed by AWGN with PSD equal to No/2 then the output noise power is given by
Where E is the energy of the pulse. The output peak signal to noise ratio is given by
Correlation Receiver:
Correlation Receiver is another possible implementation of the matched filter. In this receiver the
incoming signal is correlated with the set of possible basis functions. The output is a vector in the
N-dimensional signal space. The presence of noise changes the location of received vector from
the set of possible transmission vectors. A decision is made by calculating the distance of the
received vector from all possible transmission vectors and the decision is made in favor of the
vector with least distance. The output noise power after correlation is equal to
.
Decision Device:
The filtered and sampled version is given as input to the decision device which on the basis of
maximum likelihood principle decides which symbol was transmitted. There is a positive
probability of error in the decision due to the presence of noise.
Theoretical BER:
The analysis of polar NRZ reveals that under AWGN using matched filter/correlation receiver,
the bit error rate (BER) is given as
LAB TASKS:
Task A:
1. Define a pulse width Tb and sampling time Ts, define an impulse (one followed by zeros)
of width Tb. Assume Eb/No = 0db
2. Define a random data of length say 1000bits and create an impulse train using the
impulse defined above and the data bits i.e. a ‘1’ corresponds to an impulse of magnitude
1 and a zero corresponds to an impulse of magnitude -1.
3. Define a Nyquist pulse and convolve the impulse train with the Nyquist pulse to generate
a pulse train Pass this Pulse Train through AWGN Channel.
4. Create a function which takes this pulse stream as input and convolves it with the
matched filter response and returns the output. (Remember to Normalize the output by
multiplying it with Ts. Why?) Sample the matched filter output data at intervals kTb.
Where k=1,2,3….length(data).
5. Add noise to the sampled output. Noise will be a Gaussian random variable with zero
6. Detect the resulting output using the optimum threshold. Find the bit error rate for both
polar and unipolar NRZ.
MATLAB CODE
Tb=1e-3;
Ts=1e-5;
EbN0=1;
sa_time=Tb/Ts;
Eb_lin=10^(EbN0/10);
A=sqrt(Eb_lin/Tb);
p=A*[ones(1,sa_time)];
f=-1;
datal=100;
d=randint(1,datal);
subplot(4,1,1)
plot(d)
title ('Original Signal')
x=[];
for k=1:datal
if (d(k)==0)
x=[x f*p];
else
x=[x p];
end
end
subplot(4,1,2)
plot(x)
title('Convolved with Pulse')
y=conv(p,x);
output=y*Ts;
time_axis=0:Ts:(Tb*datal)-Ts;
subplot(4,1,3)
plot(time_axis, output(1:length(time_axis)))
title('Matched Filter')
sample_output = output(sa_time:sa_time:end)
var=Eb_lin/2;
noise=sqrt(var)*randint(1,length(sample_output));
noisy_output=noise+sample_output;
subplot(4,1,4)
plot(noisy_output);
title('Noisy Output');
threshold=Eb_lin/2;
for k=1:length(noisy_output)
if (noisyoutput(k)>threshold)
f_out(k)=1
else
f_out(k)=0
end
end
error=length(find(d - f_out));
BER=error/datal;
RESULTS
It has been observed that the Error and BER of the result obtained from the matched
filter is ‘0’.
7. Repeat Task A but now with correlation receiver. Define the basis function φ(t).
8. Write a function which correlates (multiplies and integrates) your generated pulse stream
with φ(t). (How to implement integration using sampled data?)
9. Add noise to the output of the correlator. The noise will be a Gaussian distributed random
10. Detect the resulting output using the optimum threshold (Will it be same or different from
matched filter case?). Find the bit error rate for both polar and unipolar NRZ.
11. Figure out BER for different values of Eb/No ranging from 0-6dB and plot the output.
MATLAB CODE
Tb=0.001;
Ts=0.00005;
sa =Tb./Ts;
EbNo=1;
Eb=10^(EbNo/10);
A=sqrt(Eb/Tb);
pulse=A.*[ones(1,sa)];
factor=0;
data_l=100;
data=randint(1,data_l);
stream=[];
for k=1:data_l
if(data(k)==0)
stream=[stream factor*pulse];
else
stream=[stream pulse];
end
end
subplot(3,1,1)
plot(stream)
title('Original Signal')
st=1;
en=length(pulse);
for k=1:length(data)
Temp=stream(st:en);
corrstr=Temp.*pi;
corroutput(k)=sum(corrstr)*Ts;
startindex=en+1;
endindex=en+length(pulse);
end
output=conv(pulse,stream)*Ts;
time_axis=0:Ts:(Tb*data_l)-Ts;
subplot(3,1,2)
plot(time_axis,output(1:length(time_axis)))
title('convolution of pulse stream with matched filter')
sample_time=Tb/Ts;
sample_output=output(sample_time:sample_time:end);
var=Eb/2;
noise=sqrt(var)*randn(1,length(sample_output));
noi_out=noise+sample_output;
subplot(3,1,3)
plot (noi_out)
title('Noise Output')
threshold=Eb/2
for k=1:length(noi_out)
if noi_out(k)>threshold
final_output(k)=1;
else
final_output(k)=0;
end
end
errors=length(find(data-final_output))
ber=errors/data_l
RESULT
It has been observed that the result from the co-orelation filter has error is 27 and BER is
0.2700
CONCLUSION/CRITICAL ANALYSIS:
In this lab I have gained the knowledge of :
Baseband signals.
AWGN (Additive White Gaussian Noise).
Codes to study the behavior of signals in AWGN channels.
It has been observed from the results obtained that the Matched Filter is better than the
Co-Relation Filter.
Performance Viva
Total/15
(10 Marks) (5 Marks )
Performance /6
Results /3
Critical Analysis /1
Comments