[time-nuts] Thunderbolt? (re simple gpsdo.)
Hal Murray
hmurray at megapathdsl.net
Tue Jan 3 03:48:12 UTC 2012
>> For those who aren't familiar with this trick, it's easy to make a low
>> pass filter in software:
>> X = X*(1-k) + k*new
> Designing filters seems like an art. What is the frequency response of the
> above for different values of k? I tend to like FIR filters because I think
> I understand them better. I think yours is an IIR.
It's a simple 1 pole filter. The corner frequency scales with the sample
rate. If you have N samples per second and k is 1/K, then the time constant
is K/N seconds. So with 1 PPS and an 8 bit shift, you get a time constant of
256 seconds.
It's just a trick to add to your collection. It's only advantage is that it
doesn't take many CPU cycles. It's just shifts and adds, no multiplies or
floating point. I first saw it used to compute round trip times on early
networking code.
You do have to get the scaling right: if k is right shift by 8 bits, X has to
be stored shifted left 8 bits so the right shift doesn't throw away too much
info. You may need to store X shifted farther left, depending on the
accuracy you need. (Or maybe you don't care about accuracy and don't need to
shift.)
It may be easier to think of X and a fraction with the binary point on the
left of the word. Then instead of storing X shifted left, the question is
how wide does X have to be.
--
These are my opinions, not necessarily my employer's. I hate spam.
More information about the Time-nuts_lists.febo.com
mailing list