You are on page 1of 6

EXPERIMENT – 2

Aim:

To study encoding and decoding of various line codes using MATLAB 7.6.0(R2008)

Theory:

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

Unipolar Non-Return to Zero (NRZ)

In this type of unipolar signal, 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.

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.
Bipolar NRZ/RZ

Bipolar return to zero: there is a half-width +ve output pulse if the input is a ‘1’; or a halfwidth -
ve output pulse if the input is a ‘0’. There is a return-to-zero for the second half of each bit
period. Bipolar not return to zero: there is full width alternate +ve/-ve output pulse if the input is
a ‘1’; or zero output pulse if the input is a ‘0’.

Alternate Mark Inversion (AMI)

Alternate Mark Inversion (AMI) AMI is a bipolar encoding system where neutral (zero) voltage
represents binary 0 and alternating positive and negative voltages represents binary 1. With this
line encoding it is the alternating voltages that determine the binary 1s.
Manchester line of code

In telecommunication and data storage, Manchester code is a line code in which the encoding of
each data bit is either low then high, or high then low, for equal time. It is a self-clocking signal
with no DC component. As a result, electrical connections using a Manchester code are easily
galvanically isolated

/* round(x) rounds each element of X to the nearest integer and rand(1,N) – generates an array of N
random numbers */

sign=1; // Signum function

Code: MATLAB (square function does not work in Octave)

r = round(rand(1, 10));

sign=1;

for i = 1:10

t = i:0.001:i+1-0.001;

if r(i)==1

nrz_unipolar = square(2*pi*t,100);

nrz_bipolar = square(2*pi*t,100);

rz_unipolar = (1+square(2*pi*t,100))/2;
rz_bipolar = (1+sign*square(2*pi*t,100))/2;

ami_nrz = sign*square(t*2*pi);

manchester = square(t*2*pi,50);

else

nrz_unipolar = 0;

nrz_bipolar = -(square(2*pi*t,100));

rz_unipolar = 0;

rz_bipolar = -(1+sign*square(2*pi*t,100))/2;

ami_nrz = 0;

manchester = -(square(2*pi*t,50));

end

subplot(6,1,1);

plot(t,nrz_unipolar,'red');

axis([1 11 , -1.5 1.5]);

xlabel('Time')

ylabel('Amplitude');

title('nrz_unipolar');

hold on;

grid on;

subplot(6,1,2);

plot(t,nrz_bipolar,'red');

axis([1 11 , -1.5 1.5]);

xlabel('Time')

ylabel('Amplitude');

title('nrz_bipolar');
hold on;

grid on;

subplot(6,1,3);

plot(t,rz_unipolar,'red');

axis([1 11 , -1.5 1.5]);

xlabel('Time')

ylabel('Amplitude');

title('rz_unipolar');

hold on;

grid on;

subplot(6,1,4);

plot(t,rz_bipolar,'red');

axis([1 11 , -1.5 1.5]);

xlabel('Time')

ylabel('Amplitude');

title('rz_bipolar');

hold on;

grid on;

subplot(6,1,5);

plot(t,ami_nrz,'red');

axis([1 11 , -1.5 1.5]);

xlabel('Time')

ylabel('Amplitude');

title('ami_nrz');

hold on;
grid on;

subplot(6,1,6);

plot(t,manchester,'red');

axis([1 11 -1.5 1.5]);

xlabel('Time')

ylabel('Amplitude');

title('manchester');

hold on;

grid on;

end

You might also like