Author Topic: Discipline a DS3231 with GPS: how?  (Read 9066 times)

0 Members and 1 Guest are viewing this topic.

Offline technixTopic starter

  • Super Contributor
  • ***
  • Posts: 3508
  • Country: cn
  • From Shanghai With Love
    • My Untitled Blog
Discipline a DS3231 with GPS: how?
« on: May 10, 2015, 01:41:21 pm »
Have anyone tried to discipline a DS3231 DTCXO/RTC with a GPS receiver? If so, how did you do it?

This is slight time nuttery but I just happens to have snatched a DS3231 grab bag from a fire sale and have a leftover u-blox 6010-based GPS module from a previous project, and the GPS module have PPS output.
 

Offline JimRemington

  • Regular Contributor
  • *
  • Posts: 210
  • Country: us
Re: Discipline a DS3231 with GPS: how?
« Reply #1 on: May 10, 2015, 03:04:12 pm »
There is an aging register in the DS3231 that adjusts the oscillator frequency. You could fiddle with that until the PPS (SQW) output syncs with the GPS PPS output.
 

Offline technixTopic starter

  • Super Contributor
  • ***
  • Posts: 3508
  • Country: cn
  • From Shanghai With Love
    • My Untitled Blog
Re: Discipline a DS3231 with GPS: how?
« Reply #2 on: May 10, 2015, 03:55:44 pm »
There is an aging register in the DS3231 that adjusts the oscillator frequency. You could fiddle with that until the PPS (SQW) output syncs with the GPS PPS output.

I know that, and how to do that up to a greater accuracy? I am thinking about letting a microcontroller run a counter on the 32768Hz and interrupt on the GPS PPS signal, and adjust the aging register according to it.

If I discipline the DS3231 with a GPS, what kind of accuracy can I get out of this?
 

Offline SL4P

  • Super Contributor
  • ***
  • Posts: 2318
  • Country: au
  • There's more value if you figure it out yourself!
Re: Discipline a DS3231 with GPS: how?
« Reply #3 on: May 10, 2015, 04:32:50 pm »
An admirable goal, but the DS323x are pretty good.
I'd just pull the time in every 12 or 24 hours or so. No one will see the difference!
Don't ask a question if you aren't willing to listen to the answer.
 

Offline technixTopic starter

  • Super Contributor
  • ***
  • Posts: 3508
  • Country: cn
  • From Shanghai With Love
    • My Untitled Blog
Re: Discipline a DS3231 with GPS: how?
« Reply #4 on: May 10, 2015, 08:07:45 pm »
An admirable goal, but the DS323x are pretty good.
I'd just pull the time in every 12 or 24 hours or so. No one will see the difference!

That is just Raspberry Pi + DS3231 overlay + gpsd - not what I am doing!

I am thinking about making a crude digital PLL keeping the DS3231 calibrated with GPS time.
 

Offline edpalmer42

  • Super Contributor
  • ***
  • Posts: 2328
  • Country: ca
Re: Discipline a DS3231 with GPS: how?
« Reply #5 on: May 10, 2015, 09:39:00 pm »
The datasheet for the DS3231 gives info on the accuracy vs. temperature and supply voltage.  You could use the aging registers for coarse tuning and then vary the supply voltage or temperature for fine tuning.

Ed
 

Offline KerryW

  • Regular Contributor
  • *
  • Posts: 112
  • Country: us
Re: Discipline a DS3231 with GPS: how?
« Reply #6 on: May 10, 2015, 10:13:30 pm »
If I were doing it, I would use an 8 pin PIC.  Program it to output a pulse train of 32,768 pulses (@~40KHz) to the RTC every time it saw a 1 PPS signal from the GPS.
One accurate measurement is worth a thousand expert opinions
- Adm. Grace Hopper
 

Offline Awesome14

  • Regular Contributor
  • *
  • !
  • Posts: 192
  • Country: us
Re: Discipline a DS3231 with GPS: how?
« Reply #7 on: May 11, 2015, 11:48:41 am »
The GPS output may be in any format imaginable. It is possible with a GPS to discipline yy:mm:dd:hh:mm:ss.ssssss, OR, you can use the PPS signal alone. Usually the PPS signal, if there is one on any particular GPS unit, uses the rising edge as the alignment to the GPS second, which is about 13s different than the actual time.

To get this to work requires computational logic, an interface to join the GPS unit and TCXO chip together to be manipulated at the same TTL level. (GPS is frequently designed around the RS232 protocol--serial port.) There's just too much juggling of analog signals necessary. So, you need some sort of CPU to keep track of everything and do your work for you.

You must understand how the GPS unit communicates, unless you're only going to use the PPS signal. But you still must know then the PPS pulse width, or preferably adjust it to some reasonable, easy to use length in milliseconds. Most GPS disciplined XO's are sync'ed once or twice per day. The error is tracked and slow adjustment is applied by external means.

The GPS PPS standard is part of the GPS protocol. It is theoretically accurate to 10^-12s. 10^-6s is usually more realistic. Although algorithmic corrections can be applied using software. Since GPS is analog, manipulating it properly requires conversion to a digital approximation. I once messed around with precision time keeping. What you're attempting is not incredibly difficult, but the benefit over pure GPS PPS  is questionable.
Anything truly new begins as a thought.
 

Offline Dragon88

  • Regular Contributor
  • *
  • Posts: 88
Re: Discipline a DS3231 with GPS: how?
« Reply #8 on: May 11, 2015, 01:14:07 pm »
There is an aging register in the DS3231 that adjusts the oscillator frequency. You could fiddle with that until the PPS (SQW) output syncs with the GPS PPS output.
If I discipline the DS3231 with a GPS, what kind of accuracy can I get out of this?

I can tell what you want, but unfortunately you won't get it that simply with GPS. As is often said, GPS has poor short term stability, but perfect long term stability. So you can't just sit there watching the PPS and making adjustments to the clock crystal every second. It will jitter all over the place. You have to average out the jitter over a very long time constant, and learn the behavior of your crystal, and have a good algorithm to make correct adjustments to your oscillator. As you do not have a voltage control pin for the oscillator, only a digital register, then of course you will need a microcontroller to do this. Which is fine, because your stability and accuracy will actually come from the algorithm you design running on the uC, not the circuitry alone.

I would just pull GPS time from the serial string once and hour, reset the clock, and record metrics about how much you drift each hour. If you examine the data after a few months and notice more drift during each hour than you want, then you can decide to do something more serious.

Also I don't believe the u-blox are known for great time keeping ability. The time nuts don't seem to speak highly of them.
 

Offline Kalvin

  • Super Contributor
  • ***
  • Posts: 2145
  • Country: fi
  • Embedded SW/HW.
Re: Discipline a DS3231 with GPS: how?
« Reply #9 on: May 11, 2015, 01:34:18 pm »
I would just pull the serial timing data from the GPS receiver's output with the MCU and drop the DS3231 altogether.

However, I liked the KerryW's cool idea very much:
If I were doing it, I would use an 8 pin PIC.  Program it to output a pulse train of 32,768 pulses (@~40KHz) to the RTC every time it saw a 1 PPS signal from the GPS.
 

Offline technixTopic starter

  • Super Contributor
  • ***
  • Posts: 3508
  • Country: cn
  • From Shanghai With Love
    • My Untitled Blog
Re: Discipline a DS3231 with GPS: how?
« Reply #10 on: May 11, 2015, 02:43:12 pm »
The GPS output may be in any format imaginable. It is possible with a GPS to discipline yy:mm:dd:hh:mm:ss.ssssss, OR, you can use the PPS signal alone. Usually the PPS signal, if there is one on any particular GPS unit, uses the rising edge as the alignment to the GPS second, which is about 13s different than the actual time.

To get this to work requires computational logic, an interface to join the GPS unit and TCXO chip together to be manipulated at the same TTL level. (GPS is frequently designed around the RS232 protocol--serial port.) There's just too much juggling of analog signals necessary. So, you need some sort of CPU to keep track of everything and do your work for you.

You must understand how the GPS unit communicates, unless you're only going to use the PPS signal. But you still must know then the PPS pulse width, or preferably adjust it to some reasonable, easy to use length in milliseconds. Most GPS disciplined XO's are sync'ed once or twice per day. The error is tracked and slow adjustment is applied by external means.

The GPS PPS standard is part of the GPS protocol. It is theoretically accurate to 10^-12s. 10^-6s is usually more realistic. Although algorithmic corrections can be applied using software. Since GPS is analog, manipulating it properly requires conversion to a digital approximation. I once messed around with precision time keeping. What you're attempting is not incredibly difficult, but the benefit over pure GPS PPS  is questionable.

My u-blox 6010 module speaks TTL level UART and the DS3231 is all digital - hence why a microcontroller is called for. Both GPS data and PPS can be used on the microcontroller. The DS3231 RTC is of course synchronized to the GPS but what about trimming the oscillator itself?
 

Offline technixTopic starter

  • Super Contributor
  • ***
  • Posts: 3508
  • Country: cn
  • From Shanghai With Love
    • My Untitled Blog
Re: Discipline a DS3231 with GPS: how?
« Reply #11 on: May 11, 2015, 02:54:04 pm »
I would just pull the serial timing data from the GPS receiver's output with the MCU and drop the DS3231 altogether.

However, I liked the KerryW's cool idea very much:
If I were doing it, I would use an 8 pin PIC.  Program it to output a pulse train of 32,768 pulses (@~40KHz) to the RTC every time it saw a 1 PPS signal from the GPS.

The 32768Hz output from the trimmed DS3231 is used as time base for my frequency counter project so that chip cannot be dropped.

If it is just timekeeping I would hook the GPS module to a Raspberry Pi with gpsd and ntpd running, turning it into a Stratum 1 NTP server to keep all my equipment's time in sync within 10ns of UTC.
 

Offline technixTopic starter

  • Super Contributor
  • ***
  • Posts: 3508
  • Country: cn
  • From Shanghai With Love
    • My Untitled Blog
Re: Discipline a DS3231 with GPS: how?
« Reply #12 on: May 11, 2015, 02:59:37 pm »
There is an aging register in the DS3231 that adjusts the oscillator frequency. You could fiddle with that until the PPS (SQW) output syncs with the GPS PPS output.
If I discipline the DS3231 with a GPS, what kind of accuracy can I get out of this?

I can tell what you want, but unfortunately you won't get it that simply with GPS. As is often said, GPS has poor short term stability, but perfect long term stability. So you can't just sit there watching the PPS and making adjustments to the clock crystal every second. It will jitter all over the place. You have to average out the jitter over a very long time constant, and learn the behavior of your crystal, and have a good algorithm to make correct adjustments to your oscillator. As you do not have a voltage control pin for the oscillator, only a digital register, then of course you will need a microcontroller to do this. Which is fine, because your stability and accuracy will actually come from the algorithm you design running on the uC, not the circuitry alone.

I would just pull GPS time from the serial string once and hour, reset the clock, and record metrics about how much you drift each hour. If you examine the data after a few months and notice more drift during each hour than you want, then you can decide to do something more serious.

Also I don't believe the u-blox are known for great time keeping ability. The time nuts don't seem to speak highly of them.

So instead of PLL'ing between GPS PPS and DS3231, I should just keep eyes on the time reported my GPS and DS3231, and once every day or two try to calibrate out the accumulated difference?
 

Offline paulie

  • Frequent Contributor
  • **
  • !
  • Posts: 849
  • Country: us
Re: Discipline a DS3231 with GPS: how?
« Reply #13 on: May 11, 2015, 03:19:48 pm »
the GPS second, which is about 13s different than the actual time.

Actually time sent by low cost GPS (ie Ublox) is the same as UTC, GMT, and local time as reported  NIST. You might be confusing with TAI which does not adjust for the leap second and is currently 19s off. Another leap second update is due end of next month.

Displaying time directly from a GPS is not an option for battery operated setups. However it is possible to update the RTCC chip periodically as long as the GPS can be powered down most of the time. A cheap MOSFET under MCU control accomplished this quite nicely. My button cell powered unit has been running for 3 years and still going strong.
 

Offline Dragon88

  • Regular Contributor
  • *
  • Posts: 88
Re: Discipline a DS3231 with GPS: how?
« Reply #14 on: May 11, 2015, 04:51:21 pm »
So instead of PLL'ing between GPS PPS and DS3231, I should just keep eyes on the time reported my GPS and DS3231, and once every day or two try to calibrate out the accumulated difference?

Sure. And if you need or want holdover performance you can tackle that as well.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf