[PROD][PM]ロックリングアナログ位相復調


% 

% 



clear

close all

clc



fs=1000;	% 

tend=100;

t=0:1/fs:tend;

t(end)=[];

fc=1;		% 

fb=100;		%PM 

gain=0.2;	% 

EbN0=20;



[b,a]=cheby2(3,30,0.2);	% 

num=gain*b;

den=conv([1 -1],a)+[num,0];

pole=roots(den);

abs(pole)		% 

fvtool(b,a);

lb=length(b);

la=length(a)-1;

bb=zeros(1,lb);

aa=zeros(1,la);



cio=cos(2*pi*fc*t+cos(2*pi*fb*t));

cqo=sin(2*pi*fc*t+cos(2*pi*fb*t));

ci=awgn(cio,EbN0,'measured');

cq=awgn(cqo,EbN0,'measured');

cout=complex(zeros(size(ci)),zeros(size(cq)));

phase_out=zeros(size(ci));

phase=0;



for k=1:length(cout)

	cout(k)=exp(1i*phase);

	err=complex(ci(k),cq(k))*exp(-1i*phase);

	phase_out(k)=angle(err);

	err=phase_out(k)*gain;

	bb=[err,bb(1:lb-1)];

	err=sum(bb.*b)-sum(aa.*a(2:end));

	aa=[err,aa(1:la-1)];

	phase=phase+err;

	if phase>pi, phase=phase-2*pi;

	elseif phase<-pi, phase=phase+2*pi;end

end



CO=fft(cio);

CO=abs(CO)/length(CO);

CR=fft(real(cout));

CR=abs(CR)/length(CR);

F=linspace(0,fs,length(CR));

N=ceil(length(F)/2);

plot(F(1:N),CO(1:N),'r');

hold on

plot(F(1:N),CR(1:N),'b');

figure

plot(t,phase_out);

PO=fft(phase_out);

PO=abs(PO)/length(PO);

figure

plot(F(1:N),PO(1:N));