0% found this document useful (0 votes)
64 views9 pages

Arif DC Lab-Report-02

Uploaded by

Emran Al Arif
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
64 views9 pages

Arif DC Lab-Report-02

Uploaded by

Emran Al Arif
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Green University of Bangladesh

Department of Computer Science and Engineering (CSE)


Faculty of Sciences and Engineering
Semester: (Spring, Year:2024), B.Sc. in CSE (Day)

LAB REPORT NO -04


Course Title: Data Communication lab Course
Code: CSE-308 Section: 221-D4

Lab Experiment Name: Implementing encoding and decoding scheme using NRZ-L and NRZ-I,
Implementing encoding and decoding scheme using Manchester and differential Manchester,
Implementing encoding and decoding scheme using AMI and Pseudo ternary

Student Details

Name ID

1. Md Arif Billah 221002520

Submission Date : 22-05-2024


CourseTeacher’s Name : Sakhaouth Hossan

[For Teachers use only: Don’t Write Anything inside this box]

Lab Report Status Marks: …………………………………

Signature:.....................
1.TITLE OF THE LAB EXPERIMENT:
Implementing encoding and decoding scheme using NRZ-L and NRZ-I, Implementing encoding and
decoding scheme using Manchester and differential Manchester, Implementing encoding and
decoding scheme using AMI and Pseudo ternary

2.OBJECTIVES:
NRZ-L and NRZ-I Encoding and Decoding:
To comprehend the principles behind Non-Return-to-Zero Level (NRZ-L) and Non-Return-to-Zero
Inverted (NRZ-I) encoding schemes.
To implement NRZ-L and NRZ-I encoding techniques, where binary 1 is represented by a high or
inverted state, respectively, and binary 0 is represented by a low state.
To develop decoding algorithms to retrieve the original bitstream from the encoded signals,
considering the differences in encoding methods between NRZ-L and NRZ-I.

Manchester and Differential Manchester Encoding and Decoding:


To grasp the concepts of Manchester and Differential Manchester encoding techniques.
To implement Manchester and Differential Manchester encoding, where transitions occur at the
midpoint of each bit period or based on the polarity of the previous bit, respectively.
To design decoding algorithms for both Manchester and Differential Manchester encoding, ensuring
accurate retrieval of the original data from the received signals.

AMI and Pseudo Ternary Encoding and Decoding:


To understand Alternate Mark Inversion (AMI) and Pseudo Ternary encoding methods.
To implement AMI and Pseudo Ternary encoding schemes, where binary 1s are represented by
alternating voltage levels or by transitions, respectively.
To develop decoding algorithms for AMI and Pseudo Ternary encoding, focusing on accurately
decoding the original bitstream while considering the differences in encoding techniques.

3.IMPLEMENTATION:
Code 1:

% Encoding

bits = [1 0 1 1 1 0 0 1]; % Define the bitstream


bitrate = 1; % Bit rate (bits per second)

n = 1000; % Sampling rate per bit

T = length(bits) / bitrate; % Total time for the bitstream

N = n * length(bits); % Total number of sample points

dt = T / N; % Time increment per sample

t = 0:dt:T; % Time domain array

x = zeros(1, length(t)); % Amplitude domain array

lastbit = 1; % Initialize previous bit

for i = 1:length(bits)

if bits(i) == 1

x((i - 1) * n + 1:i * n) = lastbit;

else

x((i - 1) * n + 1:i * n) = -lastbit;

end

end

plot(t, x, 'Linewidth', 3); % Plot the encoded signal

% Decoding

counter = 0; % Initialize bit counter

lastbit = 1; % Initialize previous bit

for i = 1:length(t)

if t(i) > counter

counter = counter + 1;

if x(i) ~= lastbit

result(counter) = 1;

lastbit = -lastbit;
else

result(counter) = 0;

end

end

end

disp('NRZ-L Decoding:');

disp(result);

Code 2:

#include <stdio.h>

#include <stdint.h>

void binaryToDecimalIP(uint32_t binaryIP) {

uint8_t firstOctet = (binaryIP >> 24) & 0xFF;

uint8_t secondOctet = (binaryIP >> 16) & 0xFF;

uint8_t thirdOctet = (binaryIP >> 8) & 0xFF;

uint8_t fourthOctet = binaryIP & 0xFF;

printf("Dotted Decimal IP: %d.%d.%d.%d\n", firstOctet, secondOctet, thirdOctet, fourthOctet);

int main() {

uint32_t binaryIP = 0b11000000101010000000000100000000;

binaryToDecimalIP(binaryIP);

return 0;

Code 3:
% Implementing Encoding and Decoding Scheme Using Pseudo ternary

% Predefined bitstream for Pseudo ternary encoding

bits = [1 0 1 1 1 0 0 1];

% Define parameters

bitrate = 1;

n = 1000;

T = length(bits) / bitrate;

N = n * length(bits);

dt = T / N;

t = 0:dt:T;

x = zeros(1, length(t));

lastbit = 1;

% Pseudo ternary encoding

for i = 1:length(bits)

if bits(i) == 1

% If bit is 1, encode as opposite voltage level

x((i-1)*n+1:i*n) = -lastbit;

lastbit = -lastbit;

else

% If bit is 0, encode as 0 (no change)

x((i-1)*n+1:i*n) = 0;

end

end

% Plotting the encoded signal

plot(t, x, 'Linewidth', 3);

title('Pseudo ternary Encoding');


xlabel('Time');

ylabel('Amplitude');

% Decoding

counter = 0;

lastbit = 1;

result = zeros(1, length(bits));

% Decoding the signal

for i = 1:length(t)

if t(i) > counter

counter = counter + 1;

if x(i) == -lastbit

result(counter) = 1;

lastbit = -lastbit;

else

result(counter) = 0;

end

end

end

% Displaying the decoded result

disp('Pseudo ternary Decoding:');

disp(result);

Output
Output 1:
Output 2:

Output 3:
6.ANALYSIS AND DISCUSSION:
NRZ-L and NRZ-I Encoding and Decoding:
In our exploration, we encountered Non-Return-to-Zero Level (NRZ-L) and Non-Return-to-Zero
Inverted (NRZ-I) encoding schemes. NRZ-L, characterized by fixed voltage levels for 1s and 0s,
offers simplicity but is vulnerable to baseline wander. Conversely, NRZ-I introduces transitions for 1s,
aiding synchronization, yet may pose challenges in sequences devoid of transitions.

Manchester and Differential Manchester Encoding and Decoding:


Our journey led us to Manchester and Differential Manchester encoding techniques, both ensuring
regular transitions for clock recovery. Manchester encoding, with its mid-bit transitions, promises
robust synchronization but at the cost of increased bandwidth. Meanwhile, Differential Manchester
encoding, while reducing the need for an external clock, demands more intricate decoding algorithms.

AMI and Pseudo Ternary Encoding and Decoding:


Another intriguing stop was at Alternate Mark Inversion (AMI) and Pseudo Ternary encoding
methods, aimed at minimizing the DC component in transmitted signals. AMI's alternating voltage
levels offer reduced baseline wander but necessitate additional synchronization efforts. On the other
hand, Pseudo Ternary encoding simplifies clock recovery but may falter in noisy environments.

7.SUMMARY:
Our laboratory experiment delved into the intricacies of encoding and decoding techniques crucial for
data communication systems. We explored a range of methods including NRZ-L, NRZ-I,
Manchester, Differential Manchester, AMI, and Pseudo Ternary encoding schemes.

NRZ-L and NRZ-I encoding methods represented binary data using fixed voltage levels or
transitions, respectively. Manchester and Differential Manchester encoding introduced transitions for
clock recovery, with Manchester encoding offering robust synchronization but requiring additional
bandwidth. AMI and Pseudo Ternary encoding aimed to minimize the DC component in transmitted
signals, with AMI utilizing alternating voltage levels and Pseudo Ternary encoding focusing on
simplified clock recovery.

Our analysis revealed the trade-offs inherent in each technique, balancing simplicity, synchronization,
bandwidth, and noise immunity. By understanding these nuances, we gained insights into designing
efficient communication systems adaptable to diverse scenarios.

In summary, our exploration provided a comprehensive understanding of encoding and decoding


techniques, empowering us to navigate the complexities of data communication and drive innovations
in the field.

You might also like