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

Line Coding

This document discusses line coding, which is the process of converting digital data to digital signals for transmission. It begins by introducing computer networks and digital/analog signal conversion. Then, it defines line coding and explains how digital data is encoded into a digital signal at the sender and decoded back at the receiver. Finally, it describes several common line coding schemes including unipolar NRZ, polar NRZ, Manchester encoding, and bipolar AMI coding. It provides implementation examples and discusses the advantages and disadvantages of each scheme.

Uploaded by

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

Line Coding

This document discusses line coding, which is the process of converting digital data to digital signals for transmission. It begins by introducing computer networks and digital/analog signal conversion. Then, it defines line coding and explains how digital data is encoded into a digital signal at the sender and decoded back at the receiver. Finally, it describes several common line coding schemes including unipolar NRZ, polar NRZ, Manchester encoding, and bipolar AMI coding. It provides implementation examples and discusses the advantages and disadvantages of each scheme.

Uploaded by

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

1.

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.

3. Line coding Schemes

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.

3.1.1 Unipolar NRZ (non-return to zero)

NRZ traditionally, a unipolar scheme was designed as a non-return-to-zero (NRZ) scheme in


which the positive voltage defines bit 1 and the zero voltage defines bit 0. It is called NRZ
because the signal does not return to zero at the middle of the bit. The following figure shows a
unipolar NRZ scheme.

Fig: Unipolar NRZ Scheme


Implementation
%NRZ Unipolar Line coding
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
%NRZ Pulse shaping
i=1;
t=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]);
Input : 1 1 0 1 1 0 0 1 1 1

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:

 There is a significant DC component, which means that power is wasted due to


heating of the wires in the transmission line. It also means that channel links
must be DC-coupled, because AC-coupled links will reject the signal's DC
component.

3.2 Polar scheme


In polar schemes, the voltages are on the both sides of the time axis. For example, the voltage
level for 0 can be positive and the voltage level for 1 can be negative. There are two types of
Polar NRZ scheme is present,

 Polar NRZ Level


 Polar NRZ Invert

3.2.1 Polar NRZ-Level (non-return-to-zero)

Non-return-to-zero-level (NRZ-L) is a data encoding scheme in which a negative voltage is used


to represent binary one and a positive voltage is used to represent binary zero.
Implementation
%NRZ polar Line coding
N=10;
n=randi([0 1],1,N);
%polar Mapping
for m=1:N
if n(m)==0
nn(m)=1;
else
nn(m)=-1;
end
end
%NRZ Pulse shaping
i=1;
t=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]);
Input: 0 1 1 0 1 0 0 1 1 1

Output:

1.5

0.5

-0.5

-1

-1.5

-2
0 1 2 3 4 5 6 7 8 9 10

3.2.2 Polar NRZ-I(non-return-to-zero-inversion)

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.

Fig: Polar NRZ-I scheme


Implementation
m = [0 1 0 0 1 1 1 0];
n = length(m);
x = [];
y = [];
a=1;
for i=1:n
x=[x i-1 i];
if(m(i)==1)
y=[y -a -a];
else
y=[y a a];
end
a=y(length(y));
end

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:

 Relatively simple to implement.


 Requires relatively low bandwidth.

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.

3.2.3 Polar Manchester (Return-to-Zero)

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

3.2.4 Polar Differential Manchester (Return-to-Zero)

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.

Fig: Differential Manchester scheme

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

3.3 Bipolar scheme


In bipolar scheme there are three voltage level: positive, negative and zero. The voltage level for
one data element is at zero, while the voltage level for the other element alternates between
positive and negative.

3.3.1 Alternate Mark Inversion (AMI Bi-Polar)

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:

 It has a synchronization problem when a long sequence of 0s is present in the


data.

3.3.2 Pseudoternary (Bi-polar)

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

3.4 Multiline Transmission: MLT3 (Three Level Multiple Transmission)

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.

The rules are basically as follows:

 If the next bit will be logic low (binary zero), there is no transition.


 If the next bit will be logic high (binary one), and the current signal level is non-
zero, then the signal will transition to zero.
 If the next bit will be logic high and the current signal level is zero, then the
signal will transition to a level that is the opposite of the most recent non-zero
signal level.
The behavior of MLT-3 can best be described by the state diagram shown in the following
figure. The three voltage levels (-V, 0, and +V) are shown by three states (ovals). The transition
from one state (level) to another is shown by the connecting lines. The following figure also
shows two examples of an MLT-3 signal.

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

After block coding is done, it is line coding for transmission.

4.1 4B/5B Block Coding

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:

 It solves problem of synchronization observed in NRZ-I.


 It offers signal rate less than Biphase scheme.

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.

You might also like