Professional Documents
Culture Documents
Matlab code:
%>>> AM Modulation <<<
clc;
close all;
clear all;
Signal Graph:
Problem 2: Write a program to generate Frequency Modulation.
Theory:
Frequency modulation (FM) is the standard technique for high-fidelity communications as is
evident in the received signals of the FM band (88-108 MHz) vs. the AM band (450-1650 KHz).
The main reason for the improved fidelity is that FM detectors, when properly designed, are not
sensitive to random amplitude variations which are the dominant part of electrical noise (heard
as static on the AM radio). Frequency modulation is not only used in commercial radio
broadcasts, but also in police and hospital communications, emergency channels, TV sound,
wireless (cellular) telephone systems, and radio amateur bands above 30 MHz. The basic idea
of an FM signal vs. an AM signal is shown in Fig. 1. In an FM signal, the frequency of the signal
is changed by the modulation (baseband) signal while its amplitude remains the same. In an
AM signal, we now know that it is the amplitude (or the envelope) of the signal that is changed
by the modulation signal.
Matlab code:
fm=input(‘Message Frequency=’);
fc=input(‘Carrier Frequency=’);
mi=input(‘Modulation Index=’);
t=0:0.0001:0.1;
m=sin(2*pi*fm*t);
subplot(3,1,1);
plot(t,m);
xlabel(‘Time’);
ylabel(‘Amplitude’);
title(‘Message Signal’);
gridon;c=sin(2*pi*fc*t);
subplot(3,1,2);
plot(t,c);
xlabel(‘Time’);
ylabel(‘Amplitude’);
title(‘Carrier Signal’);
grid on;y=sin(2*pi*fc*t+(mi.*sin(2*pi*fm*t)));%Frequency changing w.r.t
Message
subplot(3,1,3);
plot(t,y);
xlabel(‘Time’);
ylabel(‘Amplitude’); title(‘FM Signal’)
grid on;
Signal graph:
kp = pi/2;
% modulating the carrier with the message signal
carrier = cos(2*pi*fc*t);
modulated = cos(2*pi*fc*t + kp*m)
Signal graph:
Theory: Amplitude-shift keying (ASK) is a form of amplitude modulation that represents digital data as
variations in the amplitude of a carrier wave. In an ASK system, the binary symbol 1 is represented by
transmitting a fixed-amplitude carrier wave and fixed frequency for a bit duration of T seconds. If the
signal value is 1 then the carrier signal will be transmitted; otherwise, a signal value of 0 will be
transmitted.
A=3;%Amplitude
t=0:0.001:1;
v=x.*u;
subplot(3,1,1);
plot(t,x);
xlabel(‘Time’);
ylabel(‘Amplitude’);
title(‘Carrier’);
grid on;
subplot(3,1,2);
plot(t,u);
xlabel(‘Time’);
ylabel(‘Amplitude’);
title(‘Square Pulses’);
grid on;subplot(3,1,3);
plot(t,v);
xlabel(‘Time’);
ylabel(‘Amplitude’);
title(‘ASK Signal’);
grid on;
Signal Graph:
Problem 5: Write a program to generate Frequency Shift Keying (FSK)
Theory:
Frequency Shift Keying (FSK) is the digital modulation technique in which the
frequency of the carrier signal varies according to the digital signal changes. FSK is a scheme
of frequency modulation.
The output of a FSK modulated wave is high in frequency for a binary High input and is low in
frequency for a binary Low input. The binary 1s and 0s are called Mark and Space
frequencies.
Matlab Code:%>>>>>>>>> MATLAB code for binary FSK modulation >>>>>>>%
clc;
clear all;
close all;
x=[ 1 0 0 0 1 0 1];
bp=.000001;
disp(' Binary information at Trans mitter :');
disp(x);
%XX representation of transmitting binary information as digital signal XXX
bit=[];
for n=1:1:length(x)
if x(n)==1;
se=ones(1,100);
else x(n)==0;
se=zeros(1,100);
end
bit=[bit se];
end
t1=bp/100:bp/100:100*length(x)*(bp/100);
subplot(3,1,1);
plot(t1,bit,'lineWidth',2.5);grid on;
axis([ 0 bp*length(x) -.5 1.5]);
ylabel('amplitude(volt)');
xlabel(' time(sec)');
title('transmitting information as digital signal');
A=5;
br=1/bp;
f1=br*3;
f2=br*1;
t2=bp/99:bp/99:bp;
ss=length(t2);
m=[];
for (i=1:1:length(x))
if (x(i)==1)
y=A*cos(2*pi*f1*t2);
else
y=A*cos(2*pi*f2*t2);
end
m=[m y];
end
t3=bp/99:bp/99:bp*length(x);
subplot(3,1,2);
plot(t3,m);
xlabel('time(sec)');
ylabel('amplitude(volt)');
title('waveform for binary FSK modulation coresponding binary information');
Signal Figure:
Problem6: Write a program to generate Phase Shift Keying
Theory: Phase-shift keying (PSK) is a digital modulation process which conveys data by changing
(modulating) the phase of a constant frequency reference signal (the carrier wave). In PSK, the
constellation points chosen are usually positioned with uniform angular spacing around a circle In this
way, the moduli of the complex numbers they represent will be the same and thus so will the
amplitudes needed for the cosine and sine waves. Two common examples are "binary phase-shift
keying" (BPSK) which uses two phases, and "quadrature phase-shift keying" (QPSK) which uses four
phases, although any number of phases may be used. Since the data to be conveyed are usually binary,
the PSK scheme is usually designed with the number of constellation points being a power of two.
n = length(b);
t = 0:.01:n;
x = 1:1:(n+1)*100;
for i = 1:n
if (b(i) == 0)
b_p(i) = -1;
else
b_p(i) = 1;
end
for j = i:.1:i+1
bw(x(i*100:(i+1)*100)) = b_p(i);
end
end
bw = bw(100:end);
sint = sin(2*pi*t);
st = bw.*sint;
subplot(3,1,1)
plot(t,bw)
subplot(3,1,2)
plot(t,sint)
subplot(3,1,3)
plot(t,st)
Signal Graph:
Theory: In unipolar line coding scheme in which positive voltage defines bit 1 and the
zero voltage defines bit 0. Signal does not return to zero at the middle of the bit thus it is
called NRZ.
But this scheme uses more power as compared to polar scheme to send one bit per unit
line resistance. Moreover for continuous set of zeros or ones there will be self-
synchronization and base line wandering problem.
Matlab Code:
close all;
n=[1 0 1 1 0 1];
for i=1:length(n)
if(n(i)==1)
nn(i)=2;
else
nn(i)=0;
end
end
i=1;
t=0:0.01:length(n);
for j=1:length(t)
if(t(j)<=i)
y(j)=nn(i);
else
y(j)=nn(i);
i=i+1;
%j=j-2;
%y(j)=nn(i);
end
end
plot(t,y,'r-');
%grid;
xlabel('Time');
ylabel('Amplitude');
Signal Graph:
Theory: In polar NRZ encoding, we use two levels of voltage amplitude. We can have two versions of
polar NRZ: (1). NRZ-L (2). NRZ-I.
NRZ-L (NRZ-Level): The level of the voltage determines the value of the bit.
NRZ-I (NRZ-Invert): The change or lack of change in the level of the voltage determines the value of the
bit. If there is no change, the bit is 0; if there is a change, the bit is 1
Matlab Code:
close all;
%warning off;
%input
n=[1 0 1 1 0 1];
n=input();
for i=1:length(n)
if n(i)==1;
nn(i)=2;
else
nn(i)=-2;
end
end
i2=1;
t=0:0.01:length(n);
for j=1:length(t)
if t(j)<=i2;
y(j)=nn(i2);
else
y(j)=nn(i2);
i2=i2+1;
end
end
plot(t,y,'r-');
%grid;
xlabel('Time');
ylabel('Amplitude');
Signal Graph:
Problem9: Write a program to generate Polar Return-To-Zero(RZ)
Theory: Return-to-zero (RZ or RTZ) describes a line code used in telecommunications signals in which the
signal drops (returns) to zero between each pulse. This takes place even if a number of consecutive 0s or
1s occur in the signal. The signal is self-clocking. This means that a separate clock does not need to be
sent alongside the signal, but suffers from using twice the bandwidth to achieve the same data-rate as
compared to non-return-to-zero format.
%n=[0 0 0 1 0 1 0 1];
N=4;
for a=1:N
n(a)=input(['' ]);
a=a+1;
end
for i=1:length(n)
if n(i)==1
n(i)=8;
else n(i)=-8;
end
end
y=0;
i=1;
a=0;
b=0.5;
t=0:0.001:length(n);
for j=1:length(t)
y(j) = n(i);
y(j)=0;
else i=i+1;
a=a+1;
b=b+1;
end
end
end
plot(t,y);
title('polar RZ wave');
xlabel('...time...');
ylabel('..amplitude..');
grid on;
Signal Graph:
Problem10: Write a program to generate Polar: Manchester
Theory: Manchester coding is a special case of binary phase-shift keying (BPSK), where the data controls
the phase of a square wave carrier whose frequency is the data rate. Manchester code ensures frequent
line voltage transitions, directly proportional to the clock rate; this helps clock recovery. The DC
component of the encoded signal is not dependent on the data and therefore carries no information.
Therefore connections may be inductively or capacitively coupled, allowing the signal to be conveyed
conveniently by galvanically isolated media (e.g., Ethernet) using a network isolator—a simple one-to-
one isolation transformer which cannot convey a DC component.
N=4;
for a=1:N
n(a)=input(['' ]);
a=a+1;
end
nnn=[];
for m=1:N
if n(m)==0
nn=[-1 1];
else
nn=[1 -1];
end
nnn=[nnn nn];
end
i=1;
l=0.5;
t=0:.01:length(n);
for j=1:length(t)
if t(j)<=l
y(j)=nnn(i);
else
y(j)=nnn(i);
i=i+1;
l=l+0.5;
end
end
plot(t,y);
axis([0 N -2 2]);
grid;
Signal Graph: