[time-nuts] PLL Math Question

Bob Stewart bob at evoria.net
Thu Mar 13 19:19:57 EDT 2014


OK, gotcha.  But, this is in assembler, and anything wider than 3 bytes becomes tedious.  Also, anything larger than 3 bytes starts using a lot of space in a hurry.  Three byte fields allow me to use 256ths for gain and take the result directly from the two high order bytes without any shifting.  And as I mentioned to Hal in a separate post: when I hand-coded the exponential averager the results were actually good.  I was forgetting to convert to decimal to compare values to the decimal run.  For example: 0x60 doesn't look like 0.375 until you convert to decimal and divide by 256.

This has been most informative and certainly gives me more options.

Bob





>________________________________
> From: Chris Albertson <albertson.chris at gmail.com>
>To: Bob Stewart <bob at evoria.net>; Discussion of precise time and frequency measurement <time-nuts at febo.com> 
>Sent: Thursday, March 13, 2014 5:42 PM
>Subject: Re: [time-nuts] PLL Math Question
> 
>
>
>You don't really shift so much as just change the way you think about it.   The way to think about it is not that you have "16th" but that you have the "binary point" force places over.   It works just like a decimal point.  If you multiply two numbers each that has four places to the right of the point you have now eight places to the right.  You can shift it or not.  If you use 64 bit "longs" you sand up not having to shift so much because those can cary up to about 32 binary places.
>
>
>
>
>On Thu, Mar 13, 2014 at 12:10 PM, Bob Stewart <bob at evoria.net> wrote:
>
>Dennis,
>>
>>I just realized that I could do the math in sixteenths.  So, for 7/16ths multiply by 7 before shifting(i.e. dividing) and rounding.  That would probably give enough granularity.  I'll have to think about it.  It does open new doors.
>>
>>thanks,
>>
>>Bob
>>
>>
>>
>>
>>
>>>________________________________
>>> From: Dennis Ferguson <dennis.c.ferguson at gmail.com>
>>>To: Discussion of precise time and frequency measurement <time-nuts at febo.com>
>>>Cc: Hal Murray <hmurray at megapathdsl.net>
>>>Sent: Thursday, March 13, 2014 1:58 PM
>>
>>>Subject: Re: [time-nuts] PLL Math Question
>>>
>>>
>>
>>>Note that you can't do fixed-point computations exactly the same way
>>>you would do it in floating point, you often need to rearrange the equations
>>>a bit.  You can usually find a rearrangement which provides equivalent
>>>results, however.  Let's define an extra variable, x_sum, where
>>>
>>>    x_avg = x_sum * a_avg;
>>>
>>>The equation above can then be rewritten in terms of x_sum, i.e.
>>>
>>>    x_sum = x_sum * (1 - a_avg) + x;
>>>
>>>With an a_avg of 1/8 you'll instead be multiplying x_sum by 7, shifting
>>>it right 3 bits (you might want to round before the shift) and adding x.
>>>The new value of x_avg can be computed from the new value of x_sum with a
>>>shift (you might want to round that too), or you could pretend that x_sum
>>>is a fixed-point number with the decimal point 3 bits from the right.
>>>In either case x_sum carries enough bits that you don't lose precision.
>>>
>>>
>>
>>_______________________________________________
>>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.
>>
>
>
>
>-- 
>
>Chris Albertson
>Redondo Beach, California 
>
>


More information about the time-nuts mailing list