Expt. No.
Aim: Line Codes generation and performance comparison
Equipment : PC, Scilab or Matlab or Python software.
Theory:
Introduction
Digital data can be transmitted by various Line codes. Line codes are waveform patterns of
voltage or current used to represent the 1s and 0s. Each line code has its advantages and
disadvantages. Among other desirable properties, a line code is preferred to have the following:
• Bandwidth efficiency; the possibility of transmitting at a higher rate than other schemes over the
same bandwidth.
• Power efficiency: For a given bandwidth and quality, the transmitted power should be as small as
possible.
• No DC component; this allows AC coupling (capacitor or transformer) between stages (as in
telephone lines).
• Spectrum shaping; this is important in telephone line applications, for example, where the
transfer characteristic has heavy attenuation below 300 Hz.
• Synchronization; where bit clock recovery can be simplified.
• Error detection capabilities; It should be possible to detect some patterns of errors.
Unipolar NRZ:
In NRZ line coding, logic 1 is represented by a non-zero voltage level, precisely a positive voltage
and logic 0 is indicated by a zero voltage level as shown in fig 5. The signal level does not return
to
zero for the entire bit interval during the transmission of a signal. In unipolar NRZ encoding, the
signal level remains constant throughout the bit-interval. The encoded signal has an undesirable
DC
component and lack of self synchronizing capabilities.
Polar NRZ
In this line code, a binary 1 is represented by a positive voltage +v and a binary 0 is represented
by a negative voltage -v over the full bit period. This code is also referred to as NRZ(L), since a bit
is represented by maintaining a level during its entire period. This code can also be represented
by assigning negative voltage for logic 1 and positive voltage for logic 0.
The advantage of polar NRZ includes a low-bandwidth requirements, very good error probability,
and great reduced DC because the waveform has a zero DC component. A major disadvantage of
this code that there is no error detection capability and that a long string of 1's or 0's could result in
loss of synchronization and power supplies are required to generate this code.
Bipolar NRZ:
In this scheme, a binary „1' is represented by positive and negative voltage levels in alternating
mark level in full bit period. A binary „0' is represented by a zero voltage levels during entire bit
duration. This code also called as alternate mark inversion (AMI) since 1's are represented by
alternating positive and negative pulses.
This code has no DC component and zero DC content, completely avoiding the DC wander
problem. Because of the alternative polarity pulses for binary 1's, this code has error detection and
hence correction also possible. A long string of 0's could result in loss of synchronization, and two
power supplies are required for this code.
Manchester Coding
In this scheme, a binary 1 is represented by a pulse that has positive voltage during the first-half of
the bit duration and negative voltage during second-half of the bit duration. A binary „0' is
represented by a pulse that has negative voltage during first-half of the bit duration and positive
voltage during second-half of the bit duration. The advantage of this code includes a zero DC
content and so avoiding DC-wandering problems. The code having alternation positive and
negative pulses and so timing recovery is simple and it has good error rate performance. The main
disadvantage of this scheme is larger bandwidth. It has no error detection possibility.
matlab program for line codes
%Unipolar NRZ Line Code
clc;
clear all;
N=10;
n=randi([0 1],1,N)
%Unipolar Mapping
for m=1:N
if n(m)==1
nn(m)=1;
else
nn(m)=0;
end
end
%Pulse shaping
i=1;
t=0:.01:length(n);
for j=1:length(t)
if t(j)<=i
y(j)=nn(i);
else
i=i+1;
y(j)=nn(i);
end
end
plot(t,y);
grid on;
axis([0 N -2 2]);
%polar NRZ Line Code
clc;
clear all;
N=10;
n=randi([0 1],1,N)
%Unipolar Mapping
for m=1:N
if n(m)==0
nn(m)=-1;
else
nn(m)=1;
end
end
%Pulse shaping
i=1;
t=0:.01:length(n);
for j=1:length(t)
if t(j)<=i
y(j)=nn(i);
else
i=i+1;
y(j)=nn(i);
end
end
plot(t,y);
grid on;
axis([0 N -2 2]);
%Bipolar NRZ Line Code
clc;
clear all;
N=10;
n=randi([0 1],1,N)
%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
%Pulse shaping
i=1;
t=0:.01:length(n);
for j=1:length(t)
if t(j)<=i
y(j)=nn(i);
else
i=i+1;
y(j)=nn(i);
end
end
plot(t,y);
grid on;
axis([0 N -2 2]);
% Manchester polar coding
clc;
clear all;
close all;
N=10;
n=randi([0 1],1,N)
%Binary to bipolar conversion
nnn=[];
for m=1:N
if n(m)==0;
nn=[-1 1];
else
nn=[1 -1];
end
nnn=[nnn nn];
end
%Pulse shaping
i=1;
l=0.5;
t=0:.01:length(n);
for j=1:length(t)
if t(j)<=l
y(j)=nnn(i);
else
y(j)=nnn(i);
i=i+1;
l=l+0.5;
end
end
plot(t,y);
grid on;
axis([0 N -2 2]);
Conclusion: