DSPRelated.com
Forums

Software PLL - Help!

Started by tomz March 12, 2008
OK, I've been fighting with the code for a software PLL for a week now. 
I'm sure I'm missing something simple, but I haven't been able to figure
it out.

For the code, my starting point is C R Bond's implementation
(http://www.crbond.com/pll.htm) based on Best's DPLL-like SPLL (section
5.3.2 in the 4th edition).  I have converted this to C#.  The only other
change I made was to replace the references to 'u1[n-1]' with '(n-1)%2'. 
This seems reasonable as u1 simply toggles between 0 and 1 at each
instance.

For an input time stamp list, I generate a perfect fixed-frequency clock
(in the time domain, not the voltage domain), then add random noise and a
sinusoidal modulation to it.  A plot of the period looks like a *very*
fuzzy sine wave, and a plot of the time-interval error looks like a
slightly fuzzy sine wave.  So far, so good.

I then select a zeta (0.707) and omega3dB (as a fraction of the clock
frequency) and, using Best's Active PI equations, I calculate omegan,
tau1, tau2, and K0.  Ub I am currently simply setting to 1.0 as a
'normalized value'.
*** This is the first place where I'm unsure, as changing the value of Ub
does seem to significantly change the results.  However, in the setup to
this point the amplitude of the signal in the voltage domain appears to be
irrelevant - only the edge time stamps matter.  So I'm not sure how/why Ub
would matter, or how I should choose it. ***

I pass my data through the dpll() function and convert the output time
stamps back into time-interval error.  Depending on where I have chosen my
omega3dB in relation to the known modulation frequency, I have certain
expectations about what the result will look like - e.g. the modulation
should be relatively unchanged, or modulation should be severely
attenuated.  

However, the results do not look particularly different in shape (they
*are* different in peak-peak magnitude).  For example, say the mod freq is
1/2000 of the clock freq.  The only significant difference in the output
between an omega3dB set at 1/100 of the clock freq and 1/10000 of the
clock frequency is the amplitude - the shape is essentially unchanged (a
highly-attenuated version of the input time-interval error plot, offset
somewhat in phase relative to the modulation).  The pk-pk of the input
time-interval error is >7ns; regardless of the omega3dB ratio I set, the
pk-pk of the output seems to always be <100ps.

Anyway, that is where I am stuck, and I am hoping that someone here may be
able to provide the small push needed to allow me to get past this
aggravating situation and move forward...

Tom



On Mar 12, 3:46&#4294967295;pm, "tomz" <tz...@yahoo.com> wrote:
> OK, I've been fighting with the code for a software PLL for a week now. > I'm sure I'm missing something simple, but I haven't been able to figure > it out. > > For the code, my starting point is C R Bond's implementation > (http://www.crbond.com/pll.htm) based on Best's DPLL-like SPLL (section > 5.3.2 in the 4th edition). &#4294967295;I have converted this to C#. &#4294967295;The only other > change I made was to replace the references to 'u1[n-1]' with '(n-1)%2'. > This seems reasonable as u1 simply toggles between 0 and 1 at each > instance. > > For an input time stamp list, I generate a perfect fixed-frequency clock > (in the time domain, not the voltage domain), then add random noise and a > sinusoidal modulation to it. &#4294967295;A plot of the period looks like a *very* > fuzzy sine wave, and a plot of the time-interval error looks like a > slightly fuzzy sine wave. &#4294967295;So far, so good. > > I then select a zeta (0.707) and omega3dB (as a fraction of the clock > frequency) and, using Best's Active PI equations, I calculate omegan, > tau1, tau2, and K0. &#4294967295;Ub I am currently simply setting to 1.0 as a > 'normalized value'. > *** This is the first place where I'm unsure, as changing the value of Ub > does seem to significantly change the results. &#4294967295;However, in the setup to > this point the amplitude of the signal in the voltage domain appears to be > irrelevant - only the edge time stamps matter. &#4294967295;So I'm not sure how/why Ub > would matter, or how I should choose it. *** > > I pass my data through the dpll() function and convert the output time > stamps back into time-interval error. &#4294967295;Depending on where I have chosen my > omega3dB in relation to the known modulation frequency, I have certain > expectations about what the result will look like - e.g. the modulation > should be relatively unchanged, or modulation should be severely > attenuated. &#4294967295; > > However, the results do not look particularly different in shape (they > *are* different in peak-peak magnitude). &#4294967295;For example, say the mod freq is > 1/2000 of the clock freq. &#4294967295;The only significant difference in the output > between an omega3dB set at 1/100 of the clock freq and 1/10000 of the > clock frequency is the amplitude - the shape is essentially unchanged (a > highly-attenuated version of the input time-interval error plot, offset > somewhat in phase relative to the modulation). &#4294967295;The pk-pk of the input > time-interval error is >7ns; regardless of the omega3dB ratio I set, the > pk-pk of the output seems to always be <100ps. > > Anyway, that is where I am stuck, and I am hoping that someone here may be > able to provide the small push needed to allow me to get past this > aggravating situation and move forward... > > Tom
you are trying to filter out the FM modulation present on the input when the loop BW is << the modulation frequency, i.e the loop will not track the modulation... and you are trying to pass the FM modulation present on the input when the loop BW is >> the modulation frequency i.e the loop will track the modulation ... is that what you are trying to do? what is the modualtation frequency? what is the phase detector comparison freq? what are the loop BWs? Mark
>On Mar 12, 3:46=A0pm, "tomz" <tz...@yahoo.com> wrote: >> OK, I've been fighting with the code for a software PLL for a week
now.
>> I'm sure I'm missing something simple, but I haven't been able to
figure
>> it out. >> >> For the code, my starting point is C R Bond's implementation >> (http://www.crbond.com/pll.htm) based on Best's DPLL-like SPLL
(section
>> 5.3.2 in the 4th edition). =A0I have converted this to C#. =A0The only
oth=
>er >> change I made was to replace the references to 'u1[n-1]' with
'(n-1)%2'.
>> This seems reasonable as u1 simply toggles between 0 and 1 at each >> instance. >> >> For an input time stamp list, I generate a perfect fixed-frequency
clock
>> (in the time domain, not the voltage domain), then add random noise and
a
>> sinusoidal modulation to it. =A0A plot of the period looks like a
*very*
>> fuzzy sine wave, and a plot of the time-interval error looks like a >> slightly fuzzy sine wave. =A0So far, so good. >> >> I then select a zeta (0.707) and omega3dB (as a fraction of the clock >> frequency) and, using Best's Active PI equations, I calculate omegan, >> tau1, tau2, and K0. =A0Ub I am currently simply setting to 1.0 as a >> 'normalized value'. >> *** This is the first place where I'm unsure, as changing the value of
Ub
>> does seem to significantly change the results. =A0However, in the setup
to=
> >> this point the amplitude of the signal in the voltage domain appears to
be=
> >> irrelevant - only the edge time stamps matter. =A0So I'm not sure
how/why =
>Ub >> would matter, or how I should choose it. *** >> >> I pass my data through the dpll() function and convert the output time >> stamps back into time-interval error. =A0Depending on where I have
chosen =
>my >> omega3dB in relation to the known modulation frequency, I have certain >> expectations about what the result will look like - e.g. the
modulation
>> should be relatively unchanged, or modulation should be severely >> attenuated. =A0 >> >> However, the results do not look particularly different in shape (they >> *are* different in peak-peak magnitude). =A0For example, say the mod
freq =
>is >> 1/2000 of the clock freq. =A0The only significant difference in the
output=
> >> between an omega3dB set at 1/100 of the clock freq and 1/10000 of the >> clock frequency is the amplitude - the shape is essentially unchanged
(a
>> highly-attenuated version of the input time-interval error plot,
offset
>> somewhat in phase relative to the modulation). =A0The pk-pk of the
input
>> time-interval error is >7ns; regardless of the omega3dB ratio I set,
the
>> pk-pk of the output seems to always be <100ps. >> >> Anyway, that is where I am stuck, and I am hoping that someone here may
be=
> >> able to provide the small push needed to allow me to get past this >> aggravating situation and move forward... >> >> Tom > >you are trying to filter out the FM modulation present on the input >when the loop BW is << the modulation frequency, i.e the loop will not >track the modulation... and you are trying to pass the FM modulation >present on the input when the loop BW is >> the modulation frequency >i.e the loop will track the modulation ... > >is that what you are trying to do?
That is correct.
>what is the modualtation frequency?
The particular sample data I'm working with is a 100 MHz clock with a 50 KHz sinusoidal modulation. In practice, the final code needs to be independent of clock frequency or modulation frequency (or even possibly multiple modulation frequencies).
>what is the phase detector comparison freq?
It's a digital PLL implementation, so the phase detector is updated with each input edge. So 200 MHz for the 100 MHz clock.
>what are the loop BWs?
I've looked at frequency ratios anywhere from 100 (i.e. loop BW = 1 MHz) to 10000 (loop BW = 10 KHz). Note that these are -3dB frequencies, not natural frequency. Thanks for any help you can provide. Tom
On Mar 12, 8:01&#4294967295;pm, "tomz" <tz...@yahoo.com> wrote:
> >On Mar 12, 3:46=A0pm, "tomz" <tz...@yahoo.com> wrote: > >> OK, I've been fighting with the code for a software PLL for a week > now. > >> I'm sure I'm missing something simple, but I haven't been able to > figure > >> it out. > > >> For the code, my starting point is C R Bond's implementation > >> (http://www.crbond.com/pll.htm) based on Best's DPLL-like SPLL > (section > >> 5.3.2 in the 4th edition). =A0I have converted this to C#. =A0The only > oth= > >er > >> change I made was to replace the references to 'u1[n-1]' with > '(n-1)%2'. > >> This seems reasonable as u1 simply toggles between 0 and 1 at each > >> instance. > > >> For an input time stamp list, I generate a perfect fixed-frequency > clock > >> (in the time domain, not the voltage domain), then add random noise and > a > >> sinusoidal modulation to it. =A0A plot of the period looks like a > *very* > >> fuzzy sine wave, and a plot of the time-interval error looks like a > >> slightly fuzzy sine wave. =A0So far, so good. > > >> I then select a zeta (0.707) and omega3dB (as a fraction of the clock > >> frequency) and, using Best's Active PI equations, I calculate omegan, > >> tau1, tau2, and K0. =A0Ub I am currently simply setting to 1.0 as a > >> 'normalized value'. > >> *** This is the first place where I'm unsure, as changing the value of > Ub > >> does seem to significantly change the results. =A0However, in the setup > to= > > >> this point the amplitude of the signal in the voltage domain appears to > be= > > >> irrelevant - only the edge time stamps matter. =A0So I'm not sure > how/why = > >Ub > >> would matter, or how I should choose it. *** > > >> I pass my data through the dpll() function and convert the output time > >> stamps back into time-interval error. =A0Depending on where I have > chosen = > >my > >> omega3dB in relation to the known modulation frequency, I have certain > >> expectations about what the result will look like - e.g. the > modulation > >> should be relatively unchanged, or modulation should be severely > >> attenuated. =A0 > > >> However, the results do not look particularly different in shape (they > >> *are* different in peak-peak magnitude). =A0For example, say the mod > freq = > >is > >> 1/2000 of the clock freq. =A0The only significant difference in the > output= > > >> between an omega3dB set at 1/100 of the clock freq and 1/10000 of the > >> clock frequency is the amplitude - the shape is essentially unchanged > (a > >> highly-attenuated version of the input time-interval error plot, > offset > >> somewhat in phase relative to the modulation). =A0The pk-pk of the > input > >> time-interval error is >7ns; regardless of the omega3dB ratio I set, > the > >> pk-pk of the output seems to always be <100ps. > > >> Anyway, that is where I am stuck, and I am hoping that someone here may > be= > > >> able to provide the small push needed to allow me to get past this > >> aggravating situation and move forward... > > >> Tom > > >you are trying to filter out the FM modulation present on the input > >when the loop BW is << the modulation frequency, i.e the loop will not > >track the modulation... and you are trying to pass the FM modulation > >present on the input when the loop BW is >> the modulation frequency > >i.e the loop will track the modulation ... > > >is that what you are trying to do? > > That is correct. > > >what is the modualtation frequency? > > The particular sample data I'm working with is a 100 MHz clock with a 50 > KHz sinusoidal modulation. &#4294967295;In practice, the final code needs to be > independent of clock frequency or modulation frequency (or even possibly > multiple modulation frequencies). > > >what is the phase detector comparison freq? > > It's a digital PLL implementation, so the phase detector is updated with > each input edge. &#4294967295;So 200 MHz for the 100 MHz clock. > > >what are the loop BWs? > > I've looked at frequency ratios anywhere from 100 (i.e. loop BW = 1 MHz) > to 10000 (loop BW = 10 KHz). &#4294967295;Note that these are -3dB frequencies, not > natural frequency. > > Thanks for any help you can provide. > > Tom- Hide quoted text - > > - Show quoted text -
assumming 100 MHz "clock" means the PLL input frequency and not the sampling rate then it sounds resonable.. What is the sampling rate? And the PLL output is the same freq as the input? i.e. your N and R divider ratios are both = 1? I would arrange to sweep the 50kHz modulation from a lower freq to a higher one and observe the modulation at the PLL output. Maybe the PLL loop BW is not what you think it is... Mark
> assumming 100 MHz "clock" means the PLL input frequency and not the > sampling rate then it sounds resonable.. What is the sampling rate?
Yes, 100 MHz is the PLL input frequency as well as the output frequency. The code is implementing an interrupt-driven DPLL (following Best's example), so it 'samples' and calculates on every edge of the incoming signal. So the effective sampling rate is 200 MHz, though the samples are not exactly equally spaced in time due to the jitter on the incoming signal.
> I would arrange to sweep the 50kHz modulation from a lower freq to a > higher one and observe the modulation at the PLL output. Maybe the > PLL loop BW is not what you think it is...
Good idea. I'll have to generate some new data files to examine that. Thanks for your help. Tom
> Yes, 100 MHz is the PLL input frequency as well as the output > frequency. > > The code is implementing an interrupt-driven DPLL (following Best's > example), so it 'samples' and calculates on every edge of the incoming > signal. &#4294967295;So the effective sampling rate is 200 MHz, though the samples > are not exactly equally spaced in time due to the jitter on the > incoming signal. >
OK, I don't understand this part, I was thinking of a system / NCO that is running at a sampling rate well above the input/output frequency etc... maybe someone else is familiar with this technique... Mark