[go: up one dir, main page]

0% found this document useful (0 votes)
466 views12 pages

DC Lab Exp6 17l238 Rep

The document describes the design and implementation of various line coding schemes in Scilab. It discusses the theory behind line coding, types of line coding including unipolar, polar, and bipolar. It then shows the Scilab code to encode data using these schemes in both non-return-to-zero and return-to-zero formats. Additional schemes like Manchester coding and high density bipolar coding are also implemented. Finally, it calculates the power spectral density of different codes to analyze and compare them.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
466 views12 pages

DC Lab Exp6 17l238 Rep

The document describes the design and implementation of various line coding schemes in Scilab. It discusses the theory behind line coding, types of line coding including unipolar, polar, and bipolar. It then shows the Scilab code to encode data using these schemes in both non-return-to-zero and return-to-zero formats. Additional schemes like Manchester coding and high density bipolar coding are also implemented. Finally, it calculates the power spectral density of different codes to analyze and compare them.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 12

Ex.

No: 6 DESIGN AND IMPLEMENTATION OF LINE CODING


Date: 30/10/2020 SCHEMES

AIM:

To design and implement Line Coding schemes mbler using Scilab 6.1.0.

REQUIREMENTS:

PC with Scilab 6.1.0

THEORY:

Line coding schemes

A line code is the code used for data transmission of a digital signal over a transmission line. This
process of coding is chosen so as to avoid overlap and distortion of signal such as inter-symbol
interference.
Types of Line Coding
There are 3 types of Line Coding:
1. Unipolar
2. Polar
3. Bi-polar
Unipolar Signaling
Unipolar signaling is also called as On-Off Keying. The presence of pulse represents a 1 and the absence
of pulse represents a 0.
There are two variations in Unipolar signaling:
1. Non Return to Zero NRZ
2. Return to Zero RZ

Polar Signaling

In this type of Polar signaling, a High in data is represented by a positive pulse, while a Low in data is
represented by a negative pulse.

Bipolar Signaling

This is an encoding technique which has three voltage levels namely +, - and 0. Such a signal is called
as duo-binary signal.

An example of this type is Alternate Mark Inversion AMI. For a 1, the voltage level gets a transition from
+ to – or from – to +, having alternate 1s to be of equal polarity. A 0 will have a zero voltage level.

Even in this method, we have two types;

1. Bipolar NRZ
2. Bipolar RZ

Manchester Line Coding

17L238
In telecommunication and data storage, Manchester code (also known as phase encoding, or PE) is a
line code in which the encoding of each data bit is either low then high, or high then low, for equal time.
It is a self-clocking signal with no DC component.

High Density Bipolar

A sequence of four consecutive zeros in encoded using a special "violation" bit. This bit has the same
polarity as the last 1-bit that was sent using the AMI encoding rule. Further refinement is necessary to
prevent a DC voltage from being introduced by excessive runs of zeros. THe voliation bit alternates
between + and - pulses for every consecutive group of four zeros.

SCILAB

Scilab code

Unipolar encoding

clc;
clear ;
close ;

x =input("Enter data bits")// Data Stream

//Uni-Polar NRZ
z =0; // Starting value on axis
for i =1:length(x)
t=[z:1:z+1]
subplot (3,1,1)
a=gca();
a.data_bounds=[0 -1.5;length(x) 1.5]
a.grid =[1,-1]
title("Data")
plot (t ,x(i)) // Pl o t c u r r e n t da ta b i t
subplot(3,1 ,2)
a=gca() ;
a.data_bounds=[0 -1.5; length(x) 1.5]
a.grid=[1 -1]
title ("Unipolar NRZ")
if( x(i) ==0)
plot (t,0)
else
plot (t,1)
end
z = z+1
end

//Uni-Polar RZ
z =0;
for i =1:length(x)
t =[z:0.5:z+1]
//subplot (2,1,1)

17L238
a=gca();
a.data_bounds=[0 -1.5;length(x) 1.5]
a.grid =[1 -1]

subplot (3,1,3)
a=gca();
a.data_bounds =[0 -1.5;length(x) 1.5]

a.grid =[1 -1]


title ("Unipolar RZ")
if(x(i)==0)
plot(t,0)
elseif(x(i)==1)
t =[z:0.5:(z+0.5)]
plot(t,1)
t =[(z+0.5):0.5:(z+1)]
plot(t,0)
end
z=z+1;
end

Output

Polar encoding

clc;
clear ;
close ;

x =input("Enter data bits") // Data Stream

//Polar NRZ

17L238
z =0; // Starting value on axis
for i =1:length(x)
t=[z:1:z+1]
subplot (3,1,1)
a=gca();
a.data_bounds=[0 -1.5;length(x) 1.5]
a.grid =[1,-1]
title("Data")
plot (t ,x(i))
subplot(3,1 ,2)
a=gca() ;
a.data_bounds=[0 -1.5; length(x) 1.5]
a.grid=[1 -1]
title ("Polar NRZ")
if( x(i) ==0)
plot (t,-1)
else
plot (t,1)
end
z = z+1
end

//Polar RZ
z =0; //starting value on x axis
for i =1:length(x)
t =[z:0.5:z+1]
//subplot (2,1,1)
a=gca();
a.data_bounds=[0 -1.5;length(x) 1.5]
a.grid =[1 -1]

subplot (3,1,3)
a=gca();
a.data_bounds =[0 -1.5;length(x) 1.5]

a.grid =[1 -1]


title ("Polar RZ")
if(x(i)==0)
t =[z:0.5:(z+0.5)]
plot(t,-1)
t =[z+0.5:0.5:(z+1)]
plot(t,0)
elseif(x(i)==1)
t =[z:0.5:(z+0.5)]
plot(t,1)
t =[(z+0.5):0.5:(z+1)]
plot(t,0)
end

z=z+1;
end

17L238
Output

Bipolar encoding

clc;
clear ;
close ;

x =input("Enter data bits") // Data Stream

//Bi-Polar NRZ
z =0; // Starting value on axis
k1=-1
for i =1:length(x)
t=[z:1:z+1]
subplot (3,1,1)
a=gca();
a.data_bounds=[0 -1.5;length(x) 1.5]
a.grid =[1,-1]
title("Data")
plot (t ,x(i)) // Pl o t c u r r e n t da ta b i t
subplot(3,1 ,2)
a=gca() ;
a.data_bounds=[0 -1.5; length(x) 1.5]
a.grid=[1 -1]
title ("Bipolar NRZ")
if( x(i) ==0)
plot (t,0)
else
k1=-k1
plot (t,k1)
end
z = z+1
end

17L238
//Bi-Polar RZ
z =0;
k2=1
for i =1:length(x)
t =[z:0.5:z+1]

a=gca();
a.data_bounds=[0 -1.5;length(x) 1.5]
a.grid =[1 -1]
subplot (3,1,3)
a=gca();
a.data_bounds =[0 -1.5;length(x) 1.5]

a.grid =[1 -1]


title ("Bipolar RZ")
if(x(i)==0)
plot(t,0)
elseif(x(i)==1)
t =[z:0.5:(z+0.5)]
plot(t,k2) // Pl o t 0 f o r f i r s t h a l f b i t d u r a t i o n
t =[(z+0.5):0.5:(z+1)]
plot(t,0)
k2=-k2
end

z=z+1;
end

Output

Manchester and Differential Manchester

17L238
clc;
clear ;
close ;

x =input("Enter data bits")// Data Stream

//plotting the data


z =0; // Starting value on axis
for i =1:length(x)
t=[z:1:z+1]
subplot (3,1,1)
a=gca();
a.data_bounds=[0 -1.5;length(x) 1.5]
a.grid =[1,-1]
title("Data")
plot (t ,x(i))
z = z+1
end

//Manchester
z =0;
for i =1:length(x)
t =[z:0.5:z+1]
//subplot (2,1,1)
a=gca();
a.data_bounds=[0 -1.5;length(x) 1.5]
a.grid =[1 -1]
subplot (3,1,2)
a=gca();
a.data_bounds =[0 -1.5;length(x) 1.5]

a.grid =[1 -1]


title ("Manchester")
if(x(i)==0)
t =[z:0.5:(z+0.5)]
plot(t,-1)
t =[z+0.5:0.5:(z+1)]
plot(t,1)
elseif(x(i)==1)
t =[z:0.5:(z+0.5)]
plot(t,1)
t =[(z+0.5):0.5:(z+1)]
plot(t,-1)
end

z=z+1;
end

//Differential Manchester
z =0;
k=1

17L238
for i =1:length(x)
t =[z:0.5:z+1]
a=gca();
a.data_bounds=[0 -1.5;length(x) 1.5]
a.grid =[1 -1]
subplot (3,1,3)
a=gca();
a.data_bounds =[0 -1.5;length(x) 1.5]

a.grid =[1 -1]


title ("Differential Manchester")
if(x(i)==0)
t =[z:0.5:(z+0.5)]
plot(t,-k)
t =[z+0.5:0.5:(z+1)]
plot(t,k)
elseif(x(i)==1)
t =[z:0.5:(z+0.5)]
plot(t,k)
t =[(z+0.5):0.5:(z+1)]
plot(t,-k)
k=-k;
end
z=z+1;
end

Output

High Density Bipolar coding

clc;
clear ;

17L238
close ;

x =input("Enter data bits")// Data Stream

//plotting the data


z =0; // Starting value on axis
for i =1:length(x)
t=[z:1:z+1]
subplot (3,1,1)
a=gca();
a.data_bounds=[0 -1.5;length(x) 1.5]
a.grid =[1,-1]
title("Data")
plot (t ,x(i))
z = z+1
end

z =0;
c=0;
count=0;
k=1;
for i =1:length(x)
t =[z:0.5:z+1]
//subplot (2,1,1)
a=gca();
a.data_bounds=[0 -1.5;length(x) 1.5]
a.grid =[1 -1]
subplot (3,1,2)
a=gca();
a.data_bounds =[0 -1.5;length(x) 1.5]

a.grid =[1 -1]


title ("High Density Bipolar")
if(x(i)==0)
c=c+1
if(c<3)
plot(t,0)
elseif(c==4 && modulo(count,2)~=0)
c=0
count=0
plot(t,-k,'r','linewidth',3)
elseif(c==4 && modulo(count,2)==0)
c=0
count=0
plot(t,k,'r','linewidth',3)
//z=z-3;
t =[z-3:0.5:z-2]
plot(t,k);
k=-k;
//z=z+3;

17L238
else
plot(t,0)
end
elseif(x(i)==1)
count=count+1
c=0
plot(t,k)
k=-k;
end
z=z+1;
end

Output

PSD Calculation
clc
clear all
clc

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

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

//unipolar
P1=0.5*Tb*(sinc(x).*sinc(x))+ 0.5 *dirac(f);
figure(2)
plot(f,P1,'r')
grid on

17L238
box on
xlabel('f ---->')
ylabel('Power Spectral Density ---->')
title('PSD for Unipolar Signal')

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

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

hold on;
figure(1);
plot(f,P,'r')
plot(f,P1,'g')
plot(f,P2,'b')
plot(f,P3,'m')
grid on
box on
xlabel('f ---->')
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')

Output

17L238
RESULT

Thus, the different line coding schemes have been designed, implemented and verified
successfully.

17L238

You might also like