modeling digital PLL in matlab

  • Follow


hi,
  I'm trying to model an existing DPLL in matlab. The DPLL has a
simple 1st order LPF and an NCO (numerical controlled oscillator).
The LPF has a proportionality gain and an integral gain.
I first used the transform s = [1 - (z^-1)]/T where T = sample period
to convert from z-domain to s-domain. Value of T is about 10 ns =
10^-8 seconds. I also tried the bilinear transform.
  The problem is in modeling the phase detector. For modeling the
phase detector, I get the right step response only if I put T = 1.

i.e let X be the input, Y be the output, and H be the LPF.
I put H(s) = Kp + Ki/sT, where Kp = proportionality gain, and Ki =
integrator gain, T = sampling period.

Then if I write the equation as (X - Y)/s = YH, I get the right
answer.
But if I write the euqation as (X - Y)/sT = YH, I do not get the right
answer.

I'm not able to understand the reason. The phase detector is basically
a counter (integrator). In the z-domain, the phase detector should be
modeled as 1/[1 - z^-(1)]. Translating to s-domain, it should become 1/
sT and not 1/s.

Can someone give an idea what is going on?

thanks
Ganesh
0
Reply ganesh 9/14/2010 3:53:34 PM

On 09/14/2010 08:53 AM, ganesh wrote:
> hi,
>    I'm trying to model an existing DPLL in matlab. The DPLL has a
> simple 1st order LPF and an NCO (numerical controlled oscillator).
> The LPF has a proportionality gain and an integral gain.
> I first used the transform s = [1 - (z^-1)]/T where T = sample period
> to convert from z-domain to s-domain. Value of T is about 10 ns =
> 10^-8 seconds. I also tried the bilinear transform.
>    The problem is in modeling the phase detector. For modeling the
> phase detector, I get the right step response only if I put T = 1.
>
> i.e let X be the input, Y be the output, and H be the LPF.
> I put H(s) = Kp + Ki/sT, where Kp = proportionality gain, and Ki =
> integrator gain, T = sampling period.
>
> Then if I write the equation as (X - Y)/s = YH, I get the right
> answer.
> But if I write the euqation as (X - Y)/sT = YH, I do not get the right
> answer.
>
> I'm not able to understand the reason. The phase detector is basically
> a counter (integrator). In the z-domain, the phase detector should be
> modeled as 1/[1 - z^-(1)]. Translating to s-domain, it should become 1/
> sT and not 1/s.
>
> Can someone give an idea what is going on?

It sounds like you may not be modeling the gain of the phase detector 
correctly, and it looks as if you're not modeling the integrating nature 
of the NCO at all.

You should determine your phase detector gain, either in number of 
counts per radian or number of counts per cycle depending on which one 
makes the arithmetic easier (I find that counts/cycle saves me from many 
many factors of pi that need to be correctly cancelled).

You should also determine your NCO transfer function.  If this is a 
typical NCO then you give it a phase increment, and every clock cycle 
the phase increment is added to the phase accumulator, and the phase 
accumulator value is used to generate a sine wave -- is this the case 
with yours?  Find it's transfer function.

With the correct phase detector gain and NCO transfer function, the 
correct loop transfer function should be apparent.

I'd also suggest that, since this is a pure sampled-time system, you'd 
be better off just doing your analysis in the z domain rather than 
making approximations of it in the s domain.  When you must relate the 
things behavior back to continuous time, do it with the final loop 
transfer function, instead of approximating each piece and hoping for 
the best.

-- 

Tim Wescott
Wescott Design Services
http://www.wescottdesign.com

Do you need to implement control loops in software?
"Applied Control Theory for Embedded Systems" was written for you.
See details at http://www.wescottdesign.com/actfes/actfes.html
0
Reply Tim 9/14/2010 4:36:59 PM


On Sep 14, 9:36=A0pm, Tim Wescott <t...@seemywebsite.com> wrote:
> On 09/14/2010 08:53 AM, ganesh wrote:
>
>
>
> > hi,
> > =A0 =A0I'm trying to model an existing DPLL in matlab. The DPLL has a
> > simple 1st order LPF and an NCO (numerical controlled oscillator).
> > The LPF has a proportionality gain and an integral gain.
> > I first used the transform s =3D [1 - (z^-1)]/T where T =3D sample peri=
od
> > to convert from z-domain to s-domain. Value of T is about 10 ns =3D
> > 10^-8 seconds. I also tried the bilinear transform.
> > =A0 =A0The problem is in modeling the phase detector. For modeling the
> > phase detector, I get the right step response only if I put T =3D 1.
>
> > i.e let X be the input, Y be the output, and H be the LPF.
> > I put H(s) =3D Kp + Ki/sT, where Kp =3D proportionality gain, and Ki =
=3D
> > integrator gain, T =3D sampling period.
>
> > Then if I write the equation as (X - Y)/s =3D YH, I get the right
> > answer.
> > But if I write the euqation as (X - Y)/sT =3D YH, I do not get the righ=
t
> > answer.
>
> > I'm not able to understand the reason. The phase detector is basically
> > a counter (integrator). In the z-domain, the phase detector should be
> > modeled as 1/[1 - z^-(1)]. Translating to s-domain, it should become 1/
> > sT and not 1/s.
>
> > Can someone give an idea what is going on?
>
> It sounds like you may not be modeling the gain of the phase detector
> correctly, and it looks as if you're not modeling the integrating nature
> of the NCO at all.
>
> You should determine your phase detector gain, either in number of
> counts per radian or number of counts per cycle depending on which one
> makes the arithmetic easier (I find that counts/cycle saves me from many
> many factors of pi that need to be correctly cancelled).
>
> You should also determine your NCO transfer function. =A0If this is a
> typical NCO then you give it a phase increment, and every clock cycle
> the phase increment is added to the phase accumulator, and the phase
> accumulator value is used to generate a sine wave -- is this the case
> with yours? =A0Find it's transfer function.
>
> With the correct phase detector gain and NCO transfer function, the
> correct loop transfer function should be apparent.
>
> I'd also suggest that, since this is a pure sampled-time system, you'd
> be better off just doing your analysis in the z domain rather than
> making approximations of it in the s domain. =A0When you must relate the
> things behavior back to continuous time, do it with the final loop
> transfer function, instead of approximating each piece and hoping for
> the best.
>
> --
>
> Tim Wescott
> Wescott Design Serviceshttp://www.wescottdesign.com
>
> Do you need to implement control loops in software?
> "Applied Control Theory for Embedded Systems" was written for you.
> See details athttp://www.wescottdesign.com/actfes/actfes.html


I computed the NCO and phase_det gains, and things seem better.
The NCO is a counter, the MSB of which is a "clock". The output of LPF
is added as the LSB k-bits to the NCO.
So, if the NCO is n bits, I take the gain of NCO as 1/(2^(n-k)). I
dont think I need to do anything more for the NCO... right?

ganesh
0
Reply ganesh 9/15/2010 3:13:51 PM

On Sep 15, 11:13=A0am, ganesh <ganeshs...@gmail.com> wrote:
> On Sep 14, 9:36=A0pm, Tim Wescott <t...@seemywebsite.com> wrote:
>
>
>
> > On 09/14/2010 08:53 AM, ganesh wrote:
>
> > > hi,
> > > =A0 =A0I'm trying to model an existing DPLL in matlab. The DPLL has a
> > > simple 1st order LPF and an NCO (numerical controlled oscillator).
> > > The LPF has a proportionality gain and an integral gain.
> > > I first used the transform s =3D [1 - (z^-1)]/T where T =3D sample pe=
riod
> > > to convert from z-domain to s-domain. Value of T is about 10 ns =3D
> > > 10^-8 seconds. I also tried the bilinear transform.
> > > =A0 =A0The problem is in modeling the phase detector. For modeling th=
e
> > > phase detector, I get the right step response only if I put T =3D 1.
>
> > > i.e let X be the input, Y be the output, and H be the LPF.
> > > I put H(s) =3D Kp + Ki/sT, where Kp =3D proportionality gain, and Ki =
=3D
> > > integrator gain, T =3D sampling period.
>
> > > Then if I write the equation as (X - Y)/s =3D YH, I get the right
> > > answer.
> > > But if I write the euqation as (X - Y)/sT =3D YH, I do not get the ri=
ght
> > > answer.
>
> > > I'm not able to understand the reason. The phase detector is basicall=
y
> > > a counter (integrator). In the z-domain, the phase detector should be
> > > modeled as 1/[1 - z^-(1)]. Translating to s-domain, it should become =
1/
> > > sT and not 1/s.
>
> > > Can someone give an idea what is going on?
>
> > It sounds like you may not be modeling the gain of the phase detector
> > correctly, and it looks as if you're not modeling the integrating natur=
e
> > of the NCO at all.
>
> > You should determine your phase detector gain, either in number of
> > counts per radian or number of counts per cycle depending on which one
> > makes the arithmetic easier (I find that counts/cycle saves me from man=
y
> > many factors of pi that need to be correctly cancelled).
>
> > You should also determine your NCO transfer function. =A0If this is a
> > typical NCO then you give it a phase increment, and every clock cycle
> > the phase increment is added to the phase accumulator, and the phase
> > accumulator value is used to generate a sine wave -- is this the case
> > with yours? =A0Find it's transfer function.
>
> > With the correct phase detector gain and NCO transfer function, the
> > correct loop transfer function should be apparent.
>
> > I'd also suggest that, since this is a pure sampled-time system, you'd
> > be better off just doing your analysis in the z domain rather than
> > making approximations of it in the s domain. =A0When you must relate th=
e
> > things behavior back to continuous time, do it with the final loop
> > transfer function, instead of approximating each piece and hoping for
> > the best.
>
> > --
>
> > Tim Wescott
> > Wescott Design Serviceshttp://www.wescottdesign.com
>
> > Do you need to implement control loops in software?
> > "Applied Control Theory for Embedded Systems" was written for you.
> > See details athttp://www.wescottdesign.com/actfes/actfes.html
>
> I computed the NCO and phase_det gains, and things seem better.
> The NCO is a counter, the MSB of which is a "clock". The output of LPF
> is added as the LSB k-bits to the NCO.

okay, so that signal is your instantaneous frequency.  that gets
integrated w.r.t. time to be the instantaneous phase.

> So, if the NCO is n bits, I take the gain of NCO as 1/(2^(n-k)). I
> dont think I need to do anything more for the NCO... right?

now, even though the phase is clipped at +/- pi, or at 0 and 2*pi (or
some scaled version of either), that is the phase that is compared
directly to the hypothetical phase of incoming signal that your PLL is
locking to.  it is that phase difference that gets fed back with some
"controller" (usually called PID) for proportional, integrator,
differentiator.  even if it's the most simple proportional controller
(where that phase difference gets scaled by a constant k_P), there
always remains that integrator that is inherent to the NCO (just like
there was to the VCO in those old semi-analog PLL chips).

r b-j
0
Reply robert 9/16/2010 6:11:17 PM

3 Replies
696 Views

(page loaded in 0.211 seconds)

Similiar Articles:













7/22/2012 11:18:01 PM


Reply: