You are on page 1of 10

R.V.

COLLEGE OF ENGINEERING, BANGALORE-


560059
(Autonomous Institution Affiliated to VTU, Belgaum)

COMPUTER COMMUNICATION AND NETWORKS


(16CS55)

ASSIGNMENT

Topic: Given a stream of data bits (this is the input), you are required to produce a Polar RZ
Signal. Further convert it into Bipolar Pseudo ternary. Record your observations and obtain
the differences between the two schemes in terms of bit rate, baud rate, bandwidth, value of r.
Also, you are required to vary the above mentioned parameters and record the results (for eg.
increase the bit rate and observe how the waveform changes). Plot graphs to substantiate your
recorded observations.
Submitted by

HRITHIK M R 1RV17CS061
H RAMESH 1RV17CS057

Under the guidance of

Prof Praveena T.
Assistant Professor

Submitted to

COMPUTER SCIENCE AND ENGINEERING DEPARTMENT


R.V.College of Engineering, Bangalore-59
1. INTRODUCTION
Data as well as signals that represents data can either be digital or analog. Line coding is the
process of converting digital data to digital signals. By this technique we converts a sequence
of bits to a digital signal. At the sender side digital data are encoded into a digital signal and
at the receiver side the digital data are recreated by decoding the digital signal.
We can roughly divide line coding schemes into five categories:
1. Unipolar (eg. NRZ scheme).
2. Polar (eg. NRZ-L, NRZ-I, RZ, and Biphase – Manchester and differential Manchester).
3. Bipolar (eg. AMI and Pseudoternary).
4. Multilevel
5. Multitransition

2. CONCEPT
Polar schemes –
In polar schemes, the voltages are on the both sides of the axis.

 NRZ-L and NRZ-I – These are somewhat similar to unipolar NRZ scheme but here we
use two levels of amplitude (voltages). For NRZ-L(NRZ-Level), the level of the
voltage determines the value of the bit, typically binary 1 maps to logic-level high, and
binary 0 maps to logic-level low, and for NRZ-I(NRZ-Invert), two-level signal has a
transition at a boundary if the next bit that we are going to transmit is a logical 1, and
does not have a transition if the next bit that we are going to transmit is a logical 0.

 For NRZ-I we are assuming in the example that previous signal before starting of data
set “01001110” was positive. Therefore, there is no transition at the beginning and first
bit “0” in current data set “01001110” is starting from +V. Example: Data = 01001110.

Comparison between NRZ-L and NRZ-I: Baseline wandering is a problem for both of
them, but for NRZ-L it is twice as bad as compared to NRZ-I. This is because of
transition at the boundary for NRZ-I (if the next bit that we are going to transmit is a
logical 1). Similarly self-synchronization problem is similar in both for long sequence
of 0’s, but for long sequence of 1’s it is more severe in NRZ-L.
 Return to zero (RZ) – One solution to NRZ problem is the RZ scheme, which uses
three values positive, negative and zero. In this scheme signal goes to 0 in the middle of
each bit.

The logic we are using here to represent data is that for bit 1 half of the signal is represented
by +V and half by zero voltage and for bit 0 half of the signal is represented by -V and half
by zero voltage. Example: Data = 01001.

Bipolar schemes –

In this scheme there are three voltage levels 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.

 Alternate Mark Inversion (AMI) – A neutral zero voltage represents binary 0. Binary
1’s are represented by alternating positive and negative voltages.

 Pseudo ternary – Bit 1 is encoded as a zero voltage and the bit 0 is encoded as
alternating positive and negative voltages i.e., opposite of AMI scheme. Example: Data
= 010010.

The bipolar scheme is an alternative to NRZ.This scheme has the same signal rate as
NRZ,but there is no DC component as one bit is represented by voltage zero and other
alternates every time.
3. SOURCE CODE
1) main.m

n = input('Enter number of bits : ');


stream_bits = input('Enter the bits (within single quotes ('''')) : ');

bit_rate1 = 0; % Polar RZ
bit_rate2 = 0; % Bipolar Pseoduternary

bit_rate = 0;
baud_rate = 0;
band_width = 0;

ch = input('\nChoose a parameter\n1. Bit Rate\n2. Baud Rate\n3. Bandwidth\nEnter your


choice : ');
if ch==1
bit_rate = input('\nEnter the bit rate : ');
bit_rate1 = bit_rate;
bit_rate2 = bit_rate;
elseif ch==2
baud_rate = input('\nEnter the baud rate : ');
bit_rate1 = baud_rate;
bit_rate2 = 2*baud_rate;
elseif
ch==3
band_width = input('\nEnter the bandwidth rate : ');
bit_rate1 = band_width;
bit_rate2 = 2*band_width;
else
fprintf('\nInvalid input... Chosing default values\n');
end

fs = 10000; %step value


x = zeros(1, n*fs +2);
y1 = zeros(1, n*fs +2);
y2 = zeros(1, n*fs +2);

% X values
for i = 0:(n*fs)
x(i+2) = i/fs;
end

% Y1 values
y1(1) = 0;
y1(n*fs +2) = 0;
for i = 0:(n*fs -1)
if i/fs - floor(i/fs) >= 0.5
y1(i+2) = 0;
else
if stream_bits(floor(i/fs) +1) - '0' == 0
y1(i+2) = -1;
else
y1(i+2) = 1;
end
end
end

% Y2 values
y2(1) = 0;
y2(n*fs +2) = 0;
prev = -1;

for i = 0:(n*fs -1)


if stream_bits(floor(i/fs) +1) - '0' == 0
if mod(i,fs) == 0
if prev == -1
prev = 1;
else
prev = -1;
end
end
y2(i+2) = prev;
else
y2(i+2) = 0;
end
end

default(x,y1,y2,n,stream_bits);
user(x,y1,y2,n,fs,bit_rate1,bit_rate2,stream_bits);

2) default.m

function isDefaultPlotted = default(x,y1,y2,n,stream_bits)

isDefaultPlotted = 0;
% Plotting Polar RZ --------------------------------------------

subplot(2, 2, 1)
plot(x, y1)
axis([-0.1, n+0.7*n, -1.2, 1.7])
xlabel('Time (sec)')
ylabel('Amplitude')
title('Polar RZ (Default)')

% Printing info
text(n+0.2, 1.0, 'r = 0.5')
text(n+0.2, 0.5, 'Bit Rate = 1.0 bps')
text(n+0.2, 0.0, 'Baud Rate = 1.0 baud')
text(n+0.2, -0.5, 'Bandwidth = 1.0 bps')

for i = 0:(n-1)
text(i+0.5, 1.2, stream_bits(i+1))
end

% Plotting Bipolar Pseudoternary -------------------------------

subplot(2, 2, 3)
plot(x, y2)
axis([-0.1, n+0.7*n, -1.2, 1.7])
xlabel('Time (sec)')
ylabel('Amplitude')
title('Bipolar Pseudoternary (Default)')

% Printing info
text(n+0.2, 1.0, 'r = 1.0')
text(n+0.2, 0.5, 'Bit Rate = 1.0 bps')
text(n+0.2, 0.0, 'Baud Rate = 0.5 baud')
text(n+0.2, -0.5, 'Bandwidth = 0.5 bps')

for i = 0:(n-1)
text(i+0.5, 1.2, stream_bits(i+1))
end

isDefaultPlotted = 1;
end

3) user.m

function isUserChoicePlotted = user(x,y1,y2,n,fs,bit_rate1,bit_rate2,stream_bits)

isUserChoicePlotted = 0;
% Plotting Polar RZ --------------------------------------------

% X values
for i = 0:(n*fs)
x(i+2) = i/fs/bit_rate1;
end

subplot(2, 2, 2)
plot(x, y1)
axis([-0.1, n/bit_rate1+0.7*n/bit_rate1, -1.2, 1.7])
xlabel('Time (sec)')
ylabel('Amplitude')
title('Polar RZ (User choice)')

% Printing info
text(n/bit_rate1+0.2/bit_rate1, 1.0, 'r = 0.5')
text(n/bit_rate1+0.2/bit_rate1, 0.5, strcat(strcat('Bit Rate = ', num2str(bit_rate1)), ' bps'))
text(n/bit_rate1+0.2/bit_rate1, 0.0, strcat(strcat('Baud Rate = ', num2str(bit_rate1)), ' baud'))
text(n/bit_rate1+0.2/bit_rate1, -0.5, strcat(strcat('Bandwidth = ', num2str(bit_rate1)), ' bps'))

for i = 0:(n-1)
text(i/bit_rate1+0.3/bit_rate1, 1.2, stream_bits(i+1))
end

% Plotting Bipolar Pseudoternary -------------------------------

% X values
For i = 0 :(n*fs)
x(i+2) = i/fs/bit_rate2;
end

subplot(2, 2, 4)
plot(x, y2)
axis([-0.1, n/bit_rate2+0.7*n/bit_rate2, -1.2, 1.7])
xlabel('Time (sec)')
ylabel('Amplitude')
title('Bipolar Pseudoternary (User choice)')

% Printing info
text(n/bit_rate2+0.2/bit_rate2, 1.0, 'r = 1.0')
text(n/bit_rate2+0.2/bit_rate2, 0.5, strcat(strcat('Bit Rate = ', num2str(bit_rate2)), '
bps'))
text(n/bit_rate2+0.2/bit_rate2, 0.0, strcat(strcat('Baud Rate = ', num2str(bit_rate2/2)), '
baud'))
text(n/bit_rate2+0.2/bit_rate2, -0.5, strcat(strcat('Bandwidth = ', num2str(bit_rate2/2)),
' bps'))

for i = 0:(n-1)
text(i/bit_rate2+0.3/bit_rate2, 1.2, stream_bits(i+1))
end

isUserChoicePlotted = 1;

end

Screenshots:

A] INPUTS:
B] OUTPUTS:

5. APPENDIX
Communications Toolbox supports general linear block codes. It also process cyclic,

BCH, Hamming, and Reed-Solomon codes (which are all special kinds of linear block
codes). Blocks in the product can encode or decode a message. The blocks and functions
in Communications Toolbox are designed for error-control codes that use an alphabet

having 2 or 2m symbols.

Communications Toolbox Support Functions: Functions in Communications Toolbox


can support simulation blocks by

Determining characteristics of a technique, such as error-correction capability


or possible message lengths

Performing lower-level computations associated with a technique, such as

o Computing a truth table

o Computing a generator or parity-check matrix

o Converting between generator and parity-check matrices


6. REFERENCES

[1] Berlekamp, Elwyn R., Algebraic Coding Theory, New York, McGraw-Hill, 1968.

[2] Using The Matlab Communications Toolbox To Look At Cyclic Coding,Wm. Hugh
Blanton East Tennessee State University

[3] MATLAB Examples: Linear Block Codes, Henry D. Pfister ECE Department Texas
A&M University

[4] Peterson, W. Wesley, and E. J. Weldon, Jr., Error-Correcting Codes, 2nd ed.,
Cambridge, MA, MIT Press, 1972.

[5] van Lint, J. H., Introduction to Coding Theory, New York, Springer-Verlag, 1982.

[6] Wicker, Stephen B., Error Control Systems for Digital Communication and Storage,
Upper Saddle River, NJ, Prentice Hall, 1995.

You might also like