Turning a frequency locked loop into a phase locked loop

gps

I want to use a GPS module (with a PPS output) to ultimately generate a 5kHz timing signal that is phase-aligned with the PPS positive edge.

PPS-------MSP430-----DAC-------10MHz VCO-------Divider--------5kHz
             /\                            |
             |(count pulses in             |
             |between PPS edges            |
             |inside MCU)                  |       
             -------------------------------

Thus far, I can generate a stable 10MHz signal (10MHz VCO connected to an MSP430 Launchpad for control), and then I divide this 10MHz signal down to 5kHz using several 74LS90 chips.

  • This generates a very stable 5kHz timing signal, but the positive edge of the 5kHz signal, in the pulse of the period, is NOT aligned with the positive edge of the PPS.

  • How can I adjust the phase, so that the 5kHz and PPS edges are aligned?

—-EDIT
Thank you for your comments! Our timing error budget is 1 microsecond, so 100nanosec would be great.

I was under the impression that, IF we use a 10MHz oscillator, and control that to 10MHz with the loop, and THEN divide the result down to 5kHz, then "by default" the 5kHz would be very precise (controlling a 10MHz oscillator to within 1Hz, is 100 nanosec of timing accuracy). If I controlled the 5kHz output, and I'm off by 1Hz, then I'm off by 200 microsec (much bigger timing error). Am I correct in my thinking?

Best Answer

Virtually every MCU ever made includes at least one timer/counter module, so it's kind of silly to use an external counter chain.

Just connect the VCXO output to the input of the timer module (or better yet, use the VCXO as the main MCU clock), and program it to generate your 5 kHz output.

In the firmware, you sample the value of the counter every time you get an intterupt from the GPS reference pulse. If the counter has a low value (assuming it's counting up, not down), it means it's running too fast and you need to slow it down. If it has a high value (i.e., near 2000), it means it's running too slow and needs to be speeded up. Adjust the DAC output accordingly.

Eventually, the rollover events of the counter will be synchronized with the GPS reference pulses.

Related Topic