0% found this document useful (0 votes)
5 views

Project

Uploaded by

omarkhaled999777
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Project

Uploaded by

omarkhaled999777
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

Line Coding

Program: Junior Electrical


Course Name: Fundamental of Communication Systems
Course Code: ECE 252

Name ID

Mohamed Tarek Mahmoud 1901502

Mohamed Sami Mohamed 1901271

Youssef Amgad Saleh 1900624

Abdelrahman Osama Khamis 1901029

Introduced for: Dr. Hussein Kotb


Introduction
A line code is the code used for data transmission of a digital signal over a
transmission line. This process of coding is chosen to avoid overlap and distortion of
signal such as inter-symbol interference.

We can say that line code is electrical representation of binary stream.

Properties of Line Codes


 Low bandwidth: Transmission bandwidth should be as small as possible.

 Power efficiency: For a given bandwidth and a specified detection error rate,
the transmission power should be as low as possible.

 Error detection and correction capability:


o It is desirable to detect and preferably correct the detected errors.
o In a bipolar case, a single error will cause bipolar violation and can
easily be detected.

 Adequate timing content: It should be possible to extract timing or clock


information from the signal.

 Transparency:
o Transparent code: for every possible sequence of data, the coded
signal is received faithfully.

 Favorable power spectral density:


o It is desirable to have zero power spectral density (PSD) at 𝑓 = 0.
o AC coupling and transformers are often used at the regenerative
repeaters.
o DC wander in the pulse stream when ac coupling is used.

Types of line codes with respect to pulse duration


 Non-return to zero.
 The pulse amplitude is held to a constant value throughout the pulse
interval.

P age|1
 Return to zero.
 Return-to-zero implies that the pulse shape used to represent the bit
always returns to the 0 volts or the neutral level before the end of the bit
(half-width pulses).

Types of line codes with respect to pulse amplitude


 Unipolar.
 Polar.
 Bipolar.

So, we will include our report comparison between Unipolar non return to zero and
Alternative Mark Inversion.

Point of Unipolar non return to zero Alternate Mark Inversion


(Bipolar)
Comparison
Data In this type of unipolar signaling, a In the bipolar AMI encoding scheme, 0
Representation High in data is represented by a is represented by no signal and 1 by
positive pulse called as Mark, which either positive or negative voltage.
has a duration 𝑇0 equal to the Binary 1 bits alternate in polarity. Ease
symbol bit duration. A Low in data of synchronization is the main
input has no pulse. advantage of this scheme.
Scheme

P age|2
Advantages  It is simple  No DC component.
 A lesser bandwidth is required  It is simple
 Occupies less bandwidth than
unipolar and polar NRZ schemes.
 Does not suffer from signal droop
(suitable for transmission over AC
coupled lines).
 Possesses single error detection
capability.

Disadvantages  Transmission bandwidth  Does not possess any clocking


 Nonzero power spectrum at component for ease of
dc synchronization.
 No error detection (or  Is not Transparent.
correction).  Long strings of data causes loss
 No clock is present. of synchronization.

Bandwidth 𝑅𝑏 𝑅𝑏

PSD at DC Non-Zero because It has an The PSD has a null at DC, which aids
impulse at 𝑓 = 0 in transformer coupling.
The PSDs of RZ polar, split phase,
and NRZ bipolar (AMI) line codes look
like this:

Power 2 𝐴2 2 𝐴2

Power Require twice as much power as An increasing trade-off between


pattern-effect reduction and mean
Efficiency polar line code
output power with increasing bitrate.

P age|3
Representation Polar NRZ + DC 0 is represented by no signal and 1 by
either positive or negative voltage
Transparency On-off codes is not transparent. A Not Transparent
long string of 0s (or offs) causes the
absence of a signal and can lead to
errors in timing extraction.

The program code of Unipolar NRZ:


Time Domain:
clear

clc;

Random_Signal = randi([0,1],[1,64]);

for i = 1:length(Random_Signal)

if Random_Signal(i)>0

d(i) = 1;

else

d(i) = 0;

end

end

i = 1;

t = 0:0.01:length(Random_Signal);

for j = 1:length(t)

if t(j) <= i

y(j) = d(i);

else

y(j) = d(i);

i = i+1;

end

end

plot(t,y,'g');

P age|4
xlabel('Time');

title('Unipolar NRZ');

P age|5
Power:
clear
clc;
Sum = 0;
h = 0;
while(h<400)
Random_Signal = randi([0,1],[1,1000]);
for i = 1:length(Random_Signal)
if Random_Signal(i)==1
d(i) = 1;
else
d(i) = 0;
end
end
i = 1;
N = ceil(length(Random_Signal)/0.01);
t = 0:0.01:(N-1)*0.01;
h=h+1;
for j = 1:length(t)
if t(j) <= i
y(j) = d(i);
else
y(j) = d(i);
i=i+1;
end
end
a = abs(fftshift(fft(y)))/N;
Sum = Sum+(a).^2;
end
fs = 1/0.01;
df = 1/length(Random_Signal);
f = -0.5*fs:df:0.5*fs-df;
plot(f,Sum/400);
xlabel('Power');
title('Unipolar NRZ');

P age|6
P age|7
Frequency Domain:
clear
clc;
Sum = 0;
h = 0;
while(h<400)
Random_Signal = randi([0,1],[1,1000]);
for i = 1:length(Random_Signal)
if Random_Signal(i)==1
d(i) = 1;
else
d(i) = 0;
end
end
i = 1;
N = ceil(length(Random_Signal)/0.01);
t = 0:0.01:(N-1)*0.01;
h=h+1;
for j = 1:length(t)
if t(j) <= i
y(j) = d(i);
else
y(j) = d(i);
i=i+1;
end
end
a = abs(fftshift(fft(y)))/N;
Sum = Sum+(a);
end
fs = 1/0.01;
df = 1/length(Random_Signal);
f = -0.5*fs:df:0.5*fs-df;
plot(f,Sum/400);
xlabel('Frequency');
title('Unipolar NRZ');

P age|8
P age|9
The program code of Alternate Mark Inversion:
Time Domain:

clc

clear

A=1;

F=randn(1,64);

for j=1:length(F)

if F(j)>0

if A==1

ll(j)=1;

A=-1;

else

ll(j)=-1;

A=1;

end

else

ll(j)=0;

end

end

Z=1;

K=0;

M=0.5;

N=ceil(length(F)/0.01);

T=0:0.01:(N-1)*0.01;

for RTZ=1:length(T)

if T(RTZ)>=K && T(RTZ)<=M

P(RTZ)=ll(Z);

else if T(RTZ)>M && T(RTZ)<=Z

P(RTZ)=0;

else

Z=Z+1;
P a g e | 10
K=K+1;

M=M+1;

end

end

end

plot (T,P);

title('Alternate Mark Inversion');

P a g e | 11
Power:
A=1;
R=0;
SUM=0;
while(R<100)
F=randn(1,1000);
for j=1:length(F)
if F(j)>0
if A==1
ll(j)=1;
A=-1;
else
ll(j)=-1;
A=1;
end
else
ll(j)=0;
end
end
Z=1;
K=0;
M=0.5;
N=ceil(length(F)/0.01);
T=0:0.01:(N-1)*0.01;
for RTZ=1:length(T)
if T(RTZ)>=K && T(RTZ)<=M
P(RTZ)=ll(Z);
else if T(RTZ)>M && T(RTZ)<=Z
P(RTZ)=0;
else
Z=Z+1;
K=K+1;
M=M+1;
end
end
end
ff=fft(P);
Shff=fftshift(ff);
N=abs(Shff)/N;
SUM=SUM+(N).^2;
R=R+1;
end
dt=0.01;
fm=1/dt;
df = 1/length(F);
f = (-0.5*fm) : df : (0.5*fm - df);

P a g e | 12
plot (f,SUM/100);
title('Alternate Mark Inversion');

P a g e | 13
Frequency Domain:
A=1;
R=0;
SUM=0;
while(R<100)
F=randn(1,1000);
for j=1:length(F)
if F(j)>0
if A==1
ll(j)=1;
A=-1;
else
ll(j)=-1;
A=1;
end
else
ll(j)=0;
end
end
Z=1;
K=0;
M=0.5;
N=ceil(length(F)/0.01);
T=0:0.01:(N-1)*0.01;
for RTZ=1:length(T)
if T(RTZ)>=K && T(RTZ)<=M
P(RTZ)=ll(Z);
else if T(RTZ)>M && T(RTZ)<=Z
P(RTZ)=0;
else
Z=Z+1;
K=K+1;
M=M+1;
end
end
end
ff=fft(P);
Shff=fftshift(ff);
N=abs(Shff)/N;
SUM=SUM+(N);
R=R+1;
end
dt=0.01;
fm=1/dt;
df = 1/length(F);
f = (-0.5*fm) : df : (0.5*fm - df);

P a g e | 14
plot (f,SUM/100);
title('Alternate Mark Inversion');

P a g e | 15
Bonus Part
Polar Non-return to zero
In telecommunication, a 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.

Polar NRZ

The advantages
The advantages of Polar NRZ are:

 It is simple.
 No low-frequency components are present.
 Requires only half the baseband bandwidth required by the Manchester code

The disadvantages
The disadvantages of Polar NRZ are:

 no capability for error detection or error correction.


 It has nonzero Power spectral density (PSD) at dc (𝑓 = 0).
 No clock is present.

P a g e | 16
The bandwidth
The bandwidth for Polar non-return to
zero marked by the first null is halved
to 𝑅𝑏 Hz (where 𝑅𝑏 is the clock
frequency or bit rate).

The program code:


Time Domain:
clear

clc;

Random_Signal = randi([0,1],[1,64]);

for i = 1:length(Random_Signal)

if Random_Signal(i)>0

d(i) = 1;

else

d(i) = -1;

end

end

i = 1;

t = 0:0.01:length(Random_Signal);

for j = 1:length(t)

if t(j) <= i

y(j) = d(i);

else

y(j) = d(i);

i = i+1;

end

end

plot(t,y,'g');

xlabel('Time');

title('polar NRZ');

P a g e | 17
P a g e | 18
Power:
clear
clc;
Sum = 0;
h = 0;
while(h<400)
Random_Signal = randi([0,1],[1,1000]);
for i = 1:length(Random_Signal)
if Random_Signal(i)==1
d(i) = 1;
else
d(i) = -1;
end
end
i = 1;
N = ceil(length(Random_Signal)/0.01);
t = 0:0.01:(N-1)*0.01;
h=h+1;
for j = 1:length(t)
if t(j) <= i
y(j) = d(i);
else
y(j) = d(i);
i=i+1;
end
end
a = abs(fftshift(fft(y)))/N;
Sum = Sum+(a).^2;
end
fs = 1/0.01;
df = 1/length(Random_Signal);
f = -0.5*fs:df:0.5*fs-df;
plot(f,Sum/400);
xlabel('Power');
title('polar NRZ');

P a g e | 19
P a g e | 20
Frequency Domain:
clear
clc;
Sum = 0;
h = 0;
while(h<400)
Random_Signal = randi([0,1],[1,1000]);
for i = 1:length(Random_Signal)
if Random_Signal(i)==1
d(i) = 1;
else
d(i) = -1;
end
end
i = 1;
N = ceil(length(Random_Signal)/0.01);
t = 0:0.01:(N-1)*0.01;
h=h+1;
for j = 1:length(t)
if t(j) <= i
y(j) = d(i);
else
y(j) = d(i);
i=i+1;
end
end
a = abs(fftshift(fft(y)))/N;
Sum = Sum+(a);
end
fs = 1/0.01;
df = 1/length(Random_Signal);
f = -0.5*fs:df:0.5*fs-df;
plot(f,Sum/400);
xlabel('Frequency');
title('polar NRZ');

P a g e | 21
P a g e | 22

You might also like