# Switch out the X1 Oscillator on a RPI 2/3

Raspberry Pi Asked on November 5, 2020

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. 😀 (The scale is microseconds (milli*milli))

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 replace with a \$10 TCXO

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).

Swapping to the TCXO gives these graphs

Superficially this might look worse, until you realise that the scales for offset and frequency cover ranges which 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!

(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.)

Correct answer by colintd on November 5, 2020

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:

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.

Answered by crasic on November 5, 2020

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.

Answered by scruss on November 5, 2020

## Related Questions

### Raspberry 4 usbmount not working

5  Asked on December 12, 2021 by papatrexas

### RPI 4B – Bluetooth unavailable on Ubuntu 20.04

1  Asked on December 12, 2021 by aymdev

### Autostart chromium browser other user than pi

2  Asked on December 12, 2021

### 3B+ fails to boot Ubuntu mate

1  Asked on December 10, 2021 by washy

### How to add the hfp/hsp profile based speaker for input (speech recognition)and output simultaneously?

1  Asked on December 10, 2021 by path-or

### How do I use the command line to check which WiFi network I am connected to?

3  Asked on December 7, 2021 by ericmjl

### Raspberry PI2 under voltage with a standard microsoft webcam connected.

2  Asked on December 6, 2021 by mark-bennett

### How to use Rpi python to read/write/convert, to/from Arduino PPM and PWM servo control signals?

2  Asked on December 6, 2021 by geaux62

### What is going on with my GPIO pins?

1  Asked on December 4, 2021 by dubstepzedd

### says i don’t have wiringpi module when runing code at startup

3  Asked on December 4, 2021

### can’t login after modifying .bash_aliases

0  Asked on December 2, 2021 by abstract

### Network boot with rootfs on USB3 drive fails with Ubuntu 20.04

1  Asked on November 30, 2021 by peter-wishart

### Is it possible to interact with the NOOBS install remotely (VNC, SSH or other)?

2  Asked on November 28, 2021

### Access point as WiFi router/repeater, optional with bridge

3  Asked on November 28, 2021

### Alpine Linux – Changing/Moving the file system

1  Asked on November 25, 2021 by lisandro-di-meo

### 3.5 Inch RPi LCD with colors problem

2  Asked on November 25, 2021 by gabriel-schubert

### Getting Memory Error while installing tensorflow in raspberry

1  Asked on November 25, 2021

### Sub-process /usr/bin/dpkg returned an error code (1)

2  Asked on November 23, 2021 by lolok

### PWM issues with pigpio and RPi.GPIO

2  Asked on November 23, 2021

### Can I identify my PI by domain name in a LAN?

3  Asked on November 21, 2021 by dorin-botan