DCOM - EXP6 - Line Coding
DCOM - EXP6 - Line Coding
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);
DCL/V/July-November_2024_Page No.-
K. J. Somaiya College of Engineering, Mumbai-77
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
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
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
Manchester:
DCL/V/July-November_2024_Page No.-
K. J. Somaiya College of Engineering, Mumbai-77
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;
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")
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)
DCL/V/July-November_2024_Page No.-
K. J. Somaiya College of Engineering, Mumbai-77
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.
DCL/V/July-November_2024_Page No.-