The most accurate Raspberry Pi atomic clock IN THE WORLD!

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
sometimes i lose track of time when i'm out enjoying nature at least the one or two times here i go outside but computers can't afford to lose track of time and lucky for them there's this the time card i'm going to plug this gps-based atomic clock into a raspberry pi compute model 4 to make the world's most accurate raspberry pi based clock a truly atomic pi the time card is an open source pci express time reference that uses gps satellites to acquire the exact time down to the tens of nanoseconds but a gps signal like any wireless signal can't be relied on to be perfect all the time what do you do to make sure the time stays accurate when the signal drops most computers keep time with a quartz crystal which oscillates at a frequency just under 33 kilohertz if you have a good circuit and control its temperature you could hold the time accurate to within a second for maybe 30 days well on the time card this rubidium atomic clock holds the time accurate within a second for 32 000 years how does it do that well at a basic level it shines a light through rubidium gas inside a chamber and since rubidium oscillates at a frequency of 6.8 gigahertz it's more than 200 000 times more accurate than a quartz clock but when you need this level of accuracy we're not talking about seconds or years we're dealing in nanoseconds which are one billionth of a second and the time card is accurate to a few billionths of a second even if you lose satellite coverage for up to two days and you might be wondering who cares about billionths of a second well that's understandable most people haven't worked in data centers with distributed computing or in broadcast media where timing is well everything when humans went from sundials to mechanical clocks schedules could be coordinated better since it was easier to know what time it was any time of day computers even the humble raspberry pi can do billions of calculations in the blink of an eye you might not care about nanoseconds but computers do most computers use the equivalent of a sundial today and the time card allows computers to synchronize and coordinate hundreds of times faster if you want a real world example of how the time card could help i've run a service called server check-in for over a decade it uses a set of eight servers all around the world to measure uptime there's this one dumb server in chicago that always seems to drift forward in time two seconds per month and that caused my code to break and distribute more checks to it than my other servers i had to add in extra code to inject artificial delays so my central database doesn't let chicago hog everything since it seems to be running in the future i also had to add extra automation to adjust the time on that server every night if all my servers had time cards or the data center had a central time server with the time card none of them would ever be more than a few nanoseconds off and i wouldn't have wasted a week of my life adding that code which by the way makes my application more complicated before we dive into it this card doesn't have any new technology per se atomic clocks even higher accuracy cesium clocks have been around for decades and gps-based timing has been a thing for a while now too and many data centers do have specialized time appliances just apparently not the one i use in chicago but this card is to time accuracy as apple's ipod was to mp3 players before it it repackages existing technology in a way that's better and easier to use but unlike the ipod everything's open source if you have 1500 bucks on a soldering iron you could make your own time card with off-the-shelf parts all you need to run it is a computer with a pci express slot did i mention the raspberry pi compute module 4 has pci express built in yeah we're going to jam it into pi and see what happens as i get ready to plug it in let's take a closer look at the hardware on the card there are three main components first this u-blox timing board is the brains behind the gnss satellite timekeeping it'll work with gps glonass galileo and baidu and it has a gps antenna connector on it i plugged in this gps antenna facebook sent me and put it near one of my windows so i could get a view of the sky next this metal box contains a miniature rubidium oscillator this is the most expensive part of the board just this part alone costs 700 bucks but that's the price you pay to get accuracy down to billionths of a second you could swap out this part to save money or if you wanted even more accuracy you could wire it up to a cesium atomic clock source but the price for that might make your eyes water redshirt jeff told me he wants more radiation to as he said mess around with but i don't think i have the budget for it or the appropriate amount of lead shielding in my walls the last major part of the board is the fpga it's an artix 7 and it runs the code that exposes the time reference to the computer over pci express this particular model has a gig of ram built-in it's a little weird saying your real-time clock has almost as much ram as your computer but here we are i also asked if there were plans for a flux capacitor for the next board version but they said they were hard to come by right now because of the chip shortage okay i guess i'm out of time for bad jokes like that moving on the board has a by four pci express connector but the i o board only has a by one slot i could carefully cut the edge of the slot to make this card fit but in this case i'll just use this adapter let's power up the pie and see what happens so far so good the blinking lights are a good indication that at least something's working i booted up a copy of 64-bit pios and used ls pci on the command line to see if the card appeared and look at that the pi can see it it doesn't have a driver loaded though and if i look at the d-message log output from when the pi started communicating with the card i don't see any time specific stuff yet so the next step is to see if i can get a driver working first i tried compiling the driver from the open compute project's github after fixing a bug in their build script i tried running it but it wouldn't work apparently the code in their driver requires a newer version of the linux kernel than the one that comes with raspberry pi os pios comes with 5.10 but their code required 5.11 or newer and i found out that the driver is actually included in the kernel if you use 5.12 or later i'm kind of used to recompiling the kernel on the pi and you can get the shirt for that on redshirtjeff.com so i decided to build a 5.14 kernel with the time card enabled i ran menu config and navigated through the kernel options until i found the open compute timecard as ptp clock option i selected that to make sure it was enabled in the kernel configuration compiled the kernel copied it to the pi and rebooted fingers crossed i waited for the thing to boot up and once it did look at that in the d message logs it shows the ptp underscore ocp driver loading successfully that means the driver i compiled in worked and found the card so next i checked the device tree the fpga on the timecard is supposed to expose two new devices to linux ptp0 and pts and there they are the next thing i wanted to see was if i could turn my raspberry pi into a grand master clock using ptp or the precision time protocol if this works this means a raspberry pi and time card could replace expensive proprietary clocks in data centers and could synchronize the clocks for hundreds or even thousands of servers or other devices you might have heard of ntp or network time protocol that's used a lot today like on your iphone or laptop and it can be accurate to a few milliseconds at least under ideal circumstances ptp uses hardware-based timestamping and can be accurate to nanoseconds or in some cases even picoseconds and with a gps and rubidium clock a pie with the time card could be classified as a stratum one time server this is the most accurate a time source can be outside of gps devices directly these other four connectors on the card are also there because of ptp they can output a pulse per second for an additional level of hardware time verification but back to the pie there's software in the linux kernel that allows you to run ptp over ethernet but the ethernet adapter has to support it and here's the interesting wrinkle about the compute module 4. the little ethernet chip it uses is actually different than the one used in the regular boring old pi4 model b it's a special broadcom ethernet controller with built-in ptp hardware timestamping so let's check if linux can use it i ran the command east tool to see what capabilities the interface has and oh it says it can't do hardware timestamps well that stinks i looked into it and apparently the hardware support is there but the software side hasn't implemented support for this special broadcom chip at least not yet you can follow this github issue to see progress on adding support so for now you could still use the time card and get extremely accurate time on the pie itself and very accurate time over in the network using software timestamping or good old ntp but until that bug is fixed the pi can't be set up as a definitive hardware grandmaster ptp clock so it looks like it may be a little longer before google amazon facebook and everyone else starts adopting the raspberry pi as the new time server standard but i have it on high authority that facebook engineers have worked directly with broadcom and the pi engineers to get this thing working i have a feeling this won't be my last video on the time card i haven't even scratched the surface of what you can do with it how about synchronized motion for industrial automation or new audio and video broadcast standards like aes67 or cemti2110 and how about 5g networking or people who want to sync up live audio equipment with a master clock like in a dac accurate time helps in all these areas today and current solutions use expensive proprietary hardware heck what if every car had a time card in it maybe alec from technology connections would finally achieve his dream of every car on the road having synchronized blinkers special thanks to a mod from facebook engineering for sending this card also to everyone on his team who's worked on this open source project and made it possible for me to make this video about clocks it's about time if you want to learn even more about the time card before i do another video on it check out the two videos i linked in the description one by tech tech potato and another by bailinus tech tips and finally right as i started recording this video i found out about will wang's project which is basically putting the important parts of the time card right onto a compute module 4 board take a look at this i'll be following both of these projects pretty closely but until next time i'm jeff gearling by the time we finish this all broken part of this card i'm sure have been around for decades and gps based timing has been a thing for a while now too two and here's the interesting wrinkle about the compute module four that is not an interesting wrinkle that's a burp tech tech potato tech tech potato i probably look like an idiot if anybody's watching me right now all right well that's a wrap
Info
Channel: Jeff Geerling
Views: 160,921
Rating: undefined out of 5
Keywords: raspberry pi, time card, ptp, ntp, pps, atomic clock, cm4, compute module, pci, pci express, pcie, facebook, open source, open hardware, open compute project, linux, compile, kernel, red shirt jeff, cesium, rubidium, guide, tutorial, setup, hardware timestamping, software, nic, driver, broadcom, bcm54210pe, pi 4, hat, fpga, gps, timing, master clock, grand master, grandmaster, sync, dac, audio, broadcast, smpte 2110, aes67, video, industrial automation, data center, radio, gnss, glonass
Id: tU0xC1ynaT8
Channel Id: undefined
Length: 11min 19sec (679 seconds)
Published: Wed Sep 01 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.