[time-nuts] A Simple PIC Divider

Brooke Clarke brooke at pacific.net
Mon Aug 7 17:37:24 UTC 2006


Hi Glenn:

The PIC uC chips all divide the incoming oscillator signal by 4 to 
generate a set of 4 internal clock signals so the actual instruction 
frequency is Fin/4.
A 10 MHz input results in a 2.5 Mhz instruction cycle frequency, or 400 
ns per instruction.  Any code in the PIC that involves a branch and 
doing something is going to take a few instructions so you end up around 
a 1 us offset.  But for most things you want an offset so that you are 
not measuring on both sides of zero.  It might be possible to change the 
SYNC function so that instead of trying to make the code as fast as 
possible instead after the sync pulse is detected to wait for .9999996 
seconds (or some other time TBD) so as to get closer to the 1 PPS edge.

Another idea would be to make an external circuit that would be put in 
series between the 10 Mhz clock and the divider with a button and every 
press of the button would remove one cycle of the clock giving  you a 
-100 ns step.  This idea could be extended to 10 cycles, 100 cycles, 
etc.  Allowing moving the 1 PPS edge.

It happens that I've just started looking at how to move the 1 PPS edge 
in the Precision Clock, see:
http://www.pacificsites.com/~brooke/PRC68COM.shtml#PC3
and it looks like the PIC can easily move it in 1 ms steps and I think 
that may be good enough. 
Rather than instruction counting, like is used in the tvb divider the 
clock uses interrupts.  This has a big advantage in that the clock keeps 
running all the time, even while it's being set.  That way changing the 
time will not effect the 1 PPS edge.

Have Fun,

Brooke Clarke

-- 
w/Java http://www.PRC68.com
w/o Java http://www.pacificsites.com/~brooke/PRC68COM.shtml
http://www.precisionclock.com



Glenn wrote:

>Does anyone have a good solution for the 1-2 us delay between the 
>divider "reset" (or "start") and the first (and later) pulses?
>
>I think this might be a good reason to put a serial port on one of the 
>pins. Then, you could send the divider "skip x steps" or "add x steps." 
>I'm not sure if it would matter if the skipped steps were on the high or 
>low side of the pulse. You could also use this function to compensate 
>for the temperature dependent TTL->RS232 line driver delay used on 1 PPS 
>lines sent to things like NTP servers.
>
>cheers,
>glenn
>
>
>_______________________________________________
>time-nuts mailing list
>time-nuts at febo.com
>https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts
>
>  
>





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