0% found this document useful (0 votes)
8 views12 pages

Datalastlab

lab

Uploaded by

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

Datalastlab

lab

Uploaded by

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

INSTITUTE OF ENGINEERING

ADVANCED COLLEGE OF ENGINEERING


AND MANAGEMENT
KALANKI, KATHMANDU
(AFFILIATED TO TRIBHUVAN UNIVERSITY)

LAB REPORT

SUBJECT: Data Communication

LAB NO: 04&05

SUBMITTED BY: SUBMITTEDTO:

NAME: Sandeep Bhusal Department of computer


and electronics engineering
ROLL NO: ACE078BCT061

DATE: 2080/03/26
LAB 4: DIGITAL MODULATION: ASK/PSK/FSK
OBJECTIVES:
• To learn about digital modulation.
• To implement ASK, PSK, FSK in MATLAB.

THEORY:

Digital Modulation is the process of varying a carrier signal in order to


transmit data. The three common types of digital modulation techniques are
Amplitude Shift Keying (ASK), Phase Shift Keying (PSK), and Frequency
Shift Keying (FSK).

1. Amplitude Shift Keying (ASK):

• In ASK, the amplitude (height) of the carrier wave changes to represent


binary data.
• For binary 1, the carrier signal is transmitted at a higher amplitude.
• For binary 0, the carrier signal is transmitted at a lower amplitude or
zero.

2. Phase Shift Keying (PSK):

• In PSK, the phase of the carrier wave changes to represent binary data.
• Each phase shift represents a different binary value.
• Common types of PSK include Binary PSK (BPSK) where two phases
are used, and Quadrature PSK (QPSK) where four phases are used.

3. Frequency Shift Keying (FSK):

• In FSK, the frequency of the carrier wave changes to represent binary


data.
• For binary 1, the carrier signal is transmitted at one frequency.
• For binary 0, the carrier signal is transmitted at a different frequency.
%CONSTRUCT AN ASK MODULATED SIGNAL

clc;
close all;

fc=input('enter freq. of sine wave');


fp=input('enter periodic binary pulse');
amp=input('enter amplitude for both carrier & bin. pulse');

t=0:0.001:1;

x=amp.*sin(2*pi*fc*t);
subplot(3,1,1);
plot(t,x);
xlabel('time');
ylabel('amplitude');
title('Carrier/Sandeep/BCT061');
grid on;

y=amp/2.*square(2*pi*fp*t)+amp/2;
subplot(3,1,2);
plot(t,y);
xlabel('time');
ylabel('amplitude');
title('Message/Sandeep/BCT061');
grid on;

a=x.*y;
subplot(3,1,3);
plot(t,a);
xlabel('time');
ylabel('amplitude');
title('ASK
modulation/Sandeep/BCT061');
grid on;
%CONSTRUCT AN PSK MODULATED SIGNAL
clc;
close all;

t=0:0.001:1;

fc=input('enter freq. of carrier sine wave');


fm=input('Message freq.');
amp=input('enter amplitude for both carrier & message’);

x=amp.*sin(2*pi*fc*t);
subplot(3,1,1);
plot(t,x);
xlabel('time');
ylabel('amplitude');
title('Carrier/Sandeep/BCT061');
grid on;

y=square(2*pi*fm*t);
subplot(3,1,2);
plot(t,y);
xlabel('time');
ylabel('amplitude');
title('Message/Sandeep/BCT061');
grid on;

a=x.*y;
subplot(3,1,3);
plot(t,a);
xlabel('time');
ylabel('amplitude');
title('PSK
modulation/Sandeep/BCT061');
legend('PSK');
grid on;
%CONSTRUCT AN FSK MODULATED SIGNAL

clc;
close all;

fc1=input('enter freq. of 1st sine wave');


fc2=input('enter freq. of 2nd sine wave');
fp=input('enter freq. of periodic binary pulse');
amp=input('enter amplitude for both carrier & bin.pulse');

t=0:0.001:1;

c1=amp/2.*sin(2*pi*fc1*t);
c2=amp/2.*sin(2*pi*fc2*t);

subplot(4,1,1);
plot(t,c1);
xlabel('time');
ylabel('amplitude');
title('Carrier1/Sandeep/BCT061');
grid on;

subplot(4,1,2);
plot(t,c2);
xlabel('time');
ylabel('amplitude');
title('Carrier2/Sandeep/BCT061');
grid on;

m=amp/2.*square(2*pi*fp*t)+amp/2;
subplot(4,1,3);
plot(t,m);
xlabel('time');
ylabel('amplitude');
title('Message/Sandeep/BCT061');
grid on;

for i=0:1000
if m(i+1)==0
mm(i+1)=c2(i+1);
else
mm(i+1)=c1(i+1);
end
end
subplot(4,1,4);
plot(t,mm);
xlabel('time');
ylabel('amplitude');
title('FSK Signal/Sandeep/BCT061')
legend('FSK');
grid on;

Discussion and Conclusion:

Digital modulation techniques such as Amplitude Shift Keying (ASK), Phase


Shift Keying (PSK), and Frequency Shift Keying (FSK) are essential for
transmitting digital data over various communication channels. In ASK, the
amplitude of the carrier signal is varied to represent binary data, with high
amplitude indicating '1' and low amplitude indicating '0'. Although ASK is
simple and bandwidth-efficient, it is highly susceptible to noise. PSK, on the
other hand, changes the phase of the carrier signal to encode data, offering
better noise resistance. Binary PSK (BPSK) uses two phases to represent '1'
and '0', while higher-order forms like Quadrature PSK (QPSK) use multiple
phases for more efficient data representation. FSK changes the frequency of
the carrier signal to denote binary values, with one frequency representing '1'
and another representing '0'. FSK is robust against amplitude noise but
requires more bandwidth.

Each digital modulation technique has its strengths and weaknesses, making
the choice dependent on specific communication system requirements. ASK is
straightforward and bandwidth-efficient but less robust against noise. PSK
provides better noise resistance and efficient bandwidth usage, especially in
higher-order forms, though it is more complex to implement. FSK offers
excellent noise resilience but at the cost of increased bandwidth.
Understanding these techniques is crucial for designing effective
communication systems that balance simplicity, noise resistance, and
bandwidth efficiency.
LAB5: CONVERSATION OF BINARY SEQUENCE
INTO LINE CODING

OBJECTIVES:
• To implement conversation of binary sequence into line coding using
MATLAB

THEORY:

Line Coding is a method used to convert binary data (0s and 1s) into a form
that can be easily transmitted over a communication channel. There are
various line coding schemes, each with different characteristics:

1. Unipolar:
• Uses only positive voltages to represent binary data.
• Binary '1' is a positive voltage; binary '0' is zero voltage.

2. Polar:
• Uses both positive and negative voltages.
• Binary '1' is a positive voltage; binary '0' is a negative voltage.

3. Bipolar:
• Uses three levels: positive, negative, and zero.
• Binary '1' alternates between positive and negative voltages; binary '0' is
zero voltage.

4. Manchester:
• Ensures synchronization by having a transition in the middle of each bit.
• Binary '1' is a high-to-low transition; binary '0' is a low-to-high
transition.
% UNIPOLAR LINE ENCODING

clc;
close all;
clear all;

bits = [1 0 1 1 1 0 1 1];
bitrate = 1;
n = 1000;
T = length(bits)/bitrate;
N = n*length(bits);
dt = T/N;
t = 0:dt:T;

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

for i=1:length(bits)

if bits(i)==1

x((i-1)*n+1:(i-1)*n+n/2) = 1;
x((i-1)*n+n/2:i*n) = 1;
else
x((i-1)*n+1:(i-1)*n+n/2) = 0;
x((i-1)*n+n/2:i*n) = 0;
end;
end;

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


counter = 0;

for i = 1:length(t)
if t(i)>counter
counter = counter + 1;
if x(i)>0
result(counter) = x(i);
else result(counter) = 0;
end;
end ;
end ;
title('Unipolar linecoding(10111011)/ Sandeep / 061');
disp(result);
%bipolar

clc;
clear all;
close all;

bits = [1 0 1 1 0 1 1 0 0 1 0 1];
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;

for i=1:length(bits)
if bits(i)==1
x((i-1)*n+1:i*n) = -lastbit;
lastbit = -lastbit;
end;
end;

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

counter = 0;
lastbit = 1;

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

title('Bipolar Encoding (101101100101)/Sandeep/061');


disp(result);
% POLAR LINE ENCODING

clc;
close all;
clear all;

bits = [1 1 0 1 1 0 0 1];
bitrate = 1;
n = 1000;
T = length(bits)/bitrate;
N = n*length(bits);
dt = T/N;
t = 0:dt:T;

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

for i=1:length(bits)
if bits(i)==1
x((i-1)*n+1:(i-1)*n+n/2) = -1;
x((i-1)*n+n/2:i*n) = -1;
else
x((i-1)*n+1:(i-1)*n+n/2) = 1;
x((i-1)*n+n/2:i*n) = 1;
end
end

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

counter = 0;
for i = 1:length(t)
if t(i)>counter
counter = counter + 1;
if x(i)>0
result(counter) = x(i);
else result(counter) = 0;
end
end
end

title('Polar(NRZ-L)linecoding (11011001)/ Sandeep / 061');


disp(result);
%4. MANCHESTER LINE ENCODING

clc;
clear all;
close all;

bits = [1 0 1 0 1 1 0 1];
bitrate = 1;
n = 1000;
T = length(bits)/bitrate;
N = n*length(bits);
dt = T/N;
t = 0:dt:T;

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

for i=1:length(bits)
if bits(i)==1
x((i-1)*n+1:(i-1)*n+n/2) = 1;
x((i-1)*n+n/2:i*n) = -1;
else
x((i-1)*n+1:(i-1)*n+n/2) = -1;
x((i-1)*n+n/2:i*n) = 1;
end;
end;

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

counter = 0;
for i = 1:length(t)
if t(i)>counter
counter = counter + 1;
if x(i)>0
result(counter) = x(i);
else result(counter) = 0;
end;
end;
end;

title('Manchester line encoding(10101101)/Sandeep/061');


disp(result);
Discussion and Conclusion:

Line coding techniques are crucial for transmitting digital data effectively over
communication channels. Each method—Unipolar, Polar, Bipolar, and
Manchester—has distinct characteristics that make them suitable for different
applications. Unipolar coding is simple and easy to implement but suffers
from synchronization issues and a significant DC component, which can cause
signal distortion. Polar coding, by using both positive and negative voltages,
improves synchronization and reduces the DC component but still requires
more bandwidth. Bipolar coding further enhances signal robustness by
eliminating the DC component and alternating the polarity for binary '1',
providing better error detection. However, it is more complex to implement.
Manchester encoding, with its inherent synchronization and absence of a DC
component, ensures a robust signal transmission but demands more bandwidth
than other schemes.

Selecting the appropriate line coding scheme is essential for optimizing the
performance of a communication system. Unipolar coding, though simple,
may not be suitable for applications requiring high synchronization and
minimal signal distortion. Polar coding offers a balance but at the cost of
increased bandwidth. Bipolar coding, while more complex, provides excellent
error detection and signal integrity. Manchester encoding stands out for its
robust synchronization capabilities, making it ideal for environments where
signal integrity is paramount despite its higher bandwidth requirement.
Ultimately, the choice of line coding depends on the specific requirements of
the communication system, including the need for bandwidth efficiency, error
detection, and signal robustness.

You might also like