{"id":10999,"date":"2023-04-05T09:48:59","date_gmt":"2023-04-05T13:48:59","guid":{"rendered":"https:\/\/www.engineeringradio.us\/blog\/?p=10999"},"modified":"2024-04-02T09:02:56","modified_gmt":"2024-04-02T13:02:56","slug":"what-time-is-it","status":"publish","type":"post","link":"https:\/\/www.engineeringradio.us\/blog\/2023\/04\/what-time-is-it\/","title":{"rendered":"What time is it?"},"content":{"rendered":"\n<p>This is an important question these days.  We are running into more situations where timing is important, especially when audio and video codecs are concerned.  If there is too much time differential, the codec will unlock.  More often, digital transmission methods require precise timing to prevent jitter and dropouts.  Some equipment has 10 MHz or 1PPS inputs.  Some equipment does not and relies on NTP to keep things in sync.<\/p>\n\n\n\n<p>While searching online for GPS time sever, I came across this post where <a rel=\"noreferrer noopener\" href=\"https:\/\/austinsnerdythings.com\/2021\/04\/19\/microsecond-accurate-ntp-with-a-raspberry-pi-and-pps-gps\/\" target=\"_blank\">Austin<\/a> built a Stratum 1 level time sever with a Raspberry pi and an inexpensive GPS receiver.  I thought to myself; damn that sounds interesting. While a Raspberry pi is a hobbyist toy, the same setup can be done with a more serious computer to create a solid NTP server for a facility or LAN.<\/p>\n\n\n\n<p>A little about <a href=\"https:\/\/en.wikipedia.org\/wiki\/Network_Time_Protocol\" target=\"_blank\" rel=\"noreferrer noopener\">NTP<\/a> time servers; Stratum 0 server is directly connected to an atomic clock.  Since <a href=\"https:\/\/en.wikipedia.org\/wiki\/Global_Positioning_System\" target=\"_blank\" rel=\"noreferrer noopener\">GPS<\/a> satellites have atomic clocks, that makes them a Stratum 0 server.  Stratum 1 servers are connected to Stratum 0 servers.  Stratum 2 servers are connected to Stratum 1 servers and so on.  The time accuracy for a Stratum 1 server is 10 microseconds.<\/p>\n\n\n\n<p>First, I wiped my SD card and loaded a fresh install of Raspberry pi OS.  Then followed along with the instructions.  For this install, I opted for the cheaper GPS receiver, the <a rel=\"noreferrer noopener\" href=\"https:\/\/www.amazon.com\/dp\/B07P8YMVNT?psc=1&amp;ref=ppx_yo2ov_dt_b_product_details\" target=\"_blank\">GT-U7<\/a> (not an affiliate link) from Amazon for $10.99.  It comes with a cheap little antenna, which actually worked sitting inside on my desktop while I was configuring the software. <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1195\" height=\"900\" src=\"https:\/\/www.engineeringradio.us\/blog\/wp-content\/uploads\/2023\/04\/PXL_20230405_132727780-1195x900.jpg\" alt=\"\" class=\"wp-image-11386\" srcset=\"https:\/\/www.engineeringradio.us\/blog\/wp-content\/uploads\/2023\/04\/PXL_20230405_132727780-1195x900.jpg 1195w, https:\/\/www.engineeringradio.us\/blog\/wp-content\/uploads\/2023\/04\/PXL_20230405_132727780-650x489.jpg 650w, https:\/\/www.engineeringradio.us\/blog\/wp-content\/uploads\/2023\/04\/PXL_20230405_132727780-150x113.jpg 150w, https:\/\/www.engineeringradio.us\/blog\/wp-content\/uploads\/2023\/04\/PXL_20230405_132727780-768x578.jpg 768w, https:\/\/www.engineeringradio.us\/blog\/wp-content\/uploads\/2023\/04\/PXL_20230405_132727780-1536x1157.jpg 1536w, https:\/\/www.engineeringradio.us\/blog\/wp-content\/uploads\/2023\/04\/PXL_20230405_132727780-2048x1542.jpg 2048w\" sizes=\"auto, (max-width: 1195px) 100vw, 1195px\" \/><\/figure>\n\n\n\n<p>This little module is designed for a drone but works well in this application.  The 1PPS output looks clean on the scope.   Here is the <a href=\"https:\/\/pinout.xyz\/#\" target=\"_blank\" rel=\"noreferrer noopener\">pinout <\/a>between the GT-U7 and the Raspberry pi:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>GT-U7 pin<\/td><td>pi pin<\/td><td>Use<\/td><td>Color<\/td><\/tr><tr><td>vcc<\/td><td>1<\/td><td>+3.3 vdc<\/td><td>Green<\/td><\/tr><tr><td>gnd<\/td><td>6<\/td><td>ground<\/td><td>Brown<\/td><\/tr><tr><td>txd<\/td><td>8<\/td><td>rxd<\/td><td>Orange<\/td><\/tr><tr><td>rxd<\/td><td>10<\/td><td>txd<\/td><td>Red<\/td><\/tr><tr><td>pps<\/td><td>12<\/td><td>GPIO 18<\/td><td>Yellow<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1195\" height=\"900\" src=\"https:\/\/www.engineeringradio.us\/blog\/wp-content\/uploads\/2023\/04\/PXL_20230331_232738612-1195x900.jpg\" alt=\"\" class=\"wp-image-11369\" style=\"width:690px;height:519px\" srcset=\"https:\/\/www.engineeringradio.us\/blog\/wp-content\/uploads\/2023\/04\/PXL_20230331_232738612-1195x900.jpg 1195w, https:\/\/www.engineeringradio.us\/blog\/wp-content\/uploads\/2023\/04\/PXL_20230331_232738612-650x489.jpg 650w, https:\/\/www.engineeringradio.us\/blog\/wp-content\/uploads\/2023\/04\/PXL_20230331_232738612-150x113.jpg 150w, https:\/\/www.engineeringradio.us\/blog\/wp-content\/uploads\/2023\/04\/PXL_20230331_232738612-768x578.jpg 768w, https:\/\/www.engineeringradio.us\/blog\/wp-content\/uploads\/2023\/04\/PXL_20230331_232738612-1536x1157.jpg 1536w, https:\/\/www.engineeringradio.us\/blog\/wp-content\/uploads\/2023\/04\/PXL_20230331_232738612-2048x1542.jpg 2048w\" sizes=\"auto, (max-width: 1195px) 100vw, 1195px\" \/><\/figure>\n\n\n\n<p>I found this really nice aluminum case in a pile of disused junk at a transmitter site.  It used to be for a digital TELCO STL circuit.  I figured it would be nice to put the Raspberry pi and GPS receiver in a suitable home.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1195\" height=\"900\" src=\"https:\/\/www.engineeringradio.us\/blog\/wp-content\/uploads\/2023\/04\/PXL_20230405_132746985-1195x900.jpg\" alt=\"\" class=\"wp-image-11387\" srcset=\"https:\/\/www.engineeringradio.us\/blog\/wp-content\/uploads\/2023\/04\/PXL_20230405_132746985-1195x900.jpg 1195w, https:\/\/www.engineeringradio.us\/blog\/wp-content\/uploads\/2023\/04\/PXL_20230405_132746985-650x489.jpg 650w, https:\/\/www.engineeringradio.us\/blog\/wp-content\/uploads\/2023\/04\/PXL_20230405_132746985-150x113.jpg 150w, https:\/\/www.engineeringradio.us\/blog\/wp-content\/uploads\/2023\/04\/PXL_20230405_132746985-768x578.jpg 768w, https:\/\/www.engineeringradio.us\/blog\/wp-content\/uploads\/2023\/04\/PXL_20230405_132746985-1536x1157.jpg 1536w, https:\/\/www.engineeringradio.us\/blog\/wp-content\/uploads\/2023\/04\/PXL_20230405_132746985-2048x1542.jpg 2048w\" sizes=\"auto, (max-width: 1195px) 100vw, 1195px\" \/><\/figure>\n\n\n\n<p>Raspberry pi 3 is mounted on a piece of scrap sheet steel designed to slide into the aluminum case.<\/p>\n\n\n\n<p>We have several of these nice Panasonic GPS antennas left over from various installs.  I pressed one into service on the roof of my house.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"678\" height=\"900\" src=\"https:\/\/www.engineeringradio.us\/blog\/wp-content\/uploads\/2023\/04\/PXL_20230403_144523671-678x900.jpg\" alt=\"\" class=\"wp-image-11381\" srcset=\"https:\/\/www.engineeringradio.us\/blog\/wp-content\/uploads\/2023\/04\/PXL_20230403_144523671-678x900.jpg 678w, https:\/\/www.engineeringradio.us\/blog\/wp-content\/uploads\/2023\/04\/PXL_20230403_144523671-452x600.jpg 452w, https:\/\/www.engineeringradio.us\/blog\/wp-content\/uploads\/2023\/04\/PXL_20230403_144523671-113x150.jpg 113w, https:\/\/www.engineeringradio.us\/blog\/wp-content\/uploads\/2023\/04\/PXL_20230403_144523671-768x1020.jpg 768w, https:\/\/www.engineeringradio.us\/blog\/wp-content\/uploads\/2023\/04\/PXL_20230403_144523671-1157x1536.jpg 1157w, https:\/\/www.engineeringradio.us\/blog\/wp-content\/uploads\/2023\/04\/PXL_20230403_144523671-1542x2048.jpg 1542w, https:\/\/www.engineeringradio.us\/blog\/wp-content\/uploads\/2023\/04\/PXL_20230403_144523671-scaled.jpg 1928w\" sizes=\"auto, (max-width: 678px) 100vw, 678px\" \/><\/figure>\n\n\n\n<p>Panasonic CCAH32ST01 GPS antenna<\/p>\n\n\n\n<p>I think a high-quality antenna is pretty important to get consistent good performance from this setup.  There are three slight problems, however.  Unfortunately, this antenna has been discontinued by the manufacturer.  Also unfortunate, the GT-7U boards have one of those little IPX RF connectors.  Fortunately, I found a short jumper with an F SMA connector.  Finally, it requires +5 VDC and the GT-7U runs on 3.3 VDC.  The pi does have a 5-volt rail, so I used this 2-way power divider to feed 5 volts to the antenna from one port and the received RF from the antenna goes to the GT-U7 from the other port.<\/p>\n\n\n\n<p>If you are interested, here are the commands to get this thing running:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo apt get update\nsudo apt get upgrade -y\nsudo apt install pps-tools gpsd gpsd-clients chrony<\/pre>\n\n\n\n<p>The next step is to make sure the serial port is turned on and enable the ssh login shell since this is going to live in the basement and I don&#8217;t want to run down there to fool around with it.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo raspi-config<\/pre>\n\n\n\n<p>Then go to interface options, serial interface, and enable.  The login over the serial interface can be left off.  If ssh access is needed, enable ssh, then exit.<\/p>\n\n\n\n<p>Once those packages have been downloaded and installed, some config file editing is needed.  You may use whichever method you like, I tend to use nano.  First, the \/etc\/config.txt and add the following to the file:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\u2018dtoverlay=pps-gpio,gpiopin=18\u2019\n'enable_uart=1'\n'init_uart_baud=9600'<\/pre>\n\n\n\n<p>The uart needs to be enabled if you want to receive NMEA data (NMEA stands for <a href=\"https:\/\/www.marine-ed.org\/\" target=\"_blank\" rel=\"noreferrer noopener\">National Marine Electronics Association<\/a>)  It is helpful to see if or how the GPS is working.<\/p>\n\n\n\n<p>Next, the \/etc\/modules and add:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">'pps-gpio'<\/pre>\n\n\n\n<p>Reboot, then see if the pps module is working:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">lsmod | grep pps<\/pre>\n\n\n\n<p>The output should look like this:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"786\" height=\"533\" src=\"https:\/\/www.engineeringradio.us\/blog\/wp-content\/uploads\/2023\/04\/Screenshot-from-2023-04-03-12-04-29.png\" alt=\"\" class=\"wp-image-11375\" srcset=\"https:\/\/www.engineeringradio.us\/blog\/wp-content\/uploads\/2023\/04\/Screenshot-from-2023-04-03-12-04-29.png 786w, https:\/\/www.engineeringradio.us\/blog\/wp-content\/uploads\/2023\/04\/Screenshot-from-2023-04-03-12-04-29-650x441.png 650w, https:\/\/www.engineeringradio.us\/blog\/wp-content\/uploads\/2023\/04\/Screenshot-from-2023-04-03-12-04-29-150x102.png 150w, https:\/\/www.engineeringradio.us\/blog\/wp-content\/uploads\/2023\/04\/Screenshot-from-2023-04-03-12-04-29-768x521.png 768w\" sizes=\"auto, (max-width: 786px) 100vw, 786px\" \/><\/figure>\n\n\n\n<p>Next, there are a few more configuration files that need to be edited.<\/p>\n\n\n\n<p>\/ect\/default\/gpsd &#8211; there is a default file that comes with the package, it needs to be modified to start the daemon automatically and look for the pps signal on ttyS0.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">START_DAEMON=\"true\"\nUSBAUTO=\"true\"\nDEVICES=\"\/dev\/ttyS0 \/dev\/pps0\"\nGPSD_OPTIONS=\"-n\"<\/pre>\n\n\n\n<p>Reboot<\/p>\n\n\n\n<p>Now check and see if the GPS module is working by typing cgps or gpsmon.  The output should look something like this:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"786\" height=\"533\" src=\"https:\/\/www.engineeringradio.us\/blog\/wp-content\/uploads\/2023\/04\/Screenshot-from-2023-04-03-12-17-20.png\" alt=\"\" class=\"wp-image-11376\" style=\"width:691px;height:468px\" srcset=\"https:\/\/www.engineeringradio.us\/blog\/wp-content\/uploads\/2023\/04\/Screenshot-from-2023-04-03-12-17-20.png 786w, https:\/\/www.engineeringradio.us\/blog\/wp-content\/uploads\/2023\/04\/Screenshot-from-2023-04-03-12-17-20-650x441.png 650w, https:\/\/www.engineeringradio.us\/blog\/wp-content\/uploads\/2023\/04\/Screenshot-from-2023-04-03-12-17-20-150x102.png 150w, https:\/\/www.engineeringradio.us\/blog\/wp-content\/uploads\/2023\/04\/Screenshot-from-2023-04-03-12-17-20-768x521.png 768w\" sizes=\"auto, (max-width: 786px) 100vw, 786px\" \/><\/figure>\n\n\n\n<p>It did not take the module too long to find and lock onto GPS.  If you don&#8217;t see something like this in five minutes or so, go back and check your wiring, and make sure that the data connections are made right.  The GT-U7 has a little red LED that is lit when the PPS pulse is <em>not<\/em> being sent.  If this light is not on at all, check your power connection.  If it is on steady, check your antenna.  If it is flashing, but you are not seeing any output in cgps or gpsmon, check your data connections. <\/p>\n\n\n\n<p> Next and last configuration file is the \/etc\/chrony\/chrony.conf file.   At the top of the file, I added the following lines:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">#custom lines for PPS\nserver time-a-g.nist.gov iburst\nserver time-d-g.nist.gov\nserver 3.us.pool.ntp.org\nserver time.windows.com\nserver time.apple.com\n# add refclock pps\nrefclock SMH 0 delay .1 refid NEMA\nrefclock PPS \/dev\/pps0 refid PPS\n#my home network\nallow 192.168.1.0\/24<\/pre>\n\n\n\n<p>Leave the rest of the file alone.  Basically, the time servers are added to compare the GPS time and act as a backup.  The hosts on my home network are allowed to query this host and use it as an NTP server.<\/p>\n\n\n\n<p>Restart Chrony:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo systemctl restart chrony<\/pre>\n\n\n\n<p>Wait a couple of minutes and check the chrony console to see what is happening: chronyc sources.  Should look something like this:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"786\" height=\"533\" src=\"https:\/\/www.engineeringradio.us\/blog\/wp-content\/uploads\/2023\/04\/Screenshot-from-2023-04-03-13-44-46.png\" alt=\"\" class=\"wp-image-11379\" srcset=\"https:\/\/www.engineeringradio.us\/blog\/wp-content\/uploads\/2023\/04\/Screenshot-from-2023-04-03-13-44-46.png 786w, https:\/\/www.engineeringradio.us\/blog\/wp-content\/uploads\/2023\/04\/Screenshot-from-2023-04-03-13-44-46-650x441.png 650w, https:\/\/www.engineeringradio.us\/blog\/wp-content\/uploads\/2023\/04\/Screenshot-from-2023-04-03-13-44-46-150x102.png 150w, https:\/\/www.engineeringradio.us\/blog\/wp-content\/uploads\/2023\/04\/Screenshot-from-2023-04-03-13-44-46-768x521.png 768w\" sizes=\"auto, (max-width: 786px) 100vw, 786px\" \/><\/figure>\n\n\n\n<p>This was after the server had been running for a day.  <a rel=\"noreferrer noopener\" href=\"https:\/\/chrony.tuxfamily.org\/\" target=\"_blank\">Chrony<\/a> is great because it measures the hardware performance and creates a delay file.  This is used to anticipate any hardware-added delays that the system might have.  The last sample column is of interest, the number indicates the offset between the local clock and the source at the last measurement.  The far column is the margin of error or greatest variation +\/- of the expected values.  A value of 0.0000000042 seconds or 0.042 microseconds is pretty good for an $11.00 piece of hardware.  Now every host in my house is syncd to satellite within 0.042 microseconds, in lockstep through the time-space continuum. <\/p>\n\n\n\n<p>If I were to do this professionally, I would use better hardware.  I think the pi 4 has better serial and ethernet interfaces, more RAM, and a quad-core processor.  Last I looked they were $75.00 at <a href=\"https:\/\/www.newark.com\/raspberry-pi\/rpi4-modbp-8gb\/raspberry-pi-4-model-b-8gb\/dp\/64AH2041\" target=\"_blank\" rel=\"noreferrer noopener\">Newark<\/a>.<\/p>\n\n\n\n<p>The GPS module was the cheapest I could find on Amazon.  I am slightly concerned about the longevity of this device.  Perhaps it will run for a long time, or perhaps not.  A quick search brought up several &#8220;hats&#8221; (plug directly into the 20-pin header).  These range in price from about $30.00 to $60.00.  What is required of any GPS module is 1PPS output.  The configuration would be about the same although some use GPIO 4 instead of 18.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is an important question these days. We are running into more situations where timing is important, especially when audio and video codecs are concerned. If there is too much time differential, the codec will unlock. More often, digital transmission methods require precise timing to prevent jitter and dropouts. Some equipment has 10 MHz or &hellip; <a href=\"https:\/\/www.engineeringradio.us\/blog\/2023\/04\/what-time-is-it\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">What time is it?<\/span><\/a><\/p>\n","protected":false},"author":4,"featured_media":11391,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[102,4],"tags":[333,148,303,55],"class_list":["post-10999","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-audio","category-tech-stuff","tag-atsc-3","tag-drm","tag-hd-radio","tag-tv"],"_links":{"self":[{"href":"https:\/\/www.engineeringradio.us\/blog\/wp-json\/wp\/v2\/posts\/10999","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.engineeringradio.us\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.engineeringradio.us\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.engineeringradio.us\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.engineeringradio.us\/blog\/wp-json\/wp\/v2\/comments?post=10999"}],"version-history":[{"count":17,"href":"https:\/\/www.engineeringradio.us\/blog\/wp-json\/wp\/v2\/posts\/10999\/revisions"}],"predecessor-version":[{"id":12759,"href":"https:\/\/www.engineeringradio.us\/blog\/wp-json\/wp\/v2\/posts\/10999\/revisions\/12759"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.engineeringradio.us\/blog\/wp-json\/wp\/v2\/media\/11391"}],"wp:attachment":[{"href":"https:\/\/www.engineeringradio.us\/blog\/wp-json\/wp\/v2\/media?parent=10999"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.engineeringradio.us\/blog\/wp-json\/wp\/v2\/categories?post=10999"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.engineeringradio.us\/blog\/wp-json\/wp\/v2\/tags?post=10999"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}