[Timekeeping] A Sidreal 1PPS using 10MHz and PIC12F675

Josh

Member
Having a sidereal clock is handy thing for astronomical observation / tracking, as the the 24 hr sidereal clock follows the stars positions.
I came across this great resource for interesting time things, one being an atomic clock wrist watch

Other than that here is a some useful programs for pic12F675's to get some more use out of your 10MHz oscillators:
http://leapsecond.com/pic/

pd29.asm got my attention with: "PIC 10 MHz to best sidereal 1PPS, with sync and milli-step"

from the pd29.asm:
Code:
; ------------------------------------------------------------------------
;
; Title:
;
;   PD29 -- PIC 10 MHz to sidereal 1PPS divider, with sync and milli-step
;
; Function:
;
;   This PIC program implements a digital frequency divider: the external
;   10 MHz input clock is divided by nearly ten million to produce a 1PPS
;   output that very closely approximates sidereal time.
;
;   - The 1PPS pulse width is 10 ms.
;
;   - Two Step inputs are checked once a second:
;     to advance 1PPS by   1 ms, hold StepA low
;     to retard  1PPS by  10 ms, hold StepB low
;     to advance 1PPS by 100 ms, hold both StepA and StepB low
;
;   - Two inputs support optional manual 1PPS synchronization. Pull Arm
;     pin low for a second to stop divider. The output will synchronize
;     to next rising edge of Sync pin (within one instruction cycle).
;
; Diagram:
;                                ---__---
;                5V (Vdd)  +++++|1      8|=====  Ground (Vss)
;         10 MHz clock in  ---->|2  pD  7|<+---  StepA
;                1PPS out  <----|3  29  6|<+---  StepB
;                     Arm  o--->|4      5|<+---  Sync
;                                --------
; Notes:
;
;   o External pull-up required on Arm input (pin4/GP3).
;   + Step and Sync inputs have internal WPU.
;   Output drive current is 25 mA maximum per pin.
;   Coded for Microchip 12F675 but any '609 '615 '629 '635 '675 '683 works.
;
; Theory:
;
;   A sidereal day is approximately 23 hours, 56 minutes, 4.0916 seconds
;   long (86164.0916 seconds). Thus sidereal clocks run fast compared to
;   conventional clocks (based on solar time). Sidereal clocks gain a day
;   per year (by definition), which is about one second every six minutes.
;
;   The rate difference is 86164.0916 / 86400, or 0.9972695787 (2730 ppm).
;   One second for a 10 MHz PIC is 2500000 instructions.
;   One sidereal second for a 10 MHz PIC is 2493173.946759 instructions.
;
;   Rounding up to a whole number of 2493174 instructions per loop means
;   the error is 2493174 - 2493173.946759 * 400 ns = 2.13e-8.
;   This is 21 ns/second, or 1.8 ms/day, or 0.7 seconds per year, which
;   is almost as good as the definition of the sidereal day is known.
;
;   To further improve precision, this version implements a dual-modulus
;   fractional-N synthesizer technique in order to create the irrational
;   2493173.946759 cycle count. The best (8-bit) rational approximation
;   of 0.946759 is 160/169 (= 0.946746).
;
;   The loop is made to be 2493173 + 160/169 instruction cycles long.
;   Over 169 seconds, 9 loops are 2493173 instructions long and 160
;   loops are 2493174 instructions long. The error drops to 5.20e-12.
;   This is 5.2 ps/second, or 450 ns/day, or 0.00016 seconds per year,
;   which is below the uncertainty in sidereal day length itself.
;
; Version:
;
;   09-Feb-2013  Tom Van Baak (tvb)  www.LeapSecond.com/pic
;
; ------------------------------------------------------------------------

very clever.
here are the other dividers: other src and hex
 
Top