• 大小: 3KB
    文件类型: .m
    金币: 1
    下载: 0 次
    发布日期: 2021-06-14
  • 语言: Matlab
  • 标签: 5分  

资源简介

本代码针对的是锁相环工作在单载波模式下的仿真,修改参数后也可仿真在BPSK,QPSK模式。

资源截图

代码片段和文件信息

clear all;
close all;
%定义锁相环的工作模式:单载波为“1”、BPSK调制为“2”、QPSK调制为“3”
PLL_Mode = 1;
%仿真数据长度
Simulation_Length=1000;
%基带信号
if PLL_Mode == 1
    I_Data=ones(Simulation_Length1);
    Q_Data=I_Data;
else if PLL_Mode == 2
        I_Data=randi(Simulation_Length1)*2-1;
        Q_Data=zeros(Simulation_Length1);
    else
        I_Data=randi(Simulation_Length1)*2-1;
        Q_Data=randi(Simulation_Length1)*2-1;
    end
end
Signal_Source=I_Data + j*Q_Data;
%载波信号
Freq_Sample=2400;%采样率,Hz
Delta_Freq=-60;   %频偏,Hz
Time_Sample=1/Freq_Sample;
Delta_Phase=rand(1)*2*pi; %随机初相,Rad
Carrier=exp(j*(Delta_Freq/Freq_Sample*(1:Simulation_Length)+Delta_Phase));
%调制处理
Signal_Channel=Signal_Source.*Carrier‘;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%以下为锁相环处理过程
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%参数清零
Signal_PLL=zeros(Simulation_Length1);
NCO_Phase = zeros(Simulation_Length1);
Discriminator_Out=zeros(Simulation_Length1);
Freq_Control=zeros(Simulation_Length1);
PLL_Phase_Part=zeros(Simulation_Length1);
PLL_Freq_Part=zeros(Simulation_Length1);
%环路处理
C1=0.022013;
C2=0.00024722;
for i=2:Simulation_Length
    Signal_PLL(i)=Signal_Channel(i)*exp(-j*mod(NCO_Phase(i-1)2*pi));
    I_PLL(i)=real(Signal_PLL(i));
    Q_PLL(i)=imag(Signal_PLL(i));
    if PLL_Mode == 1
        Discriminator_Out(i)=atan2(Q_PLL(i)I_PLL(i));
    else if PLL_Mode == 2
            Discriminator_Out(i)=sign(I_PLL(i))*Q_PLL(i)/abs(Signal_PLL(i));
        else
            Discriminator_O

评论

共有 条评论

相关资源