## Test PLL against step change in phase Started by 7 years ago7 replieslatest reply 7 years ago112 views

I wrote a simulation for second order PLL and I would like to test it with a input to see whether my PLL can track the phase.  I would like to change phase of my sinusoidal signal with step with magnitude 10 rad. Therefore that's what I did:

F=60;
t=0:Ts:2-Ts;
idx=find(t>=0);
theta(idx)=pi/180*10*ones(1,length(idx));
in=sin(2*pi*F*t+theta);
out=pll(in);
plot(t,out,t,theta)

However these two phase differ a lot. I am wondering can anyone tell me if there is any problem with above script to only create step change in the phase. Or I should ask is above script the correct way of testing second order PLL?

Thanks

[ - ] Ask yourself what would happen if you had a step change of exactly $$2\pi$$ radians in phase -- what would happen to the signal?  What would your PLL do in response?  If you haven't twigged to it yet, please tell me what $$\sin \left ( x + 2 \pi \right )$$ is equal to.  Now ask what a change by 10 radians will look like.

Stop and ponder that before reading on.

Now, (spoiler alert!) ask yourself what the linear range of your phase detector might be.  Are you testing your PLL for real step changes that are that large?  Or are you testing your PLL for step changes to get an idea of how the loop performs when it is being linear.  If the latter, perhaps you want to use a step change magnitude that keeps things linear?

[ - ] I know what step change would do to my signal or PLL but I was asking is above code reasonable to check whether PLL is working or not (close to zero phase error). I know magnitude of Step change should be small but what values is considered as small right now mine is like 0.1.

[ - ] It all depends on the coefficients of your PLL. The code you give is just a way to create a sinusoid with a base frequency plus a frequency shift. In order to have a better representation of that I would write the frequency shift as a percentage of the original frequency and add a static phase offset (your method is better if you want to create some strange frequency shift evolution):

theta = offset;

in=sin(2*pi*F(1+0.05)*t+theta);  % for a 5% frequency shift

As said Tim, try first with a very small frequency shift and increase it, you will see what is the bandwidth of your 2nd order PLL.

[ - ] I am looking for comparing the performance of system by comparing the reference phase and output phase to see whether they match eventually. In your case how may I plot the input phase ? Since I am changing frequency by 5% therefore the phase change will be 0.05*t, is that correct so this is like a ramp change in phase.

[ - ] You're right. If you don't want a frequency offset you keep only:

theta = offset;

in=sin(2*pi*F*t+theta);

And then you'll have your phase offset of theta.

What is the point to have a second order PLL if you don't track a frequency offset? A first order is enough and more precise than a second order in that case.

[ - ] Thanks Olivert, however I have a question regardless of value I use for theta or F, can you tell me what should be plotted against time, I mean what do you call as a input or reference phase ? is it like :

plot(t, theta)

or

plot(t, 2*pi*F*t+theta)

Since 2*pi*F*t is also considered as part of sine.

[ - ] 