Lab 4 Line Coding Techniques

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 10

Data Communication and Networking Lab Manual CPE314

Lab 4: Line Coding Techniques


Objective:

The objective of this lab is implementation of line coding techniques using Matlab.

Introduction:

A line code is the code used for data transmission of a digital signal over a transmission line.

Types of Line Coding


There are 3 types of Line Coding

1. Unipolar
2. Polar
3. Bi-polar

1. UnipolarSignaling
Unipolar signaling is also called as On-Off Keying or simply OOK.

The presence of pulse represents a 1 and the absence of pulse represents a 0.

There are two variations in Unipolar signaling −

 Non Return to Zero (NRZ)


 Return to Zero (RZ)
Unipolar Non-Return to Zero (NRZ)
In this type of unipolar signaling, a High in data is represented by a positive pulse called as Mark,
which has a duration T0 equal to the symbol bit duration. A Low in data input has no pulse.

The following figure clearly depicts this.

1 CIIT Attock Campus


Data Communication and Networking Lab Manual CPE314

Advantages

The advantages of Unipolar NRZ are −

 It is simple.
 A lesser bandwidth is required.
Disadvantages

The disadvantages of Unipolar NRZ are −

 No error correction done.

 Presence of low frequency components may cause the signal droop.

 No clock is present.

 Loss of synchronization is likely to occur (especially for long strings of 1s and 0s).

Unipolar Return to Zero (RZ)


In this type of unipolar signaling, a High in data, though represented by a Mark pulse, its
duration T0 is less than the symbol bit duration. Half of the bit duration remains high but it
immediately returns to zero and shows the absence of pulse during the remaining half of the bit
duration.

It is clearly understood with the help of the following figure.

2 CIIT Attock Campus


Data Communication and Networking Lab Manual CPE314

Advantages

The advantages of Unipolar RZ are −

 It is simple.
 The spectral line present at the symbol rate can be used as a clock.
Disadvantages

The disadvantages of Unipolar RZ are −

 No error correction.
 Occupies twice the bandwidth as unipolar NRZ.
 The signal droop is caused at the places where signal is non-zero at 0 Hz.
2. PolarSignaling
There are two methods of Polar Signaling. They are −

 Polar NRZ
 Polar RZ
Polar NRZ
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. The following figure depicts this well.

3 CIIT Attock Campus


Data Communication and Networking Lab Manual CPE314

Advantages

The advantages of Polar NRZ are −

 It is simple.
 No low-frequency components are present.
Disadvantages

The disadvantages of Polar NRZ are −

 No error correction.

 No clock is present.

 The signal droop is caused at the places where the signal is non-zero at 0 Hz.

Polar RZ
In this type of Polar signaling, a High in data, though represented by a Mark pulse, its duration T0 is
less than the symbol bit duration. Half of the bit duration remains high but it immediately returns
to zero and shows the absence of pulse during the remaining half of the bit duration.

However, for a Low input, a negative pulse represents the data, and the zero level remains same for
the other half of the bit duration. The following figure depicts this clearly.

4 CIIT Attock Campus


Data Communication and Networking Lab Manual CPE314

Advantages

The advantages of Polar RZ are −

 It is simple.
 No low-frequency components are present.
Disadvantages

The disadvantages of Polar RZ are −

 No error correction.

 No clock is present.

 Occupies twice the bandwidth of Polar NRZ.

 The signal droop is caused at places where the signal is non-zero at 0 Hz.

3. BipolarSignaling
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 1sto be of equal polarity. A 0 will have a zero
voltage level.

Even in this method, we have two types.

5 CIIT Attock Campus


Data Communication and Networking Lab Manual CPE314

 Bipolar NRZ
 Bipolar RZ
From the models so far discussed, we have learnt the difference between NRZ and RZ. It just goes in
the same way here too. The following figure clearly depicts this.

The above figure has both the Bipolar NRZ and RZ waveforms. The pulse duration and symbol bit
duration are equal in NRZ type, while the pulse duration is half of the symbol bit duration in RZ
type.

Advantages
Following are the advantages −

 It is simple.

 No low-frequency components are present.

 Occupies low bandwidth than unipolar and polar NRZ schemes.

 This technique is suitable for transmission over AC coupled lines, as signal drooping doesn’t
occur here.

 A single error detection capability is present in this.

6 CIIT Attock Campus


Data Communication and Networking Lab Manual CPE314

Disadvantages
Following are the disadvantages −

 No clock is present.
 Long strings of data cause loss of synchronization.

Programming:

close all;
clear all;
clc;

% Title: Implementation of various Line Coding Schemes


% Unipolar RZ, Polar RZ.
%
% INPUT:
% inbits = input bits row vector
% Tb = Bit time period
% A = Amplitude of the coding
% Ts = Sampling time
% OUTPUT:
% x = Output line coding row vector
% T = time vector

A = 1;
Tb = 1;
inbits = [1 0 1 0 1 1 0 0 1 0];

%---Implementation starts here


Rb = 1/Tb; %---Bit rate
Fs = 4*Rb; %---Sampled frequency
N = length(inbits); %---Bit Length of input bits
tTb = linspace(0,Tb) %---interval of bit time period

% Unipolar NRZ
x=[];
for k = 1:N
x = [x A*inbits(k)*ones(1,length(tTb))];
end
T = linspace(0,N*Tb,length(x)); %---Time vector for n bits
subplot(3,1,1);
plot(T,x);
title('Unipolar NRZ');
axis([0 10 -0.25 1.25]);

% Polar RZ
x2=[];

7 CIIT Attock Campus


Data Communication and Networking Lab Manual CPE314

for k2 = 1:N
c = ones(1,length(tTb)/2);
b = zeros(1,length(tTb)/2);
p = [c b];
x2 = [x2 ((-1)^(inbits(k2)+1))*(A/2)*p];
end
T2 = linspace(0,N*Tb,length(x2)); %---Time vector for n bits
subplot(3,1,2);
plot(T2,x2);
title('Polar RZ');
axis([0 10 -0.75 0.75]);

8 CIIT Attock Campus


Data Communication and Networking Lab Manual CPE314

Lab Tasks

In-Lab Task 1:

Implement Polar NRZ-L for bit stream [1 0 1 0 1 1 0 0 1 0]


.

Post-Lab Task 1:

Implement Polar Biphase Manchester for bit stream [0 0 1 1 1 1 0 0 1 0]

Objective:
In this lab we learn that
 We learn that biphase Manchester.
 We learn that polar NZ.

Result and Discussions:

Task 1:

9 CIIT Attock Campus


Data Communication and Networking Lab Manual CPE314

Task 2:

10 CIIT Attock Campus

You might also like