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.
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.
Bob - AE6RV
Bob,
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.
Cheers,
Magnus
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...
Bob
From: Magnus Danielson magnus@rubidium.dyndns.org
To: time-nuts@febo.com
Sent: Wednesday, March 12, 2014 12:51 PM
Subject: Re: [time-nuts] PLL Math Question
Bob,
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.
Cheers,
Magnus
time-nuts mailing list -- time-nuts@febo.com
To unsubscribe, go to https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts
and follow the instructions there.
"x_avg = x_avg + (x - x_avg) * a_avg;"
Hi again Magnus,
In fact, I just post-processed some data using that formula in perl. It looks great, and will indeed save me code and memory space. And, it can be a user variable, rather than hard-coded. Thanks for the heads up!
Bob
From: Magnus Danielson magnus@rubidium.dyndns.org
To: time-nuts@febo.com
Sent: Wednesday, March 12, 2014 12:51 PM
Subject: Re: [time-nuts] PLL Math Question
Bob,
<snip>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.
Cheers,
Magnus
Hi Bob,
On 12/03/14 19:26, Bob Stewart wrote:
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...
The effect of additional filtering can be a little tricky to analyze
sometimes, but the exponential averager, the normal 1-pole low-pass
filter, is however well-understood when the cut-off frequency is well
above the normal PI-loop bandwith. K*4 seems to pop up in my head.
It's a hint which comes from experience of others as well as myself.
You can also look into the Stanford Research PRS-10 manual, which also
optionally have such a filter in it's PPS slaving mode.
Cheers,
Magnus
Hi Bob,
On 12/03/14 23:16, Bob Stewart wrote:
"x_avg = x_avg + (x - x_avg) * a_avg;"
Hi again Magnus,
In fact, I just post-processed some data using that formula in perl. It looks great, and will indeed save me code and memory space. And, it can be a user variable, rather than hard-coded. Thanks for the heads up!
Proven in battle, dead easy to code, well understood. Happy to share.
Cheers,
Magnus