[time-nuts] 10 MHz to 32.768 kHz converter
Tom Van Baak
tvb at LeapSecond.com
Mon Mar 21 10:20:09 UTC 2016
Hi Vlad,
> How about Bresenham's Algorithm to alternate imperfect periods to
> produce an average that matches any "perfect" period.
Using dual periods is essentially what Martyn is doing. But I suspect it was serial rather than alternating (or maybe, interleaving is a better word), which caused his frequency readings to be unexpectedly anomalous.
> Refer to Bob Ammerman work to use Bresenham-type system for PIC MCU. He
> was using the counter works in the background, either by polling or
> Interrupt-Driven. So, the "SuperCycle" continues to run. The timer count
> the value is stored in a 3-byte register that is decremented by the software.
The examples that Bob and Roman present are useful for timers, interrupts and time counting (e.g., 1 Hz or 50/60 Hz). But IIRC, it did not lend itself to generating relatively high frequency, low jitter outputs like 32 kHz, especially if you're using an 8-pin PIC and your budget is a 38 instruction loop. I would be interested, though, if you were able to use their approach to solve this particular 32 kHz problem.
Meanwhile the leap cycle solution works really well: 10 MHz in, 32768 Hz out. Simple. Give it a try:
http://leapsecond.com/pic/src/pd30.asm
http://leapsecond.com/pic/src/pd30.hex
To find (free, open) copies of Bresenham's original papers google for:
Bresenham 1963 "Algorithm for computer control of a digital plotter"
Bresenham 1977 "A Linear Algorithm for Incremental Digital Display of Circular Arcs"
And then, please also read this informative 2004 paper by Mitchell Harris:
"Line Drawing, Leap Years, and Euclid"
http://www.cs.tau.ac.il/~nachum/calendar-book/papers/bresenham.pdf
If you have further questions, let me know.
/tvb
More information about the Time-nuts_lists.febo.com
mailing list