Datalastlab
Datalastlab
LAB REPORT
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:
• 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.
clc;
close all;
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;
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;
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;
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;
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;
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
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
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
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;
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;
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.