9

Just like a lot of people I'm using a RPi as a NTP server (more info about the basic setup here: https://framkant.org/2017/03/stratum-1-ntp-server-with-freebsd-on-raspberry-pi/)

I have found that the stability is really bad and it's especially sensitive to temperature changes. Even me walking out the door in the morning changes the indoor temperature enough to affect the timekeeping.

In order to resolve this I would like to change the X1 oscillator to something more stable like a TCXO or OCXO. But I not really sure what I need to know/think about before doing this.

  • Do I need a special type of oscillator other than one with the correct frequency?
  • How hard would it actually be to replace the part? (soldering and so on)
  • Is the X1 actually the part I want to replace?

Edit:

For reference, here is a graph of the timekeeping today with a spike from me making dinner in a room approx 10m away. :D (The scale is microseconds (milli*milli))

NTP graph

1

3 Answers 3

12

It is entirely possible to do this with a bit of careful rework (magnifier and hot air gear is required to remove the old crystal) and you do get very significant improvement in performance.

I took an RPi3 B+ with NTP and a Trimble GPS receiver, removed the stock crystal and replaced with a $10 TCXO

http://www.farnell.com/datasheets/2371462.pdf

As a 3V3 part it needed AC coupling via a 1nF capacitor, and the DC level setting with 240K & 100K resitors, but the results speak for themselves.

The stock performance is shown in these graphs, where you can see the temperature changes in my home office lead to ~6ppm variation in the crystal frequency, and during periods of faster change, this yields up to 150us wander (while NTP is good at compensating for frequency offset, it takes it time to spot and compensate for drift).

Performance with stock crystal

Swapping to the TCXO gives these graphs

Performance with TCXO

Superficially this might look worse, until you realise that the scales for offset and frequency cover ranges are two orders of magnitude smaller! The worst case wander is reduced to less than 1us, with the RMS being around 300ns, and the frequency variation is reduced to ~30ppb. (The bottom "Wander" graph is at 0 for the TCXO system, because the ntpq data I was scraping only reports to the us resolution, and the actual wander is much less than 1us.)

All in all a very nice cheap, compact, low power, high performance NTP server / frequency reference!

If anyone wants more info on the mod, let me know.

(Pictures of the cased system, with GPS board, TCXO, and 1pps + 10MHz outputs below. TCXO is covered with foam tape to provide insulation and reduce rate of temperature change.)

enter image description here

enter image description here

Update

Several people have asked for more info.

A picture of the connection to the position of the original crystal is attached below.

enter image description here

This shows where I pickup the 3V3 supply, and the micro-coax I use to connect to gnd and the CPU crystal input pin. (I use coax to avoid RFI issues.)

In terms of the capacitor and resistors I mention, the output of the TCXO I used is 0.8V p-to-p, centred on 1V65 (3V3/2).

The relevant bits of the RPi run at 1V8, so we need to shift the TCXO output to a bias voltage of about 0.9V (1V8/2), ideally without significantly reducing the swing.

We achieve this by connecting the TCXO output via a 1nF chip capacitor (so it becomes AC coupled), then setting the DC bias voltage of the crystal input using a resistance divider from the 3V3 supply. (With just the capacitor, operation is unstable as the DC level of the input is floating.)

The 240K/100K divider (using two resistors I had to hand) gives a bias point of ~0.95V, and is easily overcome by the TCXO output drive current and the lowish impedance of the 1nF cap at 19.2MHz.

For space reasons, the AC coupling cap and resistive divider are all mounted on the TCXO (covered in foam), and this is connected via the length of coax to the PCB.

Sketch of change as delta to RPi3 schematic below.

enter image description here

6
  • Wow, thanks! This was exactly the answer I was looking for.
    – Peter
    Commented Mar 7, 2020 at 13:20
  • No problem. Always glad to share info. Do you want more details of the change and the GPS board I used?
    – colintd
    Commented Mar 7, 2020 at 13:39
  • @colintd : The XO has two potential free connections but the TCXO has Vout and GND. Which leg did you ground and how? Why did you use 5V and not 3.3V directly? I would recommend shorter lead lengths because of EMI.
    – tanGIS
    Commented Apr 11, 2020 at 7:45
  • Could you explain to @JohnnyBravo how this capacitor and resistors are connected? Perhaps a small circuit diagram? Commented Oct 30, 2020 at 13:44
  • @JohnnyBravo I've addressed your question via a very belated update to the main answer.
    – colintd
    Commented Jan 30, 2023 at 17:18
0
  1. You'll need one with exactly the same circuit characteristics as the stock XO.

  2. If you're skilled with a hot-air rework station, and have all the right tools and equipment, it's not too hard. It's virtually impossible if you don't, though.

  3. Likely not. NTP is designed to work around variable system clocks through network consensus, so changing the XO won't give you much. Using a GPS's PPS signal effectively gives you a GPS/Multi-GNSS Disciplined Oscillator, so as long as you have skyview, you've got atomic clock accuracy even without a network. If you don't have skyview or network, it wouldn't be impossible to piece something together based on a used rubidium frequency standard — but even the cheapest of those have fearsome power requirements and are far from plug-and-play.

3
  • Thanks for the answer. I have a pretty good skyview and I get reasonable good PPS signals from GPS at the moment. But thats not much help for the stability when the PI is extremely temperature sensitive.
    – Peter
    Commented Nov 11, 2017 at 11:28
  • You might be using the wrong board. The Raspberry Pi is an inexpensive computer for education, not a lab-grade frequency reference
    – scruss
    Commented Nov 11, 2017 at 16:24
  • Hehe, I know. The only thing I want is to make the raspberry PI as accurate as possible. If I need a professional NTP server I will buy one.
    – Peter
    Commented Nov 11, 2017 at 17:59
0

This is a not a very fruitful idea, for several reasons.

The clock circuit on an embedded device like the PI is not designed for accuracy or stability, there are more elements than the XO that will affect jitter and drift.

  1. Stability and drift in the Phase-Locked Loop (PLL) inside the Broadcom CPU which generates the core clock
  2. Temperature Drift in XO resonance circuit
  3. Temeperature drift in the latching/clocking threshold detection circuits.
  4. etc. etc.

Additionally, Any hand rework, even with good equipment, runs the risk of wiping out any improvement from a better spec'd oscillator. They are very sensitive parts.

The improvement in temperature stability switching to a different XO in the same package is marginal, you are buying better tolerance and matching characteristics that reduce clock drift and temperature dependence for the device class, but physically speaking all crystals will expand/contract with temperature changes and all will experience clock drift, very hard to compensate for this.

In the end its unnecessary, if you want to run an NTP node it will work regardless, if you want to function as a (local) time standard you will need to interface external equipment, Like a GPS, thermally stable clock, cesium clock, etc...

However, If you want to experiment with stabilizing the on-board oscillator this I would suggest and alternative approach


OCXO

Clock references in precise equipment are usually in a constant temperature oven, and require some time to stabilize. These "ovens" provide a constant temperature (not necessarily HOT), usually controlled by a Peltier Element

These devices are known as Oven Controlled Crystal Oscillator (OCXO). Unfortunately they require a significant change to the circuitry and are not drop in replacements.

They Look like This: enter image description here

To experiment, you could replicate some of the stability of an OCXO by putting a Thermo-Electric Cooler (TEC aka Peltier Element) to keep the XO and the broadcom CPU at a constant temperature.

In other words, eliminate the temperature issue by keeping the Raspberry PI at constant temperature.

4
  • 1
    Excellent answer, but keeping the temperature stable is really not that simple. And I'see a lot of pll changing frequency with cpu usage, probably caused by the noise on the power supply caused by the cpu core... I would recommend using a GPS with a PPS output
    – pim
    Commented Nov 9, 2017 at 18:36
  • 1
    @pim "but keeping the temperature stable is really not that simple" Indeed, the TEC was a suggestion for "experimentation", because OP may need self-convincing that the idea won't pan out. In Real-life its very problematic and error prone (OCXO is in a metal can for a reason!) . The real solution like you say is an external stable clock source - GPS is a great low-cost option, billions of dollars of R&D into making a perfect clock source, may as well use it!
    – crasic
    Commented Nov 9, 2017 at 18:41
  • Hi, Thanks for the answer, but it puzzles me for several reasons. I state in the question that I use it fo NTP, and if you follow the link you will see that Im actually using GPS to discipline the clock. But still its very temperature sensitive. Then you talk about OCXO which I also mention in the original question. I also provide a link to a TCXO with a very small package.
    – Peter
    Commented Nov 11, 2017 at 11:25
  • As demonstrated in the answer above, it is not only possible to swap to a TCXO, but it also very significantly improves both the local timing (useful in many circumstances) and also the quality of time served via NTP.
    – colintd
    Commented Jan 31, 2023 at 16:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.