Docsity

Phase Locked Loop I-Analog Communication-Matlab Codes, Exercises of Analog Communication

Toggle sidebar
bg1
% Phase Locked Loop:
close all
% Input Arguments:
t = 0:0.002:2;
A = 10; % Amplitude of Message Signal
wm = 2*pi*20; % Frequency of message signal
fs = 500; % Corresponding Sampling frequency
oi = 2; % phase shift in input
filter_order = 70; % filter order of LPF
wcut = (2*5)/(fs); % Cutoff frequency of LPF
wc = 2*pi*40; % Free Running frequency of VCO
e0 = 10 ; % Initialization for loop with a random
value
c = 1; % Constant multiple of e0
B = 10; % Amplitude of the signal generated by
VCO
% Working:
% u --->(x)---->[ H(s) ]---+--> y
% | |
% ------[ VCO ]<-----
% H(s) = Low Pass loop filter
% VCO = Voltage Controlled Oscillator
% (x) = A multiplier working as a phase detector
% Input Signal:
u=A*sin(wm*t);
w=-250:(2*250)/1000:250;
U=fftshift(abs(fft(u)));
figure, plot(t(1:20),u(1:20)), title('Message
Signal'),xlabel('time'),ylabel('Amplitude')
figure, plot(w(501:1001),U(501:1001)), title('Spectrum of Message
Signal'),xlabel('frequency (Hz)'),ylabel('Amplitude')
a = length(u);
for k=1:1000
% VCO:
wt = wc*t(c*(e0));
v = B*cos(wt);
% for plot of e0:
x(k) = (oi-(c*e0));
y(k) = e0;
% Multiplier:
m0 = u.*v;
% Low Pass Filter:
Filter = fir1(filter_order,wcut,'low');
docsity.com
pf2

Partial preview of the text

Download Phase Locked Loop I-Analog Communication-Matlab Codes and more Exercises Analog Communication in PDF only on Docsity!

% Phase Locked Loop: close all % Input Arguments: t = 0:0.002:2; A = 10; % Amplitude of Message Signal wm = 2pi20; % Frequency of message signal fs = 500; % Corresponding Sampling frequency oi = 2; % phase shift in input filter_order = 70; % filter order of LPF wcut = (25)/(fs); % Cutoff frequency of LPF wc = 2pi*40; % Free Running frequency of VCO e0 = 10 ; % Initialization for loop with a random value c = 1; % Constant multiple of e B = 10; % Amplitude of the signal generated by VCO

% Working:

% u --->(x)---->[ H(s) ]---+--> y % | | % ------[ VCO ]<-----

% H(s) = Low Pass loop filter % VCO = Voltage Controlled Oscillator % (x) = A multiplier working as a phase detector

% Input Signal: u=Asin(wmt);

w=-250:(2*250)/1000:250; U=fftshift(abs(fft(u)));

figure, plot(t(1:20),u(1:20)), title('Message Signal'),xlabel('time'),ylabel('Amplitude') figure, plot(w(501:1001),U(501:1001)), title('Spectrum of Message Signal'),xlabel('frequency (Hz)'),ylabel('Amplitude')

a = length(u);

for k=1: % VCO: wt = wct(c(e0)); v = B*cos(wt);

% for plot of e0: x(k) = (oi-(c*e0)); y(k) = e0;

% Multiplier: m0 = u.*v;

% Low Pass Filter: Filter = fir1(filter_order,wcut,'low');

docsity.com

Filter_fourier = fftshift(abs(fft(Filter,a)));

% Applying on Multiplied Result: e0 = conv(m0,Filter); e0 = max(e0); % e0 = ((AB)/2)sin(x(k)); end

figure, plot(x,y), title('output e0(t)'),xlabel('theta e'),ylabel('Amplitude') figure, plot(w(501:1001),Filter_fourier(501:1001)), title('Frequency Responce of LPF'),xlabel('frequency (Hz)'),ylabel('Amplitude')

docsity.com