[time-nuts] PLL Math Question

Magnus Danielson magnus at rubidium.dyndns.org
Fri Mar 14 15:48:01 UTC 2014


On 12/03/14 20:25, Hal Murray wrote:
>
> magnus at rubidium.dyndns.org said:
>> 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.
>
> Also note that if a_avg is a power of 2, you can do it all with shifts rather
> than multiplies.

Indeed. For many purposes it suffice with that kind of resolution for it.

> Note that the shift is to the right which drops bits.  That suggests that you might want to work with x scaled relative to the raw data samples.  Consider a_avg to be 1/8, or a shift right 3 bits.  Suppose x_avg is 0 and you get a string of x samples of 2.  The shift throws away the 2 so x_avg never changes.

Indeed. The form I wrote it above makes it easy to understand this 
consequence.

It is always good to consider the consequence of bitwidth, and scaling 
factors for filters makes you require more. Some problems you solve by 
just throwing more bits of resolution/headroom onto it.

Cheers,
Magnus



More information about the Time-nuts_lists.febo.com mailing list