You are on page 1of 15

ECE-4001- Digital Communication System Laboratory

LAB-4

Name: - A.S.U. NANDAN


Slot: - L9 + L10
Faculty: - Dr. Revathi S

Aim/Objective:
Observe Line Coding and its Power Spectra
1. To plot the given digital sequence with the following line coding techniques-
a. Unipolar NRZ
b. Unipolar RZ
c. Polar NRZ
d. Polar RZ
e. Manchester Coding
2. To plot the power spectra of the above given coding

Theory:
We understand the pulse representation of the binary form of the data which is called the Line Coding
technique.
For the data 10101100 (Tb- Bit duration)
Unipolar NRZ- 1’s- has a pulse, 0’s- zero (for the whole Tb)
Unipolar RZ- 1’s- has a pulse for Tb/2 and return to zero, 0’s-zero
Polar NRZ- 1’s- has a pulse(+A), 0’s- has a pulse(-A) (for the whole Tb)
Polar RZ- 1’s- has a pulse for Tb/2(+A), has a pulse for Tb/2(-A)
Manchester Coding- 1’s- Positive pulse for Tb/2 and then Negative pulse for Tb/2, 0’s- Negative
pulse for Tb/2 and then Positive pulse for Tb/2
Plotting the Power Spectra-
We are going to plot in terms of frequency and we infer about the bandwidth, power and the presence
of the DC component.

Algorithm:
1. Clear the screen-
clc;
clear all;
close all;
2. Assigning binary sequence-
bits=[1 0 1 1 0 0 1 1]
3. Checking the length of the binary seq.
l= length(bits);
4. Assigning the bit duration in sec-
Tb=1;
5. No of samples within single bit duration
n=100;
6. Time sequence-
t=0: 1/100 :1
7. Initializing the output vector with zero’s-
X1= zeros(1, l);
8. Expressing the operation in terms of input seq. –
For i=1:l
If(bits(i)==1)
X1((i-1)*n : (i+n))=3
Else
X1((i-1)*n : (i+n))=0
End
End
9. Plotting the input and output seq.
Figure(1)
Subplot(2,1,1)
Stem(bits);
Axis[0 10 : -2 2]
Title(“Input Signal”)
Xlabel();
Ylabel();
Subplot(2,1,2);
Stairs(X1);
axis
Title(“Unipolar NRZ”);
Xlabel();
Ylabel();

For Polar NRZ-


change the values to 3 and -3 in the for loop step
For Unipolar RZ-
for i=1:l
if bits(i)==1
x2(((i-1)*n+1):((i-1)*n+(n/2)))= 3;
x2(((i-1)*n+(n/2)+1):(i*n))=0;
else
x2(((i-1)*n+1):(i*n))= 0;
end
end

For Polar RZ-


for i=1:l
if bits(i)==1
x4(((i-1)*n+1):((i-1)*n+(n/2)))= 3;
x4(((i-1)*n+(n/2)+1):(i*n))=0;
else
x4(((i-1)*n+1):((i-1)*n+(n/2)))= -3;
x4(((i-1)*n+(n/2)+1):(i*n))=0;
end
end

Manchester Coding-
for i=1:l
if bits(i)==1
x5(((i-1)*n+1):((i-1)*n+(n/2)))= 3;
x5(((i-1)*n+(n/2)+1):(i*n))=-3;
else
x5(((i-1)*n+1):((i-1)*n+(n/2)))= -3;
x5(((i-1)*n+(n/2)+1):(i*n))=3;
end
end

Code:
clc;
clear all;
close all;
bits= [1 0 1 1 0 1 0 0]
l= length(bits);
tb=1;
n=100;
t= 0: 1/100 : 1;
%% Unipolar NRZ %%
x1=zeros(1,l);
for i=1:l
if(bits(i)==1)
x1(((i-1)*n+1):(i*n))=3;
x1()
else
x1(((i-1)*n+1):(i*n))=0;
end
end
figure(1)
subplot(2,1,1)
stem(bits, 'b', "Linewidth", 4);
axis([0 10 -2 2]);
title("Input Signal");
xlabel("bits");
ylabel("amplitude");
subplot(2,1,2);
stairs(x1, 'r', 'Linewidth',4);
title("Unipolar NRZ");
xlabel("samples");
ylabel("amplitude");
%% Unipolar RZ %%
x2=zeros(1,l);
for i=1:l
if bits(i)==1
x2(((i-1)*n+1):((i-1)*n+(n/2)))= 3;
x2(((i-1)*n+(n/2)+1):(i*n))=0;
else
x2(((i-1)*n+1):(i*n))= 0;
end
end
figure(2)
subplot(2,1,1)
stem(bits, 'b', "Linewidth", 4);
axis([0 10 -2 2]);
title("Input Signal");
xlabel("bits");
ylabel("amplitude");
subplot(2,1,2);
stairs(x2, 'r', 'Linewidth',4);
title("Unipolar RZ");
xlabel("samples");
ylabel("amplitude");
%% Polar NRZ %%
x3=zeros(1,l);
for i=1:l
if(bits(i)==1)
x3(((i-1)*n+1):(i*n))=3;
else
x3(((i-1)*n+1):(i*n))=-3;
end
end
figure(3)
subplot(2,1,1)
stem(bits, 'b', "Linewidth", 4);
axis([0 10 -2 2]);
title("Input Signal");
xlabel("bits");
ylabel("amplitude");
subplot(2,1,2);
stairs(x3, 'r', 'Linewidth',4);
title("Polar NRZ");
xlabel("samples");
ylabel("amplitude");
%% Polar RZ %%
x4=zeros(1,l);
for i=1:l
if bits(i)==1
x4(((i-1)*n+1):((i-1)*n+(n/2)))= 3;
x4(((i-1)*n+(n/2)+1):(i*n))=0;
else
x4(((i-1)*n+1):((i-1)*n+(n/2)))= -3;
x4(((i-1)*n+(n/2)+1):(i*n))=0;
end
end
figure(4)
subplot(2,1,1)
stem(bits, 'b', "Linewidth", 4);
axis([0 10 -2 2]);
title("Input Signal");
xlabel("bits");
ylabel("amplitude");
subplot(2,1,2);
stairs(x4, 'r', 'Linewidth',4);
title("Polar RZ");
xlabel("samples");
ylabel("amplitude");
%% Manchester Coding %%
x5=zeros(1,l);
for i=1:l
if bits(i)==1
x5(((i-1)*n+1):((i-1)*n+(n/2)))= 3;
x5(((i-1)*n+(n/2)+1):(i*n))=-3;
else
x5(((i-1)*n+1):((i-1)*n+(n/2)))= -3;
x5(((i-1)*n+(n/2)+1):(i*n))=3;
end
end
figure(5)
subplot(2,1,1)
stem(bits, 'b', "Linewidth", 4);
axis([0 10 -2 2]);
title("Input Signal");
xlabel("bits");
ylabel("amplitude");
subplot(2,1,2);
stairs(x5, 'r', 'Linewidth',4);
title("Manchester Coding");
xlabel("samples");
ylabel("amplitude");

Observation:
• Unipolar NRZ
• Unipolar RZ

• Polar NRZ
• Polar RZ

• Manchester Coding
Inference:
The illustration of Unipolar NRZ, Unipolar RZ, PolarNRZ, PolarRZ, Manchester Coding
successfully using MATLAB.
ECE-4001- Digital Communication System Laboratory
LAB-5

Name: - A.S.U. NANDAN


Slot: - L9 + L10
Faculty: - Dr. Revathi S

Aim/Objective:
Duobinary encoding and Modified Duobinary encoding
Theory:
Duobinary data encoding is a form of correlative coding in partial response signaling. The
modulator drive signal can be produced by adding one-bit-delayed data to the present data bit
to give levels 0, 1, and 2.
Modified Duobinary Signalling is an extension of duobinary signalling. It has the advantage
of zero PSD at low frequencies (especially at DC ) that is suitable for channels with poor DC
response.
Algorithm:
1. Clearing the screen
Clc;
Clear all;
Close all;
2. Input Binary Sequence
b=[1 0 0 1 1 0]

iii. Assumption Bit for ak


a(1)=0

iv. Exclusive OR of bk with ak;


For i=2: length (b)+1
If a(i-1)==0 && b(i-1)==0
a(i)=0;
Else if (a(i-1)==0 && b(i-1)==0)
a(i)=1;
else
a(i)=0
end
end
v. Convert ak into polar form
For i=1: lenthg(b)+1
If a(i) ==0
Pa(i)=-1
Else
Pa(i)=1
End
End
vi. Generating the transmitted signal
For i=1:length (b)
C(i)=pa(i)+pa(i+1)
End
vii. Threshod detection of Received signal
For i=1:length( c)
If else(c(i))>1
D(i)=0
Else
D(i)=1;
End
End
viii. Plotting a. Binary signal bk
b. Polar ak
c. Transmitted Ck
d.Detected dk
Code:
clc
clear all
close all
b = [1 0 0 1 1 0 1 0];
a(1)= 0;
% The exclusive OR operation
for i = 2:length(b)+1
if a(i-1) == 0 && b(i-1) == 0
a(i) = 0;
elseif a(i-1) == 0 && b(i-1) == 1
a(i) = 1;
elseif a(i-1) == 1 && b(i-1) == 0
a(i) = 1;
else
a(i) = 0;
end
end

%Converting ak into polar form


for i = 1:length(b)+1
if a(i) == 0
Pa(i) = -1;
else
Pa(i) = 1;
end
end

%Generating the transmitted signal


for i = 1:length(b)
c(i) = Pa(i)+Pa(i+1);
end

%Threshold detection of received signal


for i = 1:length(c)
if abs(c(i))>1
d(i) = 0; %Detected message signal
else
d(i) = 1;
end
end

subplot(4,1,1);
stem(b,'color','r','linewidth',2);
title('Binary Signal-19BEC1382');
xlabel('Time');
ylabel('Amplitude');

subplot(4,1,2);
stairs(Pa,'color','b','linewidth',2);
title('Polar Form');
xlabel('Time');
ylabel('Amplitude');

subplot(4,1,3);
stairs(c,'color','c','linewidth',2);
title('Transmitted Signal');
xlabel('Time');
ylabel('Amplitude');

subplot(4,1,4);
stem(d,'color','g','linewidth',2);
title('Received Signal');
xlabel('Time');
ylabel('Amplitude');

Code 2:
clc
clear all;
close all;
bits = [1 1 0 0 1 1];
a(1) = 0;
a(2) = 0;
for i = 3:length(bits)+2
if a(i-2) == 0 && bits(i-2) == 0
a(i) = 0;
elseif a(i-2) == 0 && bits(i-2) == 1
a(i) = 1;
elseif a(i-2) == 1 && bits(i-2) == 0
a(i) = 1;
else
a(i) = 0;
end
end

for i = 1:length(bits)+2
if a(i) == 0
Pa(i) = -1;
else
Pa(i) = 1;
end
end

for i = 3:length(bits)+2
c(i-2) = Pa(i)-Pa(i-2);
end
for i = 1:length(c)
if abs(c(i))>1
d(i) = 1;
else
d(i) = 0;
end
end

subplot(4,1,1);
stem(bits,'color','black','linewidth',4);
title('Binary');
xlabel('Time');
ylabel('Amplitude');

subplot(4,1,2);
stairs(Pa,'color','y','linewidth',4);
title('Polar Form');
xlabel('Time');
ylabel('Amplitude');

subplot(4,1,3);
stairs(c,'color','m','linewidth',4);
title('Transmitted Signal');
xlabel('Time');
ylabel('Amplitude');

subplot(4,1,4);
stem(d,'color','red','linewidth',4);
title('Received Signal');
xlabel('Time');
ylabel('Amplitude');
Observation:
• Duobinary Coding

• Modified Duobinary coding


Inference:
The illustration of Unipolar NRZ, Unipolar RZ, PolarNRZ, PolarRZ, Manchester Coding
successfully using MATLAB.

You might also like