How Long for Long Pi – Part 2

In a previous blog post I considered how I might benchmark performance of different computers to understand how they compare across processor generations and maybe in the future across major architectures.

After experimenting with some different Python code, I found a version that is very consistent in it’s performance, seems to run on 1 core of a multi-core processor and can run on Windows and Linux. Here’s the version I am using for calculating Pi to 100K. I sourced it from this Stack Overflow thread.

#-*- coding: utf-8 -*-

# Author:    Fatih Mert Doğancan
# Date:      02.12.2014

# Timer Integration 18-Jun-22 by Jim Reed

# Timer function Start
import time

start = time.time()
print("Dogancan - Machin 100,000 Digits Pi Calculation Start")

#Original Calculation Code goes here


def arccot(x, u):
    sum = ussu = u // x
    n = 3
    sign = -1
    while 1:
        ussu = ussu // (x*x)
        term = ussu // n
        if not term:
            break
        sum += sign * term
        sign = -sign
        n += 2
    return sum

def pi(basamak):
    u = 10**(basamak+10)
    pi = 4 * (4*arccot(5,u) - arccot(239,u))
    return pi // 10**10

if __name__ == "__main__":
    print (pi(100000)) # 100000


# calculation code code ends
# timer reports

end = time.time()
print("Dogancan - Machin 100,000 digits elapsed calculation time")
print(end-start)

I expect to share all my raw data as I get it more in shape, but I am definitely getting some good first impressions. Let’s look at a summary of the tests on 5 machines so far, running Pi to 100K places using the code above on Python in a command prompt / terminal shell.

My PC NamePC TypeOSPi to 100K in X Seconds
(Avg 3 Runs)
TelstarRaspberry Pi 3Raspbian148.395
EdisonRaspberry Pi 4 8GBRaspbian111.263
TeslaIntel i7-7th Gen DesktopWin 1112.997
TeslaIntel i7-7th Gen DesktopUbuntu 2010.960
Charlie DukeIntel i7-8th Gen LaptopWin 1113.342
Charlie DukeIntel i7-8th Gen LaptopUbuntu 2011.627
MarconiIntel i7-12th Gen DesktopWin 116.152
MarconiIntel i7-12th Gen DesktopUbuntu 205.352

No surprise here on machine power. The more powerful the machine, the faster it processed. Now, I don’t think I have enough samples or data to draw a strong conclusion, but on the machines where I could run Ubuntu and Windows, Ubuntu outperformed Windows by at least 12% when averaged across the three runs.

Now let’s step it up an order of magnitude. How long will it take these machines to calculate Pi to 1 Million places. I used the same Python script, just changed the variable. Note on this run because of the long run times, I only ran the Raspberry Pi tests ONCE, the 3 other PC’s show an average of 3x runs.

My PC NamePC TypeOSPi to 1 Million in HH:MM:SS
TelstarRaspberry Pi 3 (1 Run)Raspbian5:12:57
EdisonRaspberry Pi 4 8GB (1 Run)Raspbian3:42:01
TeslaIntel i7-7th Gen DesktopWin 110:26:08
TeslaIntel i7-7th Gen DesktopUbuntu 200:18:21
Charlie DukeIntel i7-8th Gen LaptopWin 110:27:44
Charlie DukeIntel i7-8th Gen LaptopUbuntu 200:19:11
MarconiIntel i7-12th Gen DesktopWin 110:12:25
MarconiIntel i7-12th Gen DesktopUbuntu 200:08:57

One of the really cool pieces of data was the difference in the Marconi runs on Ubuntu 20 was 0.14 seconds from high to low.

The difference in the Windows vs Ubuntu really stood out this time. Here’s the 3 machines data individually:
Charlie Duke was 30.46% faster with Ubuntu
Tesla was 29.78% faster with Ubuntu
Marconi was 28.84% faster with Ubuntu

So, ultimately, I don’t know if this will mean anything to anyone but me, however I am enjoying this so far. Next steps:

  • Complete Household Data Gathering – Will run on Pi 1 and Pi 2, a 10th Gen Intel Laptop and a 2105 Mac Mini
  • Publish my complete data set.
  • Understand if I can port this calculation. Ultimately I’d love to try one of the old museum Cray machines to see if I can add those to the scoreboard.

If you have comments or thoughts for me on this, you can tweet me @N4BFR.

How Long for Long Pi?

Note: This is less of a blog post and more of a running commentary on a project I have conceived. I have a long way to go on it but I hope you enjoy the journey.

I’ve been thinking about computers I have seen at places like The National Museum of Computing in the UK or the Computer Museum of America here in Metro-Atlanta. One of the things that has always challenged me is how to benchmark computers against each other. For instance, we know the Cray 1A at the CMoA had 160 Megaflops of computing power, while a Raspberry Pi 4 has 13,500 Megaflops of computing power according to the University of Maine. What can you do with a megaflop of power however? How does that translate in the real world.

I’m considering a calculation matrix that would use one of two metrics. For older computers, how many places of Pi can they calculate in X amount of time. Say 100 seconds? For newer computers, how long does it take for the machine to calculate Pi to 16 Million places. Here are my early examples:

Pi to 10,000 Places on Raspberry Pi

ComputerProcessorRAMElapsed TimeHow Calculated
Raspberry Pi Model 3ARM SomethingSomething6 Min 34 Sec
394 Seconds
BC #1 (Raspbian)
Raspberry Pi Model 3ARM SomethingSomething2 Min 15 Sec
135 Seconds
BC #2
(Raspbian)
Raspberry Pi
Model 3
ARM Something0 Min 0.1 SecPi command

Pi to 16,000,000 Places

ComputerProcessorRAMPi to 16M Places TimeHow Calculated
Lenovo Yoga 920Intel Core i7-8550U CPU @ 1.8 GHz16 GB9 Min 55 Sec
595 Seconds
SuperPi for Windows Version 1.1
Lenovo Yoga 920Intel Core i7-8550U CPU @ 1.8 GHz16 GB0 Min 23 SecPi command
N4BFR Vision DesktopIntel Core i7-12700K CPU @ 3.6 GHz32 GB3 Min 15 Sec
195 Seconds
SuperPi for Windows Version 1.1
Raspberry Pi Model 3B+ARM 7 Rev 4 (V71)1 GB6 Min 03 Sec
363 Seconds
Pi command

Tools I am considering to use will be an issue because I want consistent performance across operating systems. Efficiency will be an issue because I will want something that computes at roughly the same speed for windows as for Unix.

  • SuperPi for Windows 1.1 was the first I came across and it seemed to be pretty straightforward that would run on many versions of Windows I came across.
  • Moving on to a calculator I could use in Unix, I found this John Cook Consulting Website that had a couple of calculations using the BC program. I found the results inconsistent on the Lenovo Yoga 920
BC Calculation 1: time bc -l <<< "scale=10000;4*a(1)"

BC Calculation 2: time bc -l <<< "scale=10000;16*a(1/5) - 4*a(1/239)"

I then found the Pi command on pi that might be more consistent with what I need.

$ time pi 10000

Pi Calculations on Lenovo Yoga 920
Windows time is reported by SuperPi. BC time is “Real” time reported by process.

Pi Calculated to X Places. X=Windows TimeBC `BC 2Pi Command
10K (Pi Compairison)1 Min 45 Sec0 Min 32 Sec
0 Min 35 Sec
0.09 Sec
20 K3 Min 22 Sec0.
50KIncomplete after 15 minutes
128K0 Min 01 SecIncomplete after 60 Minutes
512K0 Min 08 Sec
1 M0 Min 16 Sec
8 M3 Min 05 Sec
16 M9 Min 55 Sec0 Min 23 Sec

So using BC as a method of calculating does not seem to scale.



Coming back to this a few days later, I may have a partial solution. This will limit the use of this on older machines, but should be fairly consistent with newer ones. I plan to do the calculation with a script in Python 3. This should allow for roughly similar performance on the same machine to make results more comperable.

Python3 Downloads: https://www.python.org/downloads/release/python-3105/

Python3 methods for calculating Pi: https://www.geeksforgeeks.org/calculate-pi-with-python/

I was able to get a rudimentary calculation in Windows using both of the formulas and include a function to time the process consistently. Now I need to compare in Linux and blow out the calculation to allow a material number of places for this to be an effective measure.

I have found a few more options thanks to StackOverflow and I’m testing them now on my 12th Gen Intel machine.

  • 100,000 digits of Pi using the “much faster” method proposed by Alex Harvey: 177.92 seconds for the first pass, 177.83 seconds for the second pass. I like the consistency
  • Guest007 proposed an implementation using the Decimal library. I attempted a 10,000 digit calculation and that took 24.6 seconds, 100,000 places didn’t complete after more than 10 minutes. Interestingly, a peek at the system processing said it was only running 8.1% of CPU time.

Tomorrow I’ll start a new chart comparing these two methods across multiple machines.

Researching Sgt. Clemett Harrison Saint

Sgt. C.H. Saint’s gift from the town of Horden for being awarded the Military Medal during WW1.

I’m enjoying looking more and more into my family history and today I am spending a few minutes on C. H. Saint who hailed at one time from the village of Horden, England in County Durham. Great Granddad Saint was given the Military Medal in 1918.

Here’s what Ancestry.com has to say about Sgt. Saint

Born in Marsden Colliery, Durham, England on abt 1890 to John Thomas Richardson and Dora Harrison. Clemett Harrison Saint married Rose A Salmen and had 1 child. He passed away on 21 Mar 1937 in West Hartlepool, Durham, England.

– Ancestry.com

I found this at the UK National Archives site. It appears he fought in Egypt during the war, in the British Army’s Durham Light Infantry.

I’m hoping to visit Hoden in the fall to see what else I might find out.

Telstar and Callsign Curiosity

Note: Initial post of this article was around 5 PM on April 20, 2022. I corrected the post around 6:20 to reflect the proper call sign.

In case you didn’t know, Telstar was the first satellite to do communications between 2 continents. It launched in June 1962 and lasted less than 9 months.

YouTube was nice enough to suggest this Periscope Film called “Behind the Scenes with Telstar.”

This left me with a few questions:

At 27:08 in the video the tech says “sending station identification” and you hear in Morse what appears to be DE KF2XBR.

Correction from initial post: I found a second video where you can hear the Morse Code and it’s clearer now. The call sign is KF2XCK as found in the linked video from AT&T Tech Channel.

I don’t know that satellites to this day that satellites have had their own callsigns, so I’m assuming this is the ground station call sign. That ground station was in Andover, Maine. (An additional Bell Labs Telstar video confirms at least the DE KF portion of the call.)

This raised a couple of questions for me. If it was a communications service, why didn’t it have a XXX#### type call that seems to have been given out at the time?

Why was if KF2*** when Maine is in the 1 call sign area? My guess is that KF2XBR would have been assigned to Bell Labs, and that would have been coordinated out of their New Jersey HQ. I looked at the 1961 and 1963 Call Books, but there are no K*2X* stations listed.

I’ll be doing more research but if I am to believe Wikipedia, all experimental call signs, not just amateur, were in this **#X** format.

I did find a later use of KF2XBR as part of a BellSouth permit granted by the FCC in 1990. These look like cellular telephone frequencies.

From reading through these FCC proceedings, it might say that these experimental calls were given out sequentially instead of by call region, because many of the calls listed were KF2X** calls.

An interesting fact I found when reading was that the US accidentally nuked the satellite after a high altitude nuclear test. Scientific American documented how the Starfish Prime test impacted Telstar, which launched a day later.

Upcycling to make the SpaceX Gate Sign

Back in January found an 80’s vintage airline gate sign in an antique store and decided to upcycle it into something that would fit in my tech center redesign.

Poor sign all unwanted.

I introduce the SpaceX Gate sign.

The sign was supposedly a Piedmont Airlines sign from Newark. It had no power or instructions but I knew I could get past that. Two power bricks later and the LED’s were working great. I reached out to the manufacturer but no luck on getting a manual. I powered along.

I reached out to AlphaGraphics in Dunwoody where one of my former co-workers had set up shop. They were great in going back and forth with me to get the sign elements just the way I wanted.

There are 4 possible “vehicle” inserts. Crew Dragon, Falcon 9, Falcon Heavy and Starship. There are 4 possible “gate” inserts, 39A at KSC, Pad 40 at CCSFS, Pad 4 at Vandenberg and Starbase, Texas. Here’s an example:

Prepared for the future!

I plan on updating this with the latest manned mission info, which is currently NASA Crew 4 as shown. The LED’s are updated with a slide out keyboard on the right.

You can see this in action and the entire build in a video on my N4BFR Vision You Tube page:

What do you think? Leave feedback on YouTube or tweet me @N4BFR.

Catching up on my YouTube Channel

I’ve been loading up YouTube lately with videos I have shot on the road. Here’s the latest:

I love this 4K time lapse with the natural sound of a sunrise in the park. There’s also a longer version for nature lovers.

I was lucky enough to be one of the operators for the W5B ham radio special event. Here’s what it looked like at the studio building.

I decided to spend some time fixing up a clock I got a great deal on. Here’s the first of 3 videos showing the fixup.

There are also a bunch of new shorts and some ham radio operating videos when you go to N4BFR Vision on YouTube.

Xiegu X108G HF Transceiver as a Shortwave Receiver

I purchased a Xiegu X108G HF Transceiver at the Dalton Hamfest from an estate seller. The radio appeared to be lightly used and in it’s original foam shipping container. I connected it to my LiPo battery and my dipole HF antenna to check reception. This video shows WWV on 10, 15 and 20 Mhz. All three frequencies were coming in to my location nicely on this Sunday morning.

My goal is to build this into a small kit with a battery and end fed antenna that I can keep in my car for when the POTA bug strikes me on road trips.

First impressions:

Sounded fairly good when warmed up. On first power up, I was picking up RFI bleeding in at 15 Mhz from a local broadcaster, whose transmitter is 6 miles away as the crown flies on 680 Mhz. That seemed to fade out as I switched around between the bands. I also toggled the preamp on and off, so I can’t isolate what the culprit is.

The best control of the radio seems to be from the Icom like microphone. I could switch bands, directly enter frequencies and try different modes like AM vs USB. I wasn’t impressed that USB was set to a 2.3 Mhz bandwidth by default, I prefer 2.7 so this was a little narrow.

The power on screen listed firmware from 2017 so I will be looking for options to upgrade that. It did not remember the frequency I was on when I turned it off and on, instead defaulting to 14.270 Mhz and LSB.

Dealing with an Instagram Clone

Saturday – February 12
I was enjoying a nice weekend on the beach when on Saturday Evening my cousin sent me this in Facebook Messenger:

That’s real me at the bottom and fake Insta-clone me at the top. She was nice enough to block and report the account that was asking for money. I figured, “hey, we reported this quickly, that should put this fire out quickly.” Ha! Just in case, I added a post of my own:

Monday, February 14
Home now and assuming that the now multiple reports of my clone have encouraged the Meta company to take action. Ha! The clone has not contacted me directly so I can’t find them to check on it. They did seem to pick my wife to hit up:

Now I have a name. Back into Facebook and Instagram to make some reports. I even reach out to the clone myself:

No response. The account remains. I add some background info to my followers.

Tuesday, February 15

It’s been almost 72 hours since the first appearance of the clone and the first report to Meta. The account remains on Instagram. I reported them again. I “escalate” to Twitter:

Wednesday, February 16

Escalation does not seem to have driven any action. I can confirm the suspect account has been reported a minimum of 5 times since Saturday. Another appeal on Twitter in addition to my daily reports,’

Thursday, February 17

It’s been 5 days since the fake Instagram clone account has appeared and I have not heard a single response from Meta, Facebook or Instagram. Today I try a new vector to disrupt this user. Since they are using a photograph I took on their profile, I have reported their profile for copyright infringement.

As of 12:05 this afternoon the copyright report is submitted:

and just to prove that I am reporting these daily via their tool:

Thursday, February 17 – 3:20 PM

Apparently Instagram cares WAY MORE about copyright infringement than stolen identities, because the picture I reported was removed in less than 3 hours. This is after FIVE DAYS of reporting the account. I hope this gives someone another tool in their tool kit to fight social media scum.

Improving My Input Audio Chain

For a long time I have used two mics for my amateur radio setup, a Heil PR-40 for my HF rig and A Heil PR781 for my ID-5100. I received good audio feedback all around and every time I tried to get down to 1 I’d get noise in one or the other rig and I’d just go back to what worked.

Recently I’ve been doing some writing work and that’s required me to have conference calls a couple of times a week. The mic on the camera is decent, but I have these beautiful professional mics right next to me, and it was killing me not to use them.

I ended up purchasing a new tool to help me integrate. The Focusrite Scarlet 2i2.

Now, instead of the PR-40 going straight into the balanced input of the Flex 6500, it runs into the 2i2. The 2i2 has 2 line level outputs on the back. I run that to the Flex 6500 and it doesn’t know the difference. With the Focusrite’s USB connection to the PC, it sees it as a sound card that I can run into Zoom or Google Meet. No sweat.

This still leaves the problem of feeding the ID-5100. I’ve done this for now.

[Image Removed – It was a hot mess.]

I received feedback from the folks on the Atlanta Radio Club Sunday Night Net that the XLR Split leaves my FM audio with a high pitched whine in it. So, as the graphic says, I’m going to build an adapter to come out of the other Scarlett 2i2 line out port and step the audio down to Mic level for the 5100.

Parts are on order. I’ll update later this week on how things go.

17-Feb-21: It’s Later. Here’s what happened.

The device I made didn’t work as planned. I also purchased a commercial device and tried it on the line to the ICOM 5100. It didn’t like that either. So I purchased a mic filter that seems to mitigate some of my audio issues and here’s what the chain looks like.

If you have any thoughts on this, hit me up on Twitter @N4BFR.

Raspberry Pi GPS Time Server with Bullseye

I’m into accurate time. Ever since I stumbled across the SatSignal.eu site I have been running a Raspberry Pi on my network as a Stratum 1 time server. For those not familiar with the stratum, the only level higher is Stratum 0 and that is reserved for the absolute standard of time sources like the National Institute of Technology clock and GPS Satellites.

2016 Raspberry Pi Clock showing leap second addition at the end of 2016

I had been having some entropy on my current set of 6 GPS clocks from various issues, so I decided to rebuild my clock from the base install of the new Raspbian Bullseye distribution. Since I didn’t see a single definitive source, I put this listing together and I’m glad to share it with the community because it has been good to me with previous builds. My sources include SatSignal.eu, tomasgreno.cz, and adafruit.com. Much of what I did is just compiling and changing the order of some steps slightly to minimize reboots. Those others may work better for you, but this version worked for me.

Let’s talk hardware. I have done this project with a Raspberry Pi 1 through a Pi 4 as well as the Pi Zero and Zero W. I prefer the form factor of the full sized Pi to go along with the GPS hardware, but as long as you can make the GPIO connections from the GPS to the Pi all should work.

For a GPS module I use the Adafruit Ultimate GPS with the following pin connections. If you want to use something different, consult the breakout manufacturer and use pinout.xyz to set the proper connections. For my connections I typically use:

GPS Breakout PinRaspberry Pi Pin
VIN (Voltage in)Pin 4 – 5V Power
GND (Ground)Pin 6 – Ground
RX (Receive, to get data from the Pi TX)Pin 8 – GPIO 14 – UART TX
TX (Transmit, to send data to the Pi RX)Pin 10 – GPIO 16 – UART RX
PPS (Pulse Per Second)Pin 12 – GPIO 18

It’s not a typo, make sure TX goes to RX on the other board and vice versa.

Now on to software. Start with a clean version of Raspbian Bullseye on an MicroSD. I downloaded mine from the official RaspberryPi .com website. I used the “Raspberry Pi OS with Desktop” version and used an 8 GB MicroSD card as the media. I’m skipping the items related to base configuration of the host name and other start-up items, there are other sources for that. All the commands you see will be via the command prompt.

The instructions from here forward assume you have a working Raspberry Pi, connected to the internet with the GPS attached.

  • Start by adding two additional lines to the /boot/config.txt file. This starts the process to disable Bluetooth on the Pi and sets the Pulse Per Second GPIO Pin if your GPS supports it.
    • Note in this document, the command following $ gets entered at the command prompt, other commands are entered inside the file, at the bottom on a new line is usually good. Once commands are entered, use Ctrl-X, Y and Enter to save and exit the file and return to the command prompt. And yes, I use NANO as my text editor. You should use what you want. I’m not a text editor drill sergeant.
$ sudo nano /boot/config.txt

#Changes for GPS Clock
dtoverlay=pi3-miniuart-bt
dtoverlay=pps-gpio,gpiopin=18 (Customize to appropriate pin)
  • Disable Bluetooth in system control
$ sudo systemctl disable hciuart
  • Add a reference to /etc/modules to software for PPS management we will install shortly.
$ sudo nano /etc/modules

pps-gpio
  • Run a complete set of updates to the Pi Software
$ sudo apt-get update
$ sudo apt-get dist-upgrade
$ sudo rpi-update
$ sudo reboot

Once the computer has rebooted, it’s time to begin installing the key software.

  • Install PPS tools and a set of system libraries
$ sudo apt-get install pps-tools
$ sudo apt-get install libcap-dev
$ sudo reboot
  • Now let’s test to see if the PPS software was installed by checking some OS boot logs
$ lsmod | grep pps 

You should get two responses back that look something like this. Don’t worry if the numbers are different.

$ dmesg | grep pps

Make sure you have a line that says “new PPS source…”

  • Once you see both of those, we can check and see if the GPS is sending data. Your GPS must have a “fix” which means it’s getting data from at least three satellites in order for this to work.
$ sudo ppstest /dev/pps0

Success looks like this:

Don’t worry about the specific numbers, just look for incrementing sequence numbers. The data will continue to populate every second until you hit CTRL-C to stop it.

  • Moving on, we have installed the GPS module and gotten data from part of it, but have not installed the main GPS software set yet. This should do it:
$ sudo apt-get install gpsd gpsd-clients gpsd-tools 

Once those are complete we can take a look at the data coming from the GPS by peeking at the port.

$ sudo cat /dev/ttyAMA0

You should get a continuing output with lines like this. I look for lines that start with $GPRMC (Specific location obscured by X’s)

pi@Telstar5A:~ $ sudo cat /dev/ttyAMA0
$GPGGA,220752.000,33XX.XXXX6,N,084XX.XXXX,W,1,07,1.13,278.6,M,-30.9,M,,*5E
$GPGSA,A,3,04,03,26,31,22,27,16,,,,,,1.46,1.13,0.92*0A
$GPRMC,220752.000,A,33XX.XXXX,N,084XX.XXXX,W,0.27,216.85,171121,,,A*7C
$GPZDA,220752.000,17,11,2021,,*51

Again, CTRL-C to stop it. If you get a stream of data and it’s gibberish your GPS may be sending at a different rate. A good place to start if you see that is this SatSignal.eu page which looks at other GPS modules and other methods.

  • Now, let’s temporarily send that data to some GPS software for interpretation.
$ sudo gpsd /dev/ttyAMA0 -n -F /var/run/gpsd.sock

Then we’ll open the GPSMON software to look. (There’s also a tool called CGPS. Use either, this is a personal preference thing)

$ gpsmon
Location obscured for privacy.

The screenshot above will tell you your exact position, the number of satellites your GPS sees, and the status of your PPS data all in one screen. Did I mention you CTRL-C to get out of a screen like this? Because you do.

  • Configure the GPS software to auto-start when you boot your machine. I have seen a couple of different processes, but this one works consistently for me.
$ sudo nano /etc/default/gpsd

Unlike the other file edits where you add a line, this is what the whole file should look like when you are done. You may just want to cut and paste this whole section, or type it in, whatever works for you, I won’t judge.

#Updated for GPS Pi Clock

START_DAEMON="true"

# Devices gpsd should collect to at boot time.

GPSD_SOCKET="/var/run/gpsd.sock"

# They need to be read/writeable, either by user gpsd or the group dialout.
DEVICES="/dev/ttyAMA0"

# Other options you want to pass to gpsd
GPSD_OPTIONS="-n"
GPSD_SOCKET="/var/run/gpsd.sock"

# Automatically hot add/remove USB GPS devices via gpsdctl
USBAUTO="false"
  • Almost done with the GPS section. Four more commands to go.
$ sudo systemctl stop gpsd.socket
$ sudo systemctl disable gpsd.socket
$ sudo ln -s /lib/systemd/system/gpsd.service /etc/systemd/system/multi-user.target.wants/
$ sudo reboot

That third $ command (between “disable” and “reboot” goes on a single line, this blog text tool wraps it. It should look like this:

  • If you want to reconfirm everything is working again after reboot, run GPSMON like above and look at the pretty data fly by. Now let’s connect the GPS to the clock. I’m choosing to use NTP as my time server software for this project. You might want to play with Chrony as well.
$ sudo apt-get install ntp

Once that is done, you want to stop the timesyncd service that is installed by default with Bullseye and replace it with NTP.

$ sudo systemctl stop systemd-timesyncd
$ sudo systemctl disable systemd-timesyncd
$ sudo service ntp stop
$ sudo service ntp startntp q -

Let’s test. “Out of the box” the NTP software checks with servers on the internet to get the time. It will look something like this:

$ ntpq -p -c rl
The * on the left indicates the chosen server, this one is at Georgia Tech.

Great news! Clock is syncing, but if you look at the bottom you’ll see after “leap=00” it says “stratum=2” which is nice, but we want to use the GPS to make it a Stratum 1 clock.

  • It’s time to cross the streams and point the NTP software to look at the GPS and PPS signals for time. That means editing the NTP configuration file.
$ sudo nano /etc/ntp.conf

There are a lot of other settings in the file, so I won’t give the whole file this time but here’s what I recommend. Scroll down until you get to this section:

Use the # sign as the beginning of a line to comment out several of those “debian.pool” lines. You do want to keep an internet server on the list as a backup and for diversity, but you won’t need all of them. Save that for the folks that don’t have satellite time at home. Just below the “pool” entries, add each of the 6 lines on a new line:

# Kernel-mode PPS reference-clock for the precise seconds
server 127.127.22.0 minpoll 4 maxpoll 4
fudge 127.127.22.0 refid PPS

# Coarse time reference-clock - nearest second
server 127.127.28.0 minpoll 4 maxpoll 4 iburst prefer
fudge 127.127.28.0 time1 +0.105 flag1 1 refid GPS

If you want to use different servers on the internet, there are plenty to supplement. The manual page about ntp.conf can tell you more about other things you can do with this file.

When your changes are made it should look like this.

Do that cool CTRL-X thing and get out of there before you break anything (kidding).

Time to get the NTP client to read the new configuration file.

$ sudo service ntp restart

It sometimes helps to reboot too. Your call.
Now let’s check and see what time source we are using:

$ ntpq -p -c rl

Success! Why? Three things you want to see on this screen:
1 – The SHM / .GPS. line has a * next to it, indicating it’s the primary time source. In the “st” column you can see a 0 which indicates it’s connected to a “Stratum 0” source.
2 – The PPS / .PPS. line has an o next to it, indicating it is a “PPS peer” and it’s getting very specific pulse data from the GPS signal. It’s also a “Stratum 0” source.
3 – The “stratum” field for your NTP server now is “stratum=1” which is pretty much the best you can get as a home user.

It may take a little bit for the PPS to settle in as the primary time source, so don’t worry if it doesn’t do it in the first 5 minutes.


So, that’s the project. Why do you need this? Well, I do it for fun, but there are several applications that require very accurate time. For instance in Ham Radio the cycles for a program like FT8 depend on an accurate clock to switch between receive and send modes. Is this the thing I’m going to replace a Rubidium time standard with? No, but for about $100 bucks it’s a nice thing to have an a good early project for someone learning about Raspberry Pi. You can set Windows, Mac or Linux clients to point to your home server for time instead of time.windows.com or other sources.

One final note, this is accurate for me as of the time in that last screen shot. Something is bound to change eventually, so expect these instructions to drift over time as things change. Figuring that out is one of the fun things for me.

If you do this project and want to share success, you can tweet me @N4BFR or find me in other place on the internet.