[time-nuts] PLL Math Question
magnus at rubidium.dyndns.org
Wed Mar 12 13:51:26 EDT 2014
On 12/03/14 18:24, Bob Stewart wrote:
> Now that I've got the TIC going, I'm working on the PLL math
> for my GPSDO. My question is about moving averages. I've
> put in a moving average for the TIC. From that, I've
> calculated the slope, and have put a moving average on the
> slope to settle it down. I think this boils down to a
> moving average of a moving average. If both are 16 seconds
> long, is this essentially a 32 second moving average of the
> TIC, or is it some other function? I read briefly about
> averages of averages last night, but I'm not sure I
> understood the conclusion. This is all "clean code" so I
> may be over-complicating things, but I'm OK with that.
When you serialize two averages you maintain the same time-constant of
the average, but you get two 6 dB slopes on top of each other to form a
12 dB slope, while it is flat on the pass-band.
You should be careful about use of averager inside the loop. A moving
averager adds a zero in the loop, and you want to make sure you
understand what that zero will do to the overall control-loop. Here you
have two of them, as you run two average zeros in series.
I prefer to use a PI or PID loop for such a control-loop, and
potentially an exponential averager or two in there. If you make sure
the exponential averager has a wide enough bandwidth, you can use
standard PI dimensioning formulas, but achieve the tighter slope which
the exponential averagers contribute to.
> NOTE: The reason I'm using 16 seconds is that I'm becoming memory limited. I'm switching to an 18F2320, but that only gets me more program memory. I'm constrained to this chip on an existing board.
Exponential averger takes much less memory. Consider this code:
x_avg = x_avg + (x - x_avg) * a_avg;
Where a_avg is the time-constant control parameter.
More information about the time-nuts