全数字FM接收机2---仿真

在MATLAB下仿真程序

 1 %Simple PLL m-file demonstration
 2  
 3 %This m-file demonstrates a PLL which tracks and demodulates an FM carrier.
 4 clear all; 
 5 close all; 
 6 f=1000;%Carrier frequency 
 7 fs=100000;%Sample frequency
 8 N=5000;%Number of samples
 9 Ts=1/fs;
10 t=(0:Ts:(N*Ts)- Ts);
11 %Create the message signal
12 f1=100;%Modulating frequency
13 msg=sin(2*pi*f1*t);
14 kf=.0628;%Modulation index
15 %Create the real and imaginary parts of a CW modulated carrier to be tracked.
16 Signal=exp(j*(2*pi*f*t+2*pi*kf*cumsum(msg)));%Modulated carrier
17 Signal1=exp(j*(2*pi*f*t));%Unmodulated carrier
18 %Initilize PLL Loop 
19 phi_hat(1)=30; 
20 e(1)=0; 
21 phd_output(1)=0; 
22 vco(1)=0; 
23 %Define Loop Filter parameters(Sets damping)
24 kp=0.15; %Proportional constant 
25 ki=0.1; %Integrator constant 
26 %PLL implementation 
27 for n=2:length(Signal) 
28 vco(n)=conj(exp(j*(2*pi*n*f/fs+phi_hat(n-1))));%Compute VCO 
29 phd_output(n)=imag(Signal(n)*vco(n));%Complex multiply VCO x Signal input 
30 e(n)=e(n-1)+(kp+ki)*phd_output(n)-ki*phd_output(n-1);%Filter integrator 
31 phi_hat(n)=phi_hat(n-1)+e(n);%Update VCO 
32 end; 
33 %Plot waveforms 
34 startplot = 1;
35 endplot = 1000;
36 
37 figure(1);
38 subplot(3,2,1);
39 plot(t(startplot:endplot), msg(startplot:endplot));
40 title('100 Hz message signal');
41 %xlabel('Time (seconds)');
42 ylabel('Amplitude');
43 grid;
44 
45 figure(1);
46 subplot(3,2,2);
47 plot(t(startplot:endplot), real(Signal(startplot:endplot)));
48 title('FM (1KHz carrier modulated with a 100 Hz message signal)');
49 %xlabel('Time (seconds)');
50 ylabel('Amplitude');
51 grid;
52 
53 figure(1)
54 subplot(3,2,3);
55 plot(t(startplot:endplot), e(startplot:endplot));
56 title('PLL Loop Filter/Integrator Output');
57 %xlabel('Time (seconds)');
58 ylabel('Amplitude');
59 grid;
60 
61 subplot(3,2,4);
62 plot(t(startplot:endplot), real(vco(startplot:endplot)));
63 title('VCO Output (PLL tracking the input signal)');
64 %xlabel('Time (seconds)');
65 ylabel('Amplitude');
66 grid;
67 
68 subplot(3,2,5);
69 plot(t(startplot:endplot), phd_output(startplot:endplot));
70 title('Phase Detecter Output');
71 xlabel('Time (seconds)');
72 ylabel('Amplitude');
73 grid;
74 
75 subplot(3,2,6);
76 plot(t(startplot:endplot), real(Signal1(startplot:endplot)));
77 title('Unmodulated Carrier');
78 xlabel('Time (seconds)');
79 ylabel('Amplitude');
80 grid;
View Code

 

仿真结果

全数字FM接收机2---仿真_第1张图片

你可能感兴趣的:(数字)