Line Coding
Line Coding
Introduction
A computer network is designed to send information from one point to another. This information
needs to be converted to either a digital signal or an analog signal for transmission. In
communication technology the advances require upgrading of the transmission of different types
of information such as audio, data, graphics and real time video. Line coding is an important
parameter of digital signal transmission. Digital to digital conversion is a line coding variation
which is used to convert digital data to digital signal.
2. Line coding
Line coding is the process of converting digital data to digital signals. We assume that data, in
the form of text, numbers, graphical images, audio, or video are stored in computer memory as
sequences of bits. Line coding converts a sequence of bits of bits to a digital signal. At the
sender, digital data are encoded into a digital signal; at the receiver, the digital data are recreated
by decoding the digital signal.
Unipolar
NRZ
Polar
NRZ-
L, NRZ-I
Line Coding Bipolar
AMI, Pseudoternary
Multilevel
2B/1Q
Multitransition
MLT-3
3.1 Unipolar Scheme
In a unipolar scheme, all the signal levels are on one side of the time axis, either above or below.
Unipolar signal is known as on-off keying. When 0 is transmitted it represents the presence of a
pulse. There are two types of unipolar signaling.
Output:
1.5
0.5
-0.5
-1
-1.5
-2
0 1 2 3 4 5 6 7 8 9 10
Advantage:
Simple to implement.
Requires relatively low bandwidth.
Disadvantage:
Output:
1.5
0.5
-0.5
-1
-1.5
-2
0 1 2 3 4 5 6 7 8 9 10
The second polar NRZ line coding scheme we will look at is called NRZ-invert (NRZ-I). Here,
the value of a bit is determined by the presence or absence of a transition from a positive voltage
to a negative voltage, or vice versa. A transition signals that the next bit is a logic high (binary
one), while no transition signals a logic low (binary zero). Note that in the illustration below, it is
assumed that the line voltage was positive immediately before the start of the bit sequence.
Because the first bit in the sequence is a binary zero, no transition occurs at the start of the
sequence.
plot(x,y);
axis([0,n,-2,2]);
title('Polar NRZ I');
Input: 0 1 0 0 1 1 1 0
Output:
Polar NRZ I
2
1.5
0.5
-0.5
-1
-1.5
-2
0 1 2 3 4 5 6 7 8
Advantage:
Disadvantage:
Baseline wandering (see above) is a problem for both polar NRZ-L and polar
NRZ-I when long sequences of zeros occur. The effect is twice as likely to
occur in polar NRZ-L, where long sequences of ones can also cause baseline
wandering.
The idea of RZ (transition at the middle of the bit) and the idea of NRZ-L are combined into the
Manchester scheme.
In Manchester encoding, the duration of the bit is divided into two halves. The voltage remains at
one level during the first half and moves to the other level in the second half. The transition at
the middle of the bit provides synchronization.
Fig: Manchester scheme
Implementation
clear;
%Manchester polar line coding
N=6;
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 shapping
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);
axis([0 N -2 2]);
Input: 1 0 1 1 1 1
Output:
1.5
0.5
-0.5
-1
-1.5
-2
0 1 2 3 4 5 6
Differential Manchester, on the other hand, combines the ideas of RZ and NRZ-I. There is
always a transition at the middle of the bit, but the bit values are determined at the beginning of
the bit. If the next bit is 0, there is a transition; if the next bit is 1, there is none. Differential
Manchester overcomes several problems associated with NRZ-I. First, there is no baseline
wandering. There is no DC component because each bit has a positive and negative voltage
contribution.
Differential Manchester encoding addresses the problems associated with NRZ-I coding, and
essentially has the same advantages and disadvantages as Manchester encoding. There is no DC
component in the signal, baseline wandering is not a problem, and the embedded timing
engendered by the presence of at least one transition per bit time ensures that the receiver can
maintain synchronization. There is also the added advantage that if the signal is inverted
somewhere along the transmission path, the information carried by the line-coded signal will not
change.
Implementation
m = [1 0 0 0 0 1];
n = length(m);
x = [];
y = [];
a = 1;
for i=1:n
x=[x i-1 i-1+0.5 i-1+0.5 i];
if(m(i)==0)
y=[y -a -a a a];
else
y=[y a a -a -a];
end
a=y(length(y));
end
plot(x,y),axis([0,n,-2,2]);
title('Differential Manchester');m = [1 0 0 0 0 1];
n = length(m);
x = [];
y = [];
a = 1;
for i=1:n
x=[x i-1 i-1+0.5 i-1+0.5 i];
if(m(i)==0)
y=[y -a -a a a];
else
y=[y a a -a -a];
end
a=y(length(y));
end
plot(x,y),axis([0,n,-2,2]);
title('Differential Manchester');
Output:
Differential Manchester
2
1.5
0.5
-0.5
-1
-1.5
-2
0 1 2 3 4 5 6
Like polar RZ, bipolar line coding schemes (sometimes called multi-level binary or duo-binary)
use three voltage levels - positive, negative and zero. That, however, is pretty much where the
similarity ends. Bipolar alternate mark inversion (AMI) uses alternate positive and negative
voltages to represent logic high (binary one), and a zero voltage to represent logic low (binary
zero). Although AMI is technically an NRZ line coding scheme itself, it was developed as an
alternative to other NRZ schemes in which long runs of ones or zeros introduced a DC-
component into the signal.
Implementation
m = [1 1 0 0 1 1];
n = length(m);
x = [];
y = [];
a=1;
for i=1:n
x=[x i-1 i];
if(m(i)== 1)
y=[y a a];
a=a*(-1);
else
y=[y 0 0];
end
end
plot(x,y),axis([0,n,-2,2]);
title('Bipolar AMI');
Output:
Bipolar AMI
2
1.5
0.5
-0.5
-1
-1.5
-2
0 1 2 3 4 5 6
Advantage:
No DC component.
Less bandwidth than unipolar and polar RZ schemes.
It is common used for long distance communication.
Disadvantage:
The pseudoternary version of bipolar line coding is essentially identical to AMI except that logic
high is represented by a zero voltage and logic low is represented by alternate positive and
negative voltages - the exact opposite of what happens with AMI.
The advantages and disadvantages of pseudoternary line coding are the same as for AMI with the
single exception that, rather than long sequences of zeros, it is long sequences of ones that can
cause the receiver to lose synchronization.
Implementation
m = [1 1 0 1 0 0];
n = length(m);
x = [];
y = [];
a=1;
for i=1:n
x=[x i-1 i];
if(m(i)== 0)
y=[y a a];
a=a*(-1);
else
y=[y 0 0];
end
end
plot(x,y),axis([0,n,-2,2]);
title('Bipolar Pseudoternary / opposite of AMI');
Output:
Bipolar Pseudoternary / opposite of AMI
2
1.5
0.5
-0.5
-1
-1.5
-2
0 1 2 3 4 5 6
MLT-3 (multi-level transmit) is, like polar NRZ-I and differential Manchester, a differential line
coding scheme. The "3" in the name reflects the fact that, whereas both of the aforementioned
schemes use only two signal levels (positive and negative) to represent binary values, MLT-3
uses three levels (positive, negative and zero). It is also classed as a multi-level encoding
scheme, because it uses more than two levels to represent binary data.
A non-periodic signal has changed to a periodic signal with the period equal to 4 times the bit
duration. This worst-case situation can be simulated as an analog signal with a frequency one-
fourth of the bit rate. In other words, the signal rate for MLT-3 is one-fourth the bit rate. This
makes MLT-3 a suitable choice when we need to send 100 Mbps on a copper wire that cannot
support more than 32 MHz (frequencies above this level create electromagnetic emissions).
4. Block Coding
We need redundancy to ensure synchronization and to provide some kind of inherent error
detecting. Block coding can give us this redundancy and improve the performance of line coding.
To ensure accuracy of the received data frame redundant bits are used. For example, in even-
parity, one parity bit is added to make the count of 1s in the frame even. This way the original
number of bits is increased. It is called Block Coding.
Block coding is represented by slash notation, mB/nB. Means, m-bit block is substituted with n-
bit block where n > m. Block coding involves three steps:
Division
Substitution
Combination
The four binary/five binary (4B/5B) coding scheme was designed to be used in combination with
NRZ-I. Recall that NRZ-I has a good signal rate, one-half that of the bi-phase, but it has a
synchronization problem. A long sequence of ‘0’s can make the receiver clock lose
synchronization. One solution is to change the bit stream, prior to encoding with NRZ-I, so that
it does not have a long stream of 0s. The 4B/5B scheme achieves this goal. The block-coded
stream does not have more than three consecutives ‘0’s. At the receiver, the NRZ-I encoded
digital signal is first decoded into a stream of bits and then decoded to remove the redundancy. In
4B/5B, the 5-bit output replaces the 4-bit input has no more than one leading zero (left bit) and
no more than two trailing zeros (right bits). So, when different groups are combined to make a
new sequence, there are never more than three consecutives ‘0’s.
The following figure shows an example of substitution in 4B/5B coding. 4B/5B encoding solves
the problem of synchronization and overcomes one of the deficiencies of NRZ- I. However, we
need to remember that it increases the signal rate of NRZ-1. The redundant bits add 20 percent
more baud. Still, the result is less than the bi-phase scheme which has a signal rate of 2 times that
of NRZ-1.
Advantage:
Disadvantage:
It increases signal rate compare to NRZ-I as redundant bits add 20% more baud.
It does not eliminate DC components found in NRZ-I signal waveforms.
4.2 8B/10B Block Coding
The eight binary/ten binary (8B10B) encoding is similar to 4B/5B encoding except that a group
of 8 bits of data is now substituted by a 10-bit code. It provides greater error detection capability
than 4B/5B. The 8BIlOB block coding is actually a combination of 5B/6B and 3B/4B encoding,
as shown in the following figure.
The most five significant bits of a 10-bit block is fed into the 5B/6B encoder and the least 3
significant bits is fed into a 3B/4B encoder. The split is done to simplify the mapping table. To
prevent a long run of consecutive 0s or 1s, the code uses a disparity controller which keeps track
of excess 0s over Is (or 1s over 0s).
A group of 8 bits can have 2^8 different combinations while a group of 10 bits can have 2^10
different combinations. This means that there is 2^10-2^8=768 redundant groups that are not
used for 8B/10B encoding and can be used for error detection and disparity check.