0% found this document useful (0 votes)
32 views7 pages

DCOM - EXP6 - Line Coding

Uploaded by

inginyuerss
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)
32 views7 pages

DCOM - EXP6 - Line Coding

Uploaded by

inginyuerss
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/ 7

K. J.

Somaiya College of Engineering, Mumbai-77

Batch: A1 Roll No.: 16010322019


Experiment / assignment / tutorial No._06_
Grade: AA / AB / BB / BC / CC / CD /DD

Signature of the Staff In-charge with date

Title: Line Coding


Objectives:
1. To understand different line coding techniques of base band signal
2. To develop a logic and generate waveforms of the given line coding techniques

OUTCOME: analyze distortion less baseband transmission and reception of signal along with
waveform coding techniques

Problem statement:

A. For the given binary sequence b = {1, 0, 1, 0, 1, 1}; sketch the waveforms representing the
sequence b using the following line codes:

• Unipolar NRZ
• Polar NRZ
• Bipolar NRZ
• Manchester

Assume unit pulse amplitude and use binary data rate Rb = 1kbps. Write a program
using MATLAB or any other open source software for the above line codes.

MATLAB codes:
% Demo of using different line codings
bits = [1 0 1 0 1 1];
bitrate = 1000; % bits per second

figure;
[t,s] = unrz(bits,bitrate); plot(t,s,'LineWidth',3);
axis([0 t(end) -0.1 1.1]) grid on;
title(['Unipolar NRZ: [' num2str(bits) ']']);

figure;
[t,s] = urz(bits,bitrate); plot(t,s,'LineWidth',3);
axis([0 t(end) -0.1 1.1]) grid on;
title(['Unipolar RZ: [' num2str(bits) ']']);

figure;
[t,s] = prz(bits,bitrate); plot(t,s,'LineWidth',3);

Department of Electronics and Telecommunication Engineering

DCL/V/July-November_2024_Page No.-
K. J. Somaiya College of Engineering, Mumbai-77

axis([0 t(end) -1.1 1.1]) grid on;


title(['Polar RZ: [' num2str(bits) ']']);

figure;
[t,s] = manchester(bits,bitrate); plot(t,s,'LineWidth',3);
axis([0 t(end) -1.1 1.1]) grid on;
title(['Manchester: [' num2str(bits) ']']);

figure;
[t,s] = pnrz(bits,bitrate); plot(t,s,'LineWidth',3);
axis([0 t(end) -1.1 1.1]) grid on;
title(['Polar NRZ: [' num2str(bits) ']']);

Unipolar RZ (URZ):
function [t,x] = urz(bits, bitrate)
T = length(bits)/bitrate; %full time of bit sequence
n = 200;
N = n*length(bits); dt = T/N;
t = 0:dt:T;
x = zeros(1,length(t)); % output signal
for i = 0:length(bits)-1 if bits(i+1) == 1
x(i*n+1:(i+0.5)*n) = 1;
x((i+0.5)*n+1:(i+1)*n) = 0;
else
x(i*n+1:(i+1)*n) = 0; end
end

Unipolar NRZ (UNRZ):


function [t,x] = unrz(bits, bitrate)
T = length(bits)/bitrate;
n = 200;
N = n*length(bits); dt = T/N;
t = 0:dt:T;
x = zeros(1,length(t)); % output signal

for i = 0:length(bits)-1 if bits(i+1) == 1


x(i*n+1:(i+1)*n) = 1; else
x(i*n+1:(i+1)*n) = 0; end
end

Polar RZ(PRZ):
function [t,x] = prz(bits, bitrate) T = length(bits)/bitrate;
n = 200;
N = n*length(bits); dt = T/N;
t = 0:dt:T;
x = zeros(1,length(t)); % output signal

for i = 0:length(bits)-1 if bits(i+1) == 1


x(i*n+1:(i+0.5)*n) = 1;

Department of Electronics and Telecommunication Engineering

DCL/V/July-November_2024_Page No.-
K. J. Somaiya College of Engineering, Mumbai-77

x((i+0.5)*n+1:(i+1)*n) = 0;
else
x(i*n+1:(i+0.5)*n) = -1;
x((i+0.5)*n+1:(i+1)*n) = 0;
end end

Polar NRZ (PNRZ):


function [t,x] = pnrz(bits, bitrate)
T = length(bits)/bitrate;
n = 200;
N = n*length(bits); dt = T/N;
t = 0:dt:T;
x = zeros(1,length(t)); % output signal for i =
0:length(bits)-1
if bits(i+1) == 1 x(i*n+1:(i+0.5)*n) = 1;
x((i+0.5)*n+1:(i+1)*n) = 1;
else
x(i*n+1:(i+0.5)*n) = -1;
x((i+0.5)*n+1:(i+1)*n) = -1;
end
end end

Manchester:

function [t,x] = manchester(bits, bitrate)


T = length(bits)/bitrate;
n = 200;
N = n*length(bits); dt = T/N;
t = 0:dt:T;
x = zeros(1,length(t)); % output signal
for i = 0:length(bits)-1 if bits(i+1) == 1
x(i*n+1:(i+0.5)*n) = 1;
x((i+0.5)*n+1:(i+1)*n) = -1;
else
x(i*n+1:(i+0.5)*n) = -1;
x((i+0.5)*n+1:(i+1)*n) = 1;
end end

Department of Electronics and Telecommunication Engineering

DCL/V/July-November_2024_Page No.-
K. J. Somaiya College of Engineering, Mumbai-77

Bipolar NRZ (BNRZ):

clc
clear all close all
% NRZ bipolar Line Coding N = 6;
n = [1, 0, 1, 0, 1, 1];
% bipolar Mapping f=1;
for m = 1:N if n(m) == 1 if f==1 nn(m)=1;
f=-1
else nn(m)=-1 f=1;
end else
nn(m) = 0;
end end
%NRZ 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
plot (t,y);
axis ([0 N -2 2]);
xlabel ('Time'); ylabel('Amplitude');
title('NRZ Bipolar Line Coding')

B. Determine and sketch the power spectral density (PSD) functions corresponding to the
above line codes.

Hints: Use Rb = 1 kbps: Let f1 > 0 be the location of the first spectral null in the PSD
function. If the transmission bandwidth BT of a line code is determined by f1, determine BT
for the line codes in question 1 as a function of Rb:

Let fP1: first spectral peak; fn1: first spectral null; fp2: second spectral peak; fn2: second
spectral null; such that all fp/n > 0

CODE:

clc;
clear all;
close all;

% Input parameters
Rb = 1;
Tb = 1/Rb;
f = 0:0.05*Rb:2*Rb;
x = f*Tb;

% Power spectral density of polar signal

Department of Electronics and Telecommunication Engineering

DCL/V/July-November_2024_Page No.-
K. J. Somaiya College of Engineering, Mumbai-77

P = Tb*(sinc(x).*sinc(x));
figure(1)
plot(f,P,'r')
grid on
box on
xlabel("Freq ->")
ylabel("Power Spectral Density ->")
title("PSD for Polar Signal")

% Power spectral density of Unipolar signal


P1 = 0.5*Tb*(sinc(x).*sinc(x)+0.5*dirac(f));
figure(2)
plot(f,P1,'r')
grid on
box on
xlabel("Freq ->")
ylabel("Power Spectral Density ->")
title("PSD for Unipolar Signal")

% Power spectral density of Manchester signal


P2 = Tb*(sinc(x/2)).^2.*(sin(pi*(x/2))).^2;
figure(3)
grid on
box on
xlabel("Freq ->")
ylabel("Power Spectral Density ->")
title("PSD for Manchester Signal")

% Power spectral density of Bipolar signal


P3 = Tb*(sinc(x/2)).^2.*(sin(pi*x)).^2;
figure(4)
grid on
box on
xlabel("Freq ->")
ylabel("Power Spectral Density ->")
title("PSD for Bipolar Signal")

% Plotting Power spectral density of Binary line codes


figure(5)
hold on
plot(f,P,'r')
plot(f,P1,'g')
plot(f,P2,'b')
plot(f,P3,'m')
grid on
box on
xlabel("Freq ->")
ylabel("Power spectral density ->")
title("PSD for various Binary line codes")
legend("PSD for polar signal","PSD for unipolar signal", "PSD for manchester signal","PSD
for bipolar signal")

BW_Polar = powerbw(P,f)
Department of Electronics and Telecommunication Engineering

DCL/V/July-November_2024_Page No.-
K. J. Somaiya College of Engineering, Mumbai-77

BW_Unipolar = powerbw(P1,f)
BW_Manchester = powerbw(P2,f)
BW_Bipolar = powerbw(P3, f)

Department of Electronics and Telecommunication Engineering

DCL/V/July-November_2024_Page No.-
K. J. Somaiya College of Engineering, Mumbai-77

Record your observations in Table:

Rb = FP1 FN1 FP2 FN2 BT

Unipolar 0.5 6.087e-33 1.4 9.116e-65 4.9994


NRZ

Polar NRZ 1 6.087e-33 1.45 9.116e-65 4.9994

Bipolar NRZ 0.823501 6.087e-33 0.1283 9.116e-65 798.6481

Manchester 0.524927 6.087e-33 0 9.116e-65 479.2429

Expected output:
• Waveforms of all line coding techniques
• Graph of magnitude response of each waveform
• Bandwidth required for transmitting each line code of the baseband waveform.

Discussion/Conclusion:
In this experiment, we explored various line coding techniques for signal transmission.
Understanding these techniques enhances our ability to optimize signal integrity in digital
communication systems.

Signature of faculty in-charge

Department of Electronics and Telecommunication Engineering

DCL/V/July-November_2024_Page No.-

You might also like