

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
This is code in MATLAB. Its soution to lab assignment by Sir Bhanuprasad Venkatesan at Shree Ram Swarup College of Engineering and Management for Analog Communication course. It includes: Phase, Locked, Loop, Amplitude, Frequency, Shift, LPF, VCO, Filter, Cutoff, Input
Typology: Exercises
1 / 2
This page cannot be seen from the preview
Don't miss anything!


% Phase Locked Loop:
% Input Arguments: t=0:0.002:2; A = 10; % Amplitude of Message Signal wm = 2pi30; % Frequency of message signal fs = 500; % Corresponding Sampling frequency oi = pi/2; % phase shift in input filter_order = 70; % filter order of LPF wcut = (210)/(fs); % Cutoff frequency of LPF wc = 2pi*30; % 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 k = 1;
% 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 = Bcos(wt); o(k) = oi-(ce0); % Multiplier: m0 = u.*v;
% Low Pass Filter: Filter = fir1(filter_order,wcut,'low'); Filter_fourier = fftshift(abs(fft(Filter,a)));
% Applying on Multiplied Result:
M0 = fftshift(abs(fft(m0))); E0 = M0.Filter_fourier; e0 = ifft(ifftshift(E0)); y(k)= max(e0); e0=y(k); % y(k) = ((AB)/2)*sin(o(k)); e0=y(k); end
% figure, plot(t(1:100),v(1:100)), title('Signal Generated by VCO'),xlabel('time'),ylabel('Amplitude') % figure, plot(t(1:100),m0(1:100)), title('Multiplier Result'),xlabel('time'),ylabel('Amplitude') % figure, plot(w(501:1001),Filter_fourier(501:1001)), title('Frequency Responce of LPF'),xlabel('frequency (Hz)'),ylabel('Amplitude') % figure, plot(w(501:1001),E0(501:1001)), title('Frequency Responce eo(t)'),xlabel('frequency (Hz)'),ylabel('Amplitude') figure, plot(o,y), title('output e0(t)'),xlabel('thetae'),ylabel('Amplitude')