2k19ec209 CSF3 All
2k19ec209 CSF3 All
2k19ec209 CSF3 All
(Experiment no - 5)
Aim : To generate matlab code for Frequency Modulation.
Theory :
Frequency Modulation
Mathematical Representation
fi=fc+kfm(t)fi=fc+kfm(t)
Where,
fcfc is the carrier frequency
ktkt is the frequency sensitivity
ωi=dθi(t)dtωi=dθi(t)dt
⇒2πfi=dθi(t)dt⇒2πfi=dθi(t)dt
⇒θi(t)=2π∫fidt⇒θi(t)=2π∫fidt
θi(t)=2π∫(fc+kfm(t))dtθi(t)=2π∫(fc+kfm(t))dt
⇒θi(t)=2πfct+2πkf∫m(t)dt⇒θi(t)=2πfct+2πkf∫m(t)dt
s(t)=Accos(2πfct+2πkf∫m(t)dt)s(t)=Accos(2πfct+2πkf∫m
(t)dt)
This is the equation of FM wave.
If the modulating signal
is m(t)=Amcos(2πfmt)m(t)=Amcos(2πfmt), then the equation
of FM wave will be
s(t)=Accos(2πfct+βsin(2πfmt))s(t)=Accos(2πfct+βsin(
2πfmt))
Where,
ββ = modulation index =Δffm=kfAmfm=Δffm=kfAmfm
The difference between FM modulated frequency (instantaneous
frequency) and normal carrier frequency is termed as Frequency
Deviation. It is denoted by ΔfΔf, which is equal to the product
of kfkf and AmAm.
FM can be divided into Narrowband FM and Wideband
FM based on the values of modulation index ββ.
Narrowband FM
Wideband FM
Output Result :
(Experiment no - 6)
Aim : To generate matlab code for Phase Modulation.
Theory :
Phase Modulation
In frequency modulation, the frequency of the carrier varies.
Whereas, in Phase Modulation (PM), the phase of the carrier
signal varies in accordance with the instantaneous amplitude of
the modulating signal.
So, in phase modulation, the amplitude and the frequency of the
carrier signal remains constant. This can be better understood by
observing the following figures.
The phase of the modulated wave has got infinite points, where
the phase shift in a wave can take place. The instantaneous
amplitude of the modulating signal changes the phase of the
carrier signal. When the amplitude is positive, the phase changes
in one direction and if the amplitude is negative, the phase
changes in the opposite direction.
Mathematical Representation
ϕi=kpm(t)ϕi=kpm(t)
Where,
kpkp is the phase sensitivity
s(t)=Accos(2πfct+ϕi)s(t)=Accos(2πfct+ϕi)
s(t)=Accos(2πfct+kpm(t))s(t)=Accos(2πfct+kpm(t))
s(t)=Accos(2πfct+βcos(2πfmt))s(t)=Accos(2πfct+βcos(
2πfmt))
Where,
Output :
(Experiment no - 7)
Aim : To generate matlab code for Dsbsc demod using
synchronous detector .
Theory :
The process of extracting an original message signal from DSBSC
wave is known as detection or demodulation of DSBSC. The
following demodulators (detectors) are used for demodulating
DSBSC wave.
Synchronous Detector
Costas Loop
Synchronous Detector
s(t)=Accos(2πfct)m(t)s(t)=Accos(2πfct)m(t)
c(t)=Accos(2πfct+ϕ)c(t)=Accos(2πfct+ϕ)
v(t)=s(t)c(t)v(t)=s(t)c(t)
⇒v(t)=Accos(2πfct)m(t)Accos(2πfct+ϕ)⇒v(t)=Accos(2πfc
t)m(t)Accos(2πfct+ϕ)
=Ac2cos(2πfct)cos(2πfct+ϕ)m(t)=Ac2cos(2πfct)cos(2πfct
+ϕ)m(t)
=Ac22[cos(4πfct+ϕ)+cosϕ]m(t)=Ac22[cos(4πfct+ϕ)+cosϕ]
m(t)
v(t)=Ac22cosϕm(t)+Ac22cos(4πfct+ϕ)m(t)v(t)=Ac22cosϕm
(t)+Ac22cos(4πfct+ϕ)m(t)
In the above equation, the first term is the scaled version of the
message signal. It can be extracted by passing the above signal
through a low pass filter.
Therefore, the output of low pass filter is
v0t=Ac22cosϕm(t)v0t=Ac22cosϕm(t)
Code :
clc;
clear all;
close all;
t = 0.1:0.001:1;
fs = 1000;
fm=5;
fc=20;
wm = 2*pi*5;
wc = 2*pi*20;
Am = 1;
Ac = 2;
m = Am*sin(wm.*t);
c = Ac*cos(wc*t);
N_t = length(t);
modulated = Ac*c.*m;
N = length(modulated);
N_scale = fs*(-N/2:N/2-1)/N;
c_fft = fftshift(fft(c))/N;
m_fft = fftshift(fft(m))/N;
modulated_fft = fftshift(fft(modulated)/N);
figure(1);
subplot(2, 2, 1);
plot(t, m);
title('message Vikas 2K19/EC/209(t)');
subplot(2, 2, 2);
plot(t, c);
title('carrier(t)');
subplot(2, 2, 3);
plot(N_scale, abs(m_fft));
title('M(w)');
subplot(2, 2, 4);
plot(N_scale, abs(c_fft));
title('C(w)');
figure(2);
subplot(2, 1, 1);
plot(t, modulated);
title('s(t)');
subplot(2, 1, 2);
plot(N_scale, abs(modulated_fft));
title('S(w)');
figure(3);
Fco = 30;
n = 1;
[b,a] = butter(n, 2*Fco/fs, 'low');
freqz(b, a);
[Yh, w] = freqz(b, a, fs/2);
h = ifft(Yh);
mulOut = Ac*c.*modulated;
lpfOut = filter(b, a, mulOut);
YlpfOut = fftshift(fft(lpfOut)/length(lpfOut));
N1 = length(lpfOut);
Nd_scale = fs*(-N1/2:N1/2-1)/N1;
figure(4);
subplot(2,1,1);
plot(t, lpfOut);
title('demod at 0 2K19/EC/209');
hold on;
plot(t, m);
hold off;
subplot(2,1,2);
plot(Nd_scale, abs(YlpfOut));
title('des_fft');
phi = pi/4;
c45 = cos(wc*t + phi);
phi = pi/2;
c90 = cos(wc*t + phi);
mulOut = Ac*c45.*modulated;
lpfOut = filter(b, a, mulOut);
YlpfOut = fftshift(fft(lpfOut)/length(lpfOut));
N1 = length(lpfOut);
Nd_scale = fs*(-N1/2:N1/2-1)/N1;
figure(5);
subplot(2,1,1);
plot(t, lpfOut);
title ('demodulated at 45');
hold on;
plot(t, m);
hold off;
subplot(2,1,2);
plot(Nd_scale, abs(YlpfOut));
title ('des_fft');
mulOut = Ac*c90.*modulated;
lpfOut = filter(b, a, mulOut);
YlpfOut = fftshift(fft(lpfOut)/length(lpfOut));
N1 = length(lpfOut);
Nd_scale = fs*(-N1/2:N1/2-1)/N1;
figure(6);
subplot(2,1,1);
plot(t, lpfOut);
title ('demodulated at 90');
hold on;
plot(t, m);
hold off;
subplot(2,1,2);
plot(Nd_scale, abs(YlpfOut));
title ('des_fft');
Output :
(Experiment no - 8)
Aim : To generate matlab code for Ssbsc demod using
synchronous detector .
Theory :
The process of extracting an original message signal from SSBSC wave is
known as detection or demodulation of SSBSC. Coherent detector is used for
demodulating SSBSC wave.
Synchronous Detector
Here, the same carrier signal (which is used for generating SSBSC wave) is
used to detect the message signal. Hence, this process of detection is called
as coherent or synchronous detection. Following is the block diagram of
coherent detector.
In this process, the message signal can be extracted from SSBSC wave by
multiplying it with a carrier, having the same frequency and the phase of the
carrier used in SSBSC modulation. The resulting signal is then passed
through a Low Pass Filter. The output of this filter is the desired message
signal.
Consider the following SSBSC wave having a lower sideband.
s(t)=AmAc2cos[2π(fc−fm)t]s(t)=AmAc2cos[2π(fc−fm)t]
c(t)=Accos(2πfct)c(t)=Accos(2πfct)
v(t)=s(t)c(t)v(t)=s(t)c(t)
v(t)=AmAc2cos[2π(fc−fm)t]Accos(2πfct)v(t)=AmAc2cos[2π(fc−fm)t]Accos
(2πfct)
=AmAc22cos[2π(fc−fm)t]cos(2πfct)=AmAc22cos[2π(fc−fm)t]cos(2πfct)
=AmAc24{cos[2π(2fc−fm)]+cos(2πfm)t}=AmAc24{cos[2π(2fc−fm)]+cos(2
πfm)t}
v(t)=AmAc24cos(2πfmt)+AmAc24cos[2π(2fc−fm)t]v(t)=AmAc24cos(2πf
mt)+AmAc24cos[2π(2fc−fm)t]
In the above equation, the first term is the scaled version of the message
signal. It can be extracted by passing the above signal through a low pass
filter.
Therefore, the output of low pass filter is
v0(t)=AmAc24cos(2πfmt)v0(t)=AmAc24cos(2πfmt)
s(t)=AmAc2cos[2π(fc+fm)t]s(t)=AmAc2cos[2π(fc+fm)t]
c(t)=Accos(2πfct)c(t)=Accos(2πfct)
v(t)=s(t)c(t)v(t)=s(t)c(t)
⇒v(t)=AmAc2cos[2π(fc+fm)t]Accos(2πfct)⇒v(t)=AmAc2cos[2π(fc+f
m)t]Accos(2πfct)
=AmAc22cos[2π(fc+fm)t]cos(2πfct)=AmAc22cos[2π(fc+fm)t]cos(2
πfct)
=AmAc24{cos[2π(2fc+fm)t]+cos(2πfmt)}=AmAc24{cos[2π(2fc+fm)t]
+cos(2πfmt)}
v(t)=AmAc24cos(2πfmt)+AmAc24cos[2π(2fc+fm)t]v(t)=AmAc24cos
(2πfmt)+AmAc24cos[2π(2fc+fm)t]
In the above equation, the first term is the scaled version of the message
signal. It can be extracted by passing the above signal through a low pass
filter.
Therefore, the output of the low pass filter is
v0(t)=AmAc24cos(2πfmt)v0(t)=AmAc24cos(2πfmt)
clc;
clear ;
close all;
Am=1; %amplitude of message signal
Ac=2; %amplitude of carrier signal
ka=0.25 %amplitude sensitivity of a modulator
Fm=5; %frequency of message signal
Fc=20; %frequency of carrier signal
F=500; %sampling frequency
T=1/F; %time period
t=0:T:1; % x-axis;
n=length(t); %length of t
figure(1);
%message signal
Mt=Am*cos(2*pi*Fm*t); %sinusoidal signal
subplot(3,1,1);
plot(t,Mt); %define signal
xlabel('Time(s)');
ylabel('Amplitude');
title('Message VIKAS 2K19/EC/209 signal');
%carrier signal
Ct=Ac*cos(2*pi*Fc*t); %sinusoidal signal
subplot(3,1,2);
plot(t,Ct,'r'); %define signal
xlabel('Time(s)');
ylabel('Amplitude');
title('Carrier signal');
%SSBSC modulation
Xt1=Mt.*Ct - Mh.*Ch; %Single Side Band with Upper Side
Band
Xt2=Mt.*Ct + Mh.*Ch; %Single Side Band with lower Side
Band
subplot (3,1,3);
plot(t,Xt1,'m'); %defining ssb modulation
xlabel('Time(s)');
ylabel('Amplitude');
title('SSB modulated 2K19/EC/209 signal');
figure(2);
%FREQUENCY SPECTRUM OF MESSAGE SIGNAL
fs=F*[-n/2:n/2-1]/n; %frequency axis
Mf=fftshift(fft(Mt,n)); %defining frequency spectrum
subplot(4,1,1);
plot(fs,abs(Mf));
xlabel('Frequency (Hz)');
ylabel('Amplitude');
title('Frequency spectrum of message signal');
figure(3);
%designing of low pass filter
fco=30; % LPF 3db cutoff frequency in Hz
N=2; % order of butterworth filter
[b,a]=butter(N,2*fco/F,'low');
freqz(b,a); % bode plot (mag and phase)
% local oscillator
ct= cos(2*pi*Fc*t); %with zero phase
ct2=cos(2*pi*Fc*t + pi/2); %with 90 degree phase
figure(4);
%multiplier output with (zero degree phase shift)
mulout=Xt1.*ct; %in time domain
subplot(2,2,1);
plot(t,mulout);
xlabel('Time(s)');
ylabel('Amplitude');
title('Multiplier output (0 degree phase shift)');
%spectrum of multiplier
muloutf=fftshift(fft(mulout,n));
subplot(2,2,2);
plot(fs,abs(muloutf));
xlabel('Frequency (Hz)');
ylabel('Amplitude');
title('Spectrum of multiplier (0 degree phase shift)');
figure(5)
%multiplier output with (90 degree phase shift)
mulout2=Xt1.*ct2; %in time domain
subplot(4,1,1);
plot(t,mulout2);
xlabel('Time(s)');
ylabel('Amplitude');
title('Multiplier output (90 degree phase shift)');
%spectrum of multiplier
muloutf2=fftshift(fft(mulout2,n));
subplot(4,1,2);
plot(fs,abs(muloutf2));
xlabel('Frequency (Hz)');
ylabel('Amplitude');
title('Spectrum of multiplier (with 90 degree phase
shift)');
%output of low pass filter of order 2(with 90 degree
phase shift)
lpfout2 = filter(b,a,mulout2);
subplot(4,1,3);
plot(t,lpfout2,'r',t,Mt,'b');
xlabel('Time(s)');
ylabel('Amplitude');
title('Demodulated and message signal signal (90)');
Ylpfout2 =fftshift(fft(lpfout2,n));
subplot(4,1,4);
plot(fs,abs(Ylpfout2),'r',fs,abs(Mf));
xlabel('Frequency (Hz)');
ylabel('Amplitude');
title('Spectrum of demodulated and message signal (90)');
Output Result :