[time-nuts] Re: Complex PLL

dschuecker Detlef.Schuecker at dschuecker.de
Mon Mar 22 22:56:27 UTC 2021


Hi,

>>>>
In the code you sent you used a division for phase detection as far as I
can tell.

Yes, but it is the Matlab model code, so I dont care about division. In 'real life' I multiply with the conjugate complex value. It has the same angle and different length, but I normalize anyway.

And the 'atan' is always 'atan2', sure.

For a non-complex PLL I beat down to zero the angle of the phase discriminator.
In this complex PLL I beat down to zero the imaginary part of the quotient.

Another very interesting detail: The carrier I pll on is at 2400Hz, I have to demodulate with a synched 1800Hz. This means that I have to find the complex value which has 3/4 of the angle without atan/cos/sin, sqrt is ok.

This C-Code does the trick:
cpl4.re=sqrt((1.0+cpl3.re)/2.0f);
cpl4.im=sqrt((1.0-cpl3.re)/2.0f);
cpl5.re=sqrt((1.0+cpl4.re)/2.0f);
cpl5.im=sqrt((1.0-cpl4.re)/2.0f);
CMUL(cpl5,cpl5,cpl4);
CMUL(cpl4,cpl5,cpl3);
CROT(T3,cpl3);

much fun !
Math rulez !
Cheers
Detlef

Am 19.03.2021 um 13:23 schrieb Magnus Danielson:
> Hi,
>
> On 2021-03-18 13:59, Detlef Schuecker via time-nuts wrote:
>> Hi,
>>
>> yes, got it, I think, thanks.
>>
>> I calculate the complex quotient of the incoming complex signal and the
>> local complex oscillator. I feed the imaginary part of the quotient to the
>> PI controller, thus forcing it to zero. The local oscillator is updated by
>> multiplying it with ( real(quotient)+j*PIOutput ). Forcing the imaginary
>> part of the quotient to zero means that incoming signal and local
>> oscillator are in phase.
>>
>> See Matlab code and the image.
>> No atan/cos/sin, just mere multiplication :))
> In the code you sent you used a division for phase detection as far as I
> can tell.
>
> The modeling approach you used is different enough that it took some
> time to decode it, and maybe I would have used a different set of
> variable names, but that's more me than the model.
>
> I often use a phase-accumulator / integrator to model (and synthesize)
> in PLL simulations.
>
> Anyway, good that you are on track. Once you have that basic I think you
> can quickly enough vary the theme.
>
> You could move over from imag to real and it would only change subtly.
>
> Cheers,
> Magnus
>
>> Thanks
>>
>> Cheers
>> Detlef Schücker
>> DD4WV
>>
>> clear
>> n=10000;
>> T1=0;
>> T2=0.01;
>> s0=exp(j*2*pi*200*(0:n-1)/n);
>> s1=zeros(1,n);
>> s2=zeros(1,n);
>> s3=zeros(1,n);
>> for(k=1:n)
>>       s1(k)=(s0(k)/T2);
>>       T1=T1+imag(s1(k))/4000;
>>       s2(k)=0.03*imag(s1(k))+T1;
>>       s3(k)=T2;
>>       T2=T2*(real(s1(k))+j*s2(k));
>>   
>> end;
>> plot(1:n,real(s3),'b.-',1:n,real(s0),'r.-')
>> return
>>
>>
>>
>>
>>
>> "Magnus Danielson" <magnus at rubidium.se> schrieb am 17.03.2021 19:20:49:
>>
>>> Von: "Magnus Danielson" <magnus at rubidium.se>
>>> An: time-nuts at lists.febo.com
>>> Datum: 17.03.2021 19:59
>>> Betreff: [time-nuts] Re: Complex PLL
>>>
>>> Hi,
>>>
>>> On 2021-03-17 17:20, Detlef Schuecker via time-nuts wrote:
>>>> Hi time-nuts,
>>>>
>>>> a PLL takes the phase difference of the incoming signal and the
>>>> synthesized signal and feeds that in a loop filter. The output of the
>> loop
>>>> filter is used to steer the local oscillator.
>>>>
>>>> In my setup I have an incoming complex signal and my local oscillator
>> is
>>>> generating a complex signal as well. So calculation of the phase
>>>> difference is just the quotient of the incoming signal and the local
>>>> oscillator, it is a sampled system. I take the quotient, calculate the
>>>> angle using the atan function and then I feed it in the loop filter, a
>> PI
>>>> controller. The output of the loop filter is converted to a complex
>> phase
>>>> increment for the local oscillator with the sin and cos function.
>>>>
>>>> Now I have to get rid of the atan, cos and sin functions.
>>>>
>>>> I am looking for a loop filter which takes the quotient of the
>>>> incoming/synthesized signal as a complex value. The output of this
>> loop
>>>> filter should be the phase increment for the local oscillator. It
>> should
>>>> not use the angle of the complex value explicitly, as this will
>> involve
>>>> the atan/cos/sin functions.
>>>>
>>>> Is someone aware of such a loop filter? I surfed through Gardners'
>>>> 'Phaselock Techniques' but did not find a hint.
>>> That book is full of hints. Costas loop is one. Actually, you could just
>>> do complex multiplication and only use the real output (and thus remove
>>> half the complex multiplication) and use that output of the
>>> multiplication as input to normal PI-regulator, that will lock up and
>>> achieve everything you want. You can then also remove the sine with a
>>> squarewave. There is some benefits and losses in doing that, which may
>>> or may not be relevant.
>>>
>>> There is a richness of complex detectors to be found in GPS literature,
>>> such as that of "Understanding GPS principles and applications" of
>>> Kaplan and Hegarty. You can also look at "Phase-locked loop circuit
>>> design" by Wolaver for additional inspiration. You end up finding that
>>> Garners' book is actually very comprehensive if you only take time to
>>> dwell into it.
>>>
>>> Let me know if you need more hints.
>>>
>>> Cheers and 73,
>>> Magnus SA0MAD
>>> _______________________________________________
>>> time-nuts mailing list -- time-nuts at lists.febo.com -- To unsubscribe
>>> send an email to time-nuts-leave at lists.febo.com
>>> To unsubscribe, go to and follow the instructions there.
>> _______________________________________________
>> time-nuts mailing list -- time-nuts at lists.febo.com -- To unsubscribe send an email to time-nuts-leave at lists.febo.com
>> To unsubscribe, go to and follow the instructions there.
> _______________________________________________
> time-nuts mailing list -- time-nuts at lists.febo.com -- To unsubscribe send an email to time-nuts-leave at lists.febo.com
> To unsubscribe, go to and follow the instructions there.
>




More information about the Time-nuts_lists.febo.com mailing list