[time-nuts] PLL Math Question

Bob Stewart bob at evoria.net
Wed Mar 12 14:26:06 EDT 2014

Hi Magnus,

Thanks very much for this response!  It will be very easy to add the exponential averager to my code and do a comparison to the moving average.  I have no experience with PI/PID.  I'll have to look over the literature I have on them and relate that to what I'm controlling.

It should be mentioned that I'm more interested in the adventure than in just copying someone else's code or formulae and pumping this out.  I have an idea of how I want to do this and...


> From: Magnus Danielson <magnus at rubidium.dyndns.org>
>To: time-nuts at febo.com 
>Sent: Wednesday, March 12, 2014 12:51 PM
>Subject: Re: [time-nuts] PLL Math Question
>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.
>time-nuts mailing list -- time-nuts at febo.com
>To unsubscribe, go to https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts
>and follow the instructions there.

More information about the time-nuts mailing list