0% found this document useful (0 votes)
62 views15 pages

DCS Lab 3

This document describes an experiment on different types of line coding. The experiment generates baseband signals for different line codes including unipolar, bipolar, polar, and Manchester encoding. It then transmits the signals over an additive white Gaussian noise channel. The effect of channel noise on the reconstructed signals is analyzed by measuring the bit error rate. The line codes are implemented and tested in both non-return-to-zero and return-to-zero formats. The results show the bit error rate for each line code when transmitted over the noisy channel.

Uploaded by

harshith
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
62 views15 pages

DCS Lab 3

This document describes an experiment on different types of line coding. The experiment generates baseband signals for different line codes including unipolar, bipolar, polar, and Manchester encoding. It then transmits the signals over an additive white Gaussian noise channel. The effect of channel noise on the reconstructed signals is analyzed by measuring the bit error rate. The line codes are implemented and tested in both non-return-to-zero and return-to-zero formats. The results show the bit error rate for each line code when transmitted over the noisy channel.

Uploaded by

harshith
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

ECE4001 – Digital Communication Systems

Lab Task – 3

Name: Harshith C S

Reg No: 18BEC0585

Slot: L35+L36
Title: Pulse Code Modulation and Delta Modulation
Task No: 3

Date: 03/08/2020

Aim: To generate the baseband signal for the given text message. Also, transmit the generated base
band signal through AWGN channel.
Analyze the effect of channel noise on the reconstructed signal.
1. Unipolar
2. Polar
3. Bipolar
4. Manchester

Theory:

Line coding is the process of converting digital data to digital signals. By this technique we
convert a sequence of bits to a digital signal. At the sender side digital data are encoded into a
digital signal and at the receiver side the digital data are recreated by decoding the digital
signal.
There are two types of signals. One is non-return-to-zero (NRZ) line code is a binary code in
which ones are represented by one significant condition, usually a positive voltage, while
zeros are represented by some other significant condition, usually a negative voltage, with no
other neutral or rest condition.
The other is return-to-zero (RZ or RTZ) describes a line code used in telecommunications
signals in which the signal drops (returns) to zero between each pulse. This takes place even
if a number of consecutive 0s or 1s occur in the signal. This type of signal is self-clocking.
There are several types of line codes:
1. Unipolar Encoding – A for high voltage, 0 for low voltage
2. Polar Encoding – A for high voltage, -A for low voltage
3. Bipolar Encoding – alternates between A and -A for high voltage, 0 for low voltage
4. Manchester Encoding – A for first half time period of high and -A for other half, -A
for first half time period of low voltage and A for other half.
Programme:

Unipolar NRZ

clear all;
close all;
clc;
% Effect of noise on the transmitted
% transmitted bits
n=[1,1,0,1,0];
A=5;
f=0;
% mapping bits to levels
for ii=1:length(n);
if n(ii)==0;
nn(ii)=0;
else
nn(ii)=A;
end
end
% Pulse shaping
i=1;
t=0:0.01:length(n);
for j=1:length(t);
if t(j)<=i;
y(j)=nn(i);
else
y(j)=nn(i);
i=i+1;
end
end
% plotting
subplot(211);
plot(t,y);
axis([0 length(n) -A+1 A+1]);
% AWGN channel
SNR=-2; % in dB
r=awgn(y,SNR);
subplot(212);
plot(t,r);
% smapling
% sampling instants
Tb=1;
T=(Tb/2)/0.01;
s=r(T+1:(Tb/0.01):length(t));
% detection
% threshold
Th=(-A+A)/2;
% Hard decision decoding
for ii=1:length(s);
if s(ii)>=Th;
det(ii)=1;
else
det(ii)=0;
end
end
% bit error rate analysis
[noe ber]=biterr(n,det);
disp('Number of Errors');
noe
disp('Bit error rate');
ber

Unipolar RZ

clear all;
close all;
clc;
% Effect of noise on the transmitted
n=[1,1,0,1,0];
A=5;
f=0;
% mapping bits to levels
for ii=1:length(n);
if n(ii)==0;
nn(ii)=0;
else
nn(ii)=A;
end
end
% Pulse shaping
i=1;
a=0;
b=0.5;
t=0:0.01:length(n);
for j=1:length(t)
if t(j)>=a &&t(j)<=b
y(j)=nn(i);
elseif t(j)>b && t(j)<=i
y(j)=0;
else
i=i+1;
a=a+1;
b=b+1;
end
end
% plotting
subplot(211);
plot(t,y);
axis([0 length(n) -A+1 A+1]);
% AWGN channel
SNR=-2; % in dB
r=awgn(y,SNR);
subplot(212);
plot(t,r);
% smapling
% sampling instants
Tb=1;
T=(Tb/2)/0.01;
s=r(T+1:(Tb/0.01):length(t));
% detection
% threshold
Th=(-A+A)/2;
% Hard decision decoding
for ii=1:length(s);
if s(ii)>=Th;
det(ii)=1;
else
det(ii)=0;
end
end
% bit error rate analysis
[noe ber]=biterr(n,det);
disp('Number of Errors');
noe
disp('Bit error rate');
ber

Bipolar NRZ

clear all;
close all;
clc;
% Effect of noise on the transmitted
n=[1,1,0,1,0];
A=5;
f=0;
% mapping bits to levels
for ii=1:length(n);
if n(ii)==0;
nn(ii)=0;
else
if f==0
nn(ii)=A;
f=1;
else
nn(ii)=-A;
f=0;
end
end
end
% Pulse shaping
i=1;
t=0:0.01:length(n);
for j=1:length(t);
if t(j)<=i;
y(j)=nn(i);
else
y(j)=nn(i);
i=i+1;
end
end
% plotting
subplot(211);
plot(t,y);
axis([0 length(n) -A+1 A+1]);
% AWGN channel
SNR=-2; % in dB
r=awgn(y,SNR);
subplot(212);
plot(t,r);
% smapling
% sampling instants
Tb=1;
T=(Tb/2)/0.01;
s=r(T+1:(Tb/0.01):length(t));
% detection
% threshold
Th=(-A+A)/2;
% Hard decision decoding
for ii=1:length(s);
if s(ii)>=Th;
det(ii)=1;
else
det(ii)=0;
end
end
% bit error rate analysis
[noe ber]=biterr(n,det);
disp('Number of Errors');
noe
disp('Bit error rate');
ber

Bipolar RZ

clear all;
close all;
clc;
% Effect of noise on the transmitted
% transmitted bits
n=[1,1,0,1,0];
A=5;
f=0;
% mapping bits to levels
for ii=1:length(n);
if n(ii)==0;
nn(ii)=0;
else
if f==0
nn(ii)=A;
f=1;
else
nn(ii)=-A;
f=0;
end
end
end
% Pulse shaping
i=1;
a=0;
b=0.5;
t=0:0.01:length(n);
for j=1:length(t)
if t(j)>=a && t(j)<=b
y(j)=nn(i);
elseif t(j)>b && t(j)<=i
y(j)=0;
else
i=i+1;
a=a+1;
b=b+1;
end
end
% plotting
subplot(211);
plot(t,y);
axis([0 length(n) -A+1 A+1]);
% AWGN channel
SNR=-2; % in dB
r=awgn(y,SNR);
subplot(212);
plot(t,r);
% smapling
% sampling instants
Tb=1;
T=(Tb/2)/0.01;
s=r(T+1:(Tb/0.01):length(t));
% detection
% threshold
Th=(-A+A)/2;
% Hard decision decoding
for ii=1:length(s);
if s(ii)>=Th;
det(ii)=1;
else
det(ii)=0;
end
end
% bit error rate analysis
[noe ber]=biterr(n,det);
disp('Number of Errors');
noe
disp('Bit error rate');
ber
Polar NRZ

clear all;
close all;
clc;
% Effect of noise on the transmitted
% transmitted bits
n=[1,0,1,1,0];
A=5;
f=0;
% mapping bits to levels
for ii=1:length(n);
if n(ii)==0;
nn(ii)=-A;
else
nn(ii)=A;
end
end
% Pulse shaping
i=1;
t=0:0.01:length(n);
for j=1:length(t);
if t(j)<=i;
y(j)=nn(i);
else
y(j)=nn(i);
i=i+1;
end
end
% plotting
subplot(211);
plot(t,y);
axis([0 length(n) -A+1 A+1]);
% AWGN channel
SNR=-2; % in dB
r=awgn(y,SNR);
subplot(212);
plot(t,r);
% smapling
% sampling instants
Tb=1;
T=(Tb/2)/0.01;
s=r(T+1:(Tb/0.01):length(t));
% detection
% threshold
Th=(-A+A)/2;
% Hard decision decoding
for ii=1:length(s);
if s(ii)>=Th;
det(ii)=1;
else
det(ii)=0;
end
end
% bit error rate analysis
[noe ber]=biterr(n,det);
disp('Number of Errors');
noe
disp('Bit error rate');
ber

Polar RZ

clear all;
close all;
clc;
% Effect of noise on the transmitted
% transmitted bits
n=[1,0,1,1,0];
A=5;
f=0;
% mapping bits to levels
for ii=1:length(n);
if n(ii)==0;
nn(ii)=-A;
else
nn(ii)=A;
end
end
% Pulse shaping
i=1;
a=0;
b=0.5;
t=0:0.01:length(n);
for j=1:length(t)
if t(j)>=a &&t(j)<=b
y(j)=nn(i);
elseif t(j)>b && t(j)<=i
y(j)=0;
else
i=i+1;
a=a+1;
b=b+1;
end
end
% plotting
subplot(211);
plot(t,y);
axis([0 length(n) -A+1 A+1]);
% AWGN channel
SNR=-2; % in dB
r=awgn(y,SNR);
subplot(212);
plot(t,r);
% smapling
% sampling instants
Tb=1;
T=(Tb/2)/0.01;
s=r(T+1:(Tb/0.01):length(t));
% detection
% threshold
Th=(-A+A)/2;
% Hard decision decoding
for ii=1:length(s);
if s(ii)>=Th;
det(ii)=1;
else
det(ii)=0;
end
end
% bit error rate analysis
[noe ber]=biterr(n,det);
disp('Number of Errors');
noe
disp('Bit error rate');
ber

Manchester Encoding

clc;
clear all;
close all;
b=input('Enter bit sequence: ');
l=length(b);
b(l+1)=0;
n=1;
while n<=l
t=(n-1):.001:n;
if b(n)==1
if b(n+1)==0
y=(t<(n-0.5))+(-1)*(t>=n-0.5&t<=n);
else
y=(t<(n-0.5)|t==n)+(-1)*(t>=n-0.5&t<n);
end
else
if b(n+1)==1
y=(-1)*(t<(n-0.5))+(t>=n-0.5&t<=n);
else
y=(-1)*(t<(n-0.5)|t==n)+(t>=n-0.5&t<n);
end
end
plot(t,y)
hold on;
axis([0 l -1.5 1.5]);
n=n+1;
end
title('Manchester');
xlabel('Time');
ylabel('Amplitude');
Graphical Output (Captured Photo)
Unipolar NRZ
Number of Errors

noe =

Bit error rate

ber =

Unipolar RZ

Number of Errors
noe =

Bit error rate

ber =

0.4000

Bipolar NRZ

Number of Errors

noe =

Bit error rate

ber =

0.2000

Bipolar RZ
Number of Errors

noe =

Bit error rate

ber =

0.2000

Polar NRZ

Number of Errors
noe =

Bit error rate

ber =

Polar RZ

Number of Errors

noe =

Bit error rate

ber =
0

Manchester Encoding ( sequence – [1,1,0,1,0,0] )


Result: The experiment was performed to observe the different type of line coding, i.e., Unipolar,
Bipolar, Polar and Manchester type in both RZ and NRZ form. Also noticed the same in AWGN channel
for the first three types of line coding.

Verification Signature

You might also like