

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


% 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');
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')