Discipline a DS3231 with GPS: how? - Page 1
Forum section: electronics / projects

author: technix
author_rank: Super Contributor
timestamp: May 10, 2015, 01:41:21 pm
content: 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.

author: JimRemington
author_rank: Regular Contributor
timestamp: May 10, 2015, 03:04:12 pm
content: 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.

author: technix
author_rank: Super Contributor
timestamp: May 10, 2015, 03:55:44 pm
content: Quote from: JimRemington on May 10, 2015, 03:04:12 pmI 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?

author: SL4P
author_rank: Super Contributor
timestamp: May 10, 2015, 04:32:50 pm
content: 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!

author: technix
author_rank: Super Contributor
timestamp: May 10, 2015, 08:07:45 pm
content: Quote from: SL4P on May 10, 2015, 04:32:50 pmThat 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.

author: edpalmer42
author_rank: Super Contributor
timestamp: May 10, 2015, 09:39:00 pm
content: 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

author: KerryW
author_rank: Regular Contributor
timestamp: May 10, 2015, 10:13:30 pm
content: 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.

author: Awesome14
author_rank: Regular Contributor
timestamp: May 11, 2015, 11:48:41 am
content: 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.

author: Dragon88
author_rank: Regular Contributor
timestamp: May 11, 2015, 01:14:07 pm
content: Quote from: technix on May 10, 2015, 03:55:44 pmI 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.

author: Kalvin
author_rank: Super Contributor
timestamp: May 11, 2015, 01:34:18 pm
content: 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:Quote from: KerryW on May 10, 2015, 10:13:30 pm

author: technix
author_rank: Super Contributor
timestamp: May 11, 2015, 02:43:12 pm
content: Quote from: Awesome14 on May 11, 2015, 11:48:41 amMy 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?

author: technix
author_rank: Super Contributor
timestamp: May 11, 2015, 02:54:04 pm
content: Quote from: Kalvin on May 11, 2015, 01:34:18 pmThe 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.

author: technix
author_rank: Super Contributor
timestamp: May 11, 2015, 02:59:37 pm
content: Quote from: Dragon88 on May 11, 2015, 01:14:07 pmSo 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?

author: paulie
author_rank: Frequent Contributor
timestamp: May 11, 2015, 03:19:48 pm
content: Quote from: Awesome14 on May 11, 2015, 11:48:41 amActually 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.

author: Dragon88
author_rank: Regular Contributor
timestamp: May 11, 2015, 04:51:21 pm
content: Quote from: technix on May 11, 2015, 02:59:37 pmSure. And if you need or want holdover performance you can tackle that as well.