Friday, September 4, 2009

2009 Communication systems assignment..

Question:
Universiti XXXXXXXX

Faculty of Engineering and Science


XXXXX Communication Systems
Assignment

In Lab 2, you are shown how to model a baseband binary NRZ coded communication system using Matlab. In this assignment you have to modify some of the functions given to you in Lab 2 in order to model a slightly different communication system. You are required to model a baseband binary communication system using Manchester coding, instead of NRZ coding. Again, sampling rate is 1000Hz and data rate is 100 bps.

i) The function nrz( ) has to be modified to produce the Manchester coded waveform. Use the short data string b = [1 0 0 1 1 1 0 1 0 1] and plot out the Manchester coded waveform. The Manchester coded waveform should range from -1V to +1V.
ii) Modify the low pass channel function lpchannel( ) so that it will have a bandwidth of 350 Hz. Send the signal through it and plot the output waveform.
iii) Modify the noise code so that it will produce added white Gaussian noise with single sided spectral density of N0 = 10mW/Hz. Add the noise generated to the signal and plot the resultant waveform
iv) Work out the voltage difference of the symbols s1 – s2 and put it into the correlator function corr( ). Plot the output of the correlator.
v) Produce a long string of data bits using the round( ) and rand( ) functions. Pass the data string through the low pass channel, add in white noise, estimate the transmitted data string using the correlator receiver, then measure the number of errors in order to produce the error probability. You are to do this for ratio of 1.0 to 4.0 at 0.5 intervals. You have to use as many data bits as is necessary in order to get a reliable Pe estimation. Plot out the Pe against the ratio.
vi) Work out the theoretical Pe for the different ratios and plot this curve on the same graph. Comment on any differences found.


Answer:

Name:xxx Course: 3E xxxx
ID: xxxxxxxx
Date of Submission: xxxxxxxxx


The Manchester coded waveform is ranged from -1V to +1V when b pass through mh function.

UEEA3523 Communication Systems

Output waveform of the signal rs go through low pass channel function with bandwidth of 350 Hz


Resultant waveform (rsn) that Gaussian noise with single-sided spectral density No = 10m W/Hz was added to the signal rs with the variance = 5 W/Hz (1: 10-3).


Voltage difference of the symbols with s1=1V, s2=-1V:
s1-s2 = +2V s2-s1 = -2V
Output waveform of rd


A long string of data bits b is used by using the round( ) and rand( ) functions
plot(d)


plot (rs)


plot(rsn)


plot(rd)


Manchester coded for b = [1 0 0 1 1 1 0 1 0 1] :

b = [1 0 0 1 1 1 0 1 0 1];
global fs fd
fs = 1000; %sampling rate is 1000Hz
fd = 100; % data rate is 100 bps
d = mh(b);
plot (d)
rs = lpchannel (d, 350);% bandwidth of 350 Hz
plot (rs)
noise = sqrt(5)*randn(1, 100);
rsn = rs + noise;
plot (rsn)
s1_s2 = [2 2 2 2 2 -2 -2 -2 -2 -2];
rd = corr(rsn, s1_s2);
plot (rd)
b=round(rand(1,1000));
d=mh(b);
plot(d)
rs=lpchannel(d,350);
plot(rs)
noise=sqrt(5)*randn(1,10000);
rsn=rs+noise;
plot(rsn)
s1_s2=[2 2 2 2 2 -2 -2 -2 -2 -2];
rd=corr(rsn,s1_s2);
plot(rd)
e=pe(b,rd)


x=[1 1.5 2 2.5 3 3.5 4];
y=[0.09 0.046 0.027 0.019 0.012 0.003 0.001];
z=[0.0786 0.0416 0.0228 0.0127 0.0072 0.0041 0.0023];

plot (x,y,'--');hold on;plot(x,z,' ');hold off
xlabel('Eb/No, dB');
ylabel('Pe');
title('Plot Pe against Eb/No');
legend('Measured' ,'Theoretical');












Measured Value for Pe:
Since the value of s1_s2 =[2 2 2 2 2 -2 -2 -2 -2 -2], so Eb is equal to
Tb . fs = 1 / (Tb) x 10 =1000

For Eb/No = 1.0
No = 0.01 / 1, noise = sqrt(5)*randn(1,10000);
>>b=round(rand(1,1000));
>>d=mh(b);
>>rs=lpchannel(d,350);
>>noise=sqrt(5)*randn(1,10000);
>>rsn=rs+noise;
>>rd=corr(rsn,s1_s2);
>>e=pe(b,rd)
>>e=0.090

For Eb/No = 1.5
No = 0.01 / 1.5 , noise = sqrt(3.33)*randn(1,10000);
>>b=round(rand(1,1000));
>>d=mh(b);
>>rs=lpchannel(d,350);
>>noise=sqrt(3.33)*randn(1,10000);
>>rsn=rs+noise;
>>rd=corr(rsn,s1_s2);
>>e=pe(b,rd)
>>e=0.046

For Eb/No = 2.0
No = 0.01 / 2 , noise = sqrt(2.5)*randn(1,10000);
>>b=round(rand(1,1000));
>>d=mh(b);
>>rs=lpchannel(d,350);
>>noise=sqrt(2.5)*randn(1,10000);
>>rsn=rs+noise;
>>rd=corr(rsn,s1_s2);
>>e=pe(b,rd)
>>e=0.027

For Eb/No = 2.5
No = 0.01 / 2.5, noise = sqrt(2)*randn(1,10000);
>>b=round(rand(1,1000));
>>d=mh(b);
>>rs=lpchannel(d,350);
>>noise=sqrt(2)*randn(1,10000);
>>rsn=rs+noise;
>>rd=corr(rsn,s1_s2);
>>e=pe(b,rd)
>>e=0.019


For Eb/No = 3.0
No =0.01 / 3, noise = sqrt(1.67)*randn(1,10000);
>>b=round(rand(1,1000));
>>d=mh(b);
>>rs=lpchannel(d,350);
>>noise=sqrt(1.67)*randn(1,10000);
>>rsn=rs+noise;
>>rd=corr(rsn,s1_s2);
>>e=pe(b,rd)
>>e=0.012

For Eb/No = 3.5
No =0.01 / 3.5, noise = sqrt(1.43)*randn(1,10000);
>>b=round(rand(1,1000));
>>d=mh(b);
>>rs=lpchannel(d,350);
>>noise=sqrt(1.43)*randn(1,10000);
>>rsn=rs+noise;
>>rd=corr(rsn,s1_s2);
>>e=pe(b,rd)
>>e=0.003

For Eb/No = 4.0
No =0.01 / 4, noise = sqrt(1.25)*randn(1,10000);
>>b=round(rand(1,1000));
>>d=mh(b);
>>rs=lpchannel(d,350);
>>noise=sqrt(1.25)*randn(1,10000);
>>rsn=rs+noise;
>>rd=corr(rsn,s1_s2);
>>e=pe(b,rd)
>>e=0.001

Theoretical Value of Pe

Pe = Q ( )

For Eb/No = 1.0
>> z = Q(sqrt(2))
z =0.0786
For Eb/No = 1.5
>> z = Q(sqrt(4))
z = 0.0416
For Eb/No = 2.0
>> z = Q(sqrt(4))
z = 0.0228
For Eb/No = 2.5
>> z = Q(sqrt(5))
z =0.0127
For Eb/No = 3.0
>> z = Q(sqrt(6))
z = 0.0072
For Eb/No = 3.5
>> z = Q(sqrt(7))
z =0.0041
For Eb/No = 4.0
>> z = Q(sqrt(8))
z =0.0023



Table for Pe(measured) and Pe(Theoretical):
ratio| Pe(measured)| Pe(Theoretical)
1.0 |0.090 | 0.0786
1.5 |0.046 | 0.0416
2.0 |0.027 | 0.0228
2.5 |0.019 | 0.0127
3.0 |0.012 | 0.0072
3.5 |0.003 | 0.0041
4.0 |0.001 | 0.0023




Comments:
The experimental approach indicates that the bit error rate depend on the ratio of interference to desired signal power for the weak interference, irrespective of different interference conditions. The theoretical approach proposes the estimation of bit error rate based on the amplitude probability density function of interference signal components. The difference between theoretical and experimental of probability error is not so much and this is maybe cause by the noise that generated by random bits of data and differences computer will generated difference bits of data.


Appendix:
function [d] = mh(b)
% mh modulation of binary data string b
% Requires global fd: data rate fd, and fs: sampling rate

global fs fd;
d=[];
for k = 1 : length(b)
if (b(k)==1)
d = [d ones(1, fs./(2*fd))];
d = [d -ones(1, fs./(2*fd))];
else
d = [d -ones(1, fs./(2*fd))];
d = [d ones(1, fs./(2*fd))];
end
end

function [op] = lpchannel(s,bw)
% low pass channel with gain 1.0 and bandwidth bw
% input signal is s, requires global fs, fd

global fs fd;
datapts = length(s);
res = fs/datapts;
passband = bw/res;
response = [ones(1,passband), zeros(1,datapts-2.*passband), ones(1,passband)];
ipspec = fft(s);
opspec = ipspec.*response;
op = real(ifft(opspec));

function [rd] = corr(rs, s1_s2)
% correlator receiver matched to s1 - s2
% received waveform is rs

rd = [];
bitlength = length(s1_s2);
for k = 1 : length(rs)/bitlength
store = 0;
for l = 1 : bitlength
op = rs((k-1)*bitlength+l)*s1_s2(l);
store = store + op;
end
if (store>0)
rd = [rd 1];
else
rd = [rd 0];
end
end



function [e] = pe(sd, rd)
% compare sent and received data and calculate Pe]
% sent data is sd, received data is rd

datalength = length(sd);
biterror = 0;
for k = 1:datalength
if (sd(k)~=rd(k))
biterror = biterror + 1;
end
end
e = biterror/datalength;

function r=Q(x)
% Obtaining value of Q function using the built-in erfc function

r = 0.5*erfc(x/sqrt(2));

No comments:

Post a Comment