How to build an Atomic Clock

OK there’s a degree of licence in the title here, but unlike the “Daily Toilet Paper” which came up with headlines such as “Freddie Star Ate My Hamster” to increase it’s circulation, there’s more truth in my tag line than meets the eye.

You’re here now so read on!

As a kid I grew up in the era of having only three TV channels which switched off at midnight after the ceremonial playing of the National Anthem. As such there was a lot more radio in the house than there is today and I was always intrigued by “The Pips” which chimed out on Radio 4 at the top of the hour. I can see some people saying “You what?”

Yep those are “The Pips” also more formally known as the Greenwich Time Signal. As a nipper they always seemed a bit of fun just before the boring news, but when my Dad told me that they were generated by a very precise clock called an Atomic Clock . . . Wow! All sorts of mad scientist James Bond evil villain lair images sprung to mind. Now as you get older those images fade (slightly) as you become more educated and grown up, but the words atomic clock still conjure up images of machines the size of the CERN super collider. Now undoubtedly at one stage of their development they were and you could ask the question what use are they and what relevance is all this to radio as a sport?

Well firstly an atomic clock uses the “oscillation frequency” of particles (the rate at which they move up and down) to provide a very accurate time. That’s a bit simplistic but have a look at Wikipedia’s entry about Atomic Clocks for a more accurate explanation.

WSPR relies on a very accurate clock to sync the transmission and reception of WSPR signals.

Hence, accurate clock = a whole world of other radio related projects!

My WSPR receiver (see earlier posts) used a PC running Meinberg NTP to decode WSPR signals. My Ultimate 3 beacon uses a GPS signal to synchronise the clock within for transmission.

My plans next year are to have a crack at some other SDR projects based around new kit on the market and as part of the background reading ahead of parting with any money I discovered that one of these devices allowed for attachment of a 10Mhz external clock reference. A few months earlier, Everyday Practical Electronics (EPE) ran a constructional project around building, wait for it, an atomic clock or more accurately a rubidium standard. I can see peoples eyes glazing here but bear with me.

All a rubidium standard does, is provide a very accurate signal pulse, in the case of the EPE project it was a 10Mhz signal which could be used as a reference source for calibrating or testing things on a work bench.

I had visions of this costing thousands and requiring a degree in atomic physics to complete. Erm no, about £125 quid and the ability to solder half a dozen wires!

$(KGrHqV,!icE8V7Bpn1PBP(BziLqIw--60_12

That my friends, is a rubidium standard. It’s about the size of a paperback book and thanks to our friends in China and the ex Soviet block there are loads of these things sloshing about on the internet. I’m sure they may well have been lurking in a bunker along with other things which would make you glow in the dark in less friendlier times, but in these days of world peace and consumerism they’re being flogged off left right and Chelsea! All you need to do is give it power and you’re off.

Now as tempting as it was to build one, I haven’t. What I have built is the next best thing, which is a precursor to other projects and is a proof of concept. It also has a host of practical applications.

What I’ve built is a GPSDO based NTP server. Again I here a “You what?” A GPS (Global Positioning System) Defined Oscillator based Network Time Protocol server.

Breaking it down further the GPS satellites orbiting the earth transmit a time signal which your satnav sat on the dashboard of your car receives, does some maths with the data inside that signal and works out where you are. That time signal is highly accurate, lets face it the US military have been using it to help bomb countries back to the stone age for decades so it must be good!

An NTP server provides computers with an accurate time reference. Have a look at Wikipedia for a proper introduction and explanation.

NTP helps keep things on track. Lets face it, without it your PC’s clock will drift significantly. If you have a rummage around in the clock settings within Windows you’ll see that Mr Gates wants your computer to use the good old Microsoft time servers by default.

ntp-setup-H1

Now that is all well and good and for the majority of people will do the job nicely, but like everything there are limitations.

NTP services are hierarchical in nature and the various levels are referred to as Stratum

350px-Network_Time_Protocol_servers_and_clients.svg

Stratum 0 -These are high-precision timekeeping devices such as atomic (caesium or rubidium) clocks, GPS clocks or other radio clocks. They generate a very accurate pulse per second signal that triggers an interrupt and timestamp on a connected computer. Stratum 0 devices are also known as reference clocks.

Stratum 1 – These are computers whose system clocks are synchronized to within a few microseconds of their attached stratum 0 devices. Stratum 1 servers may peer with other stratum 1 servers for sanity checking and backup. They are also referred to as primary time servers

Stratum 2 – These are computers that are synchronized over a network to stratum 1 servers. Often a stratum 2 computer will query several stratum 1 servers. Stratum 2 computers may also peer with other stratum 2 computers to provide more stable and robust time for all devices in the peer group.

Stratum 3 – These are computers that are synchronized to stratum 2 servers. They employ exactly the same algorithms for peering and data sampling as stratum 2, and can themselves act as servers for stratum 4 computers, and so on.

Network speed, latency, network outage and so forth will reduce how “Average Joe” at the bottom of the pile receives their NTP source. By having a Stratum 1 computer within your network you are self reliant!

So, how many thousands of pounds does this cost I here you ask? Less than £50!

The ingredients for this little project are a Raspberry Pi (B+ in my case), a Raspberry Pi B+ GPS Expansion Board and an antenna.

20151216_094931

Plumb it all together and you get

20151216_100801

Apart from it looking pretty cool it does exactly what you want very well. The GPS Expansion Board is based on a Ublox MAX-M8Q positioning module and is pretty damn accurate! Admittedly it’s a motion based unit rather than a timing module but by issuing it with a serial command, it can be placed in “Stationary” dynamic mode which is the default mode for the much more expensive timing modules. I haven’t sussed that yet but all in good time!

The AVA High Altitude Balloon Project site has a very good How To which is what this project is based upon.

Also worth a read is the satsignal.eu Raspberry Pi Quickstart and the Raspberry Pi NTP guide.

Now unfortunately there’s a cautionary tale linked to this “How To”. All the bits turned up by Monday and on Tuesday I had a spare hour before going to work and decided to get it all working. The AVA walk through worked perfectly and I had the server generating a more and more stable time signal as it settled down after finalising things. Originally I had used a network cable to speed things up rather than using WiFi. The final step was to configure the on board WiFi to give it a fixed IP address and off you go.

Having played with Raspberry Pi’s before, the WiFi networking can be a real pain and not very stable but I bit on the bullet, started the GUI and began entering SSID’s and network passwords. At this point the GUI crashed quite spectacularly, locking up the machine. Having corrupted the SD card on a previous occasion by yanking the power cable I was reluctant to undo the last hours work, so while still being able to PuTTY into the Pi I rebooted it, only to find the damn thing had corrupted the SD card. Awesome!

Not wishing to be too defeatist, knowing it worked in principle I left it alone until Friday when I had a spare hour again to start from scratch. Until that hour turned into half a day! For some strange reason the device kept corrupting, refusing to boot and powering off the on board NIC so you couldn’t get into it via SSH or by being plugged into a monitor with a keyboard!

Now this caused a considerable amount of head scratching and effing and jeffing! Setting up a Raspberry Pi is simple but not the quickest of processes. At one stage I had two machines burning Wheezy and Jessie images to SD cards in a little production line ready for when I trashed the next one!

Both the AVA guide and Satsignal.eu guide have the following primary steps which get the Raspberry Pi ready for installation of the packages which actually do the clever stuff –

sudo raspi-config
1. Expand Filesystem
2. Advanced Options -> Disable Serial Shell (optional)
Reboot

sudo apt-get update            – tells the Pi to update its list of available packages
sudo apt-get dist-upgrade – updates the Pi’s distribution to the latest version
sudo rpi-update                    – updates the Pi’s firmware to the latest version
sudo reboot                            – reboots the Pi ready for the next stage and allows the updates to finalise and so forth

sudo apt-get install pps-tools – first step of installing all the necessary bits and pieces to get the GPS side of things working

Now by process of elimination (and this wasn’t quick!) I found the Pi was dying after pps-tools was installed, which was far from helpful.

The only conclusion I could make is that between Tuesday lunchtime and Friday morning a package in the distribution upgrade or the firmware update had been altered/upgraded and released to the world, which was killing the Pi once pps-tools was installed.

Proof of concept comes in that if you omit the steps

sudo apt-get update
sudo apt-get dist-upgrade
sudo rpi-update
sudo reboot

everything works perfectly!

Now how do you prove it’s working? Good question. Once the NTP server is running, issuing an ntpq -p command gives you data

Screenshot 2015-12-20 16.42.04

  • The display is a list of remote servers with various status reports arranged in columns.
  • One remote server should have an asterisk (*) in the first column.  This marks the server which NTP has selected as the current preferred source.
  • Servers which have a plus sign (+) are good enough for NTP to sync to, others are not.
  • The reach column should not be 0, and will expand from 1 during the normal working of NTP until it reaches 377.  It is an octal display of a bit-mask showing when the server was reached.  Normally you expect to see 377 in this column against each server.  A column of all zeros means that NTP can’t contact any servers.
  • The offset shows how far your PC is off from a nominal UTC, and the value is in milliseconds.
  • The poll value should gradually increase from 64 seconds to 1024 seconds as NTP needs to contact the server less and less frequently as the clock offset and frequency are gradually corrected.  Changing the poll is automatic in NTP.
  • The delay shows the time for a packet from your PC to reach the remote server and vice versa.  Values above 150ms may indicate a satellite circuit and it’s best to avoid such servers if possible.  You will get best performance from servers which are close to you on the network.
  • The jitter column shows how stable the connection between you and the remote server is.
  • The st column shows the stratum of the server, with stratum 1 servers having a local reference such as an atomic clock or, for many servers, a radio-clock or GPS receiver reference.  Most servers you will see are at stratum 2, so they are locked to a stratum-1 server.  A lightly loaded stratum-2 server is probably a better reference than a heavily loaded stratum-1 server such as those with widely-publicised addresses.

Now that the server is working and providing good stable timings it’d be a shame not to share it! This can be done in a multitude of ways. You can add the IP address of your NTP server to you hosts file within Windows as a TIMESERVER, so when you go to your time and date settings it’s there as an option to select.

Alternatively, if you use Meinberg NTP, by adding the NTP server to the ntp.conf file your local machine then has a Stratum 1 time server available to it.

Screenshot 2015-12-20 16.46.56

I’m slowly editing all the clock settings on my network machines to allow them to utilise the local NTP server as well as trying to get my head around trying to monitor the server’s stats using MRTG. MRTG is easier said than done as it’s based on Pearl and I haven’t done any scripting in years, but that’s another rainy day project.

As I said at the beginning this is a proof of concept for another project and it works a treat!

 

Advertisements

An alternative 2m antenna

After busting a gut to get my Diamond X30 up in the sky I was slightly disappointed with the absence of 2m activity. Admittedly I had a cracking WBFM reception for commercial radio and the POGSAC pager things I have been playing with utilising an RTL-SDR dongle were much improved, but I seemed to be missing a trick.

From consulting with the mine of information who is Mike (G0JMI) of Alton Antenna Arrays it transpires that as good as the Diamond X30 is, like everything it has its limitations.

Basically, the X30 is very similar to other verticals and its radiating section is about 3/4 wavelength on 2m (or there-abouts).

Three Qtr Wave Vertical Radiation Pattern 001

Above is the predicted vertical-plane radiation pattern for this form of antenna when used on 2m (145MHz) and you can see a bit of a gap at the lower bottom end where we would like energy to be if we are going to work stations at ground level.

When used on 70cm (434MHz), the vertical works as a 9 1/4 wavelength antenna and throws more radiations laterally making it better for working stations at ground level.  The predicted vertical-plane pattern for 70cm is below.

Nine Qtr Wave Vertical Radiation Pattern 002
The alternative 2m antenna to overcome this gap is a 2m half wave dipole.

Half Wave Vertical Dipole Radiation Pattern 003

As can be seen from the predicted vertical-plane radiation pattern for a 2m (145MHz) dipole and you can see that lots of useful power goes horizontally to allow us to work stations at ground level.  This antenna on 70cm has a similar radiation pattern to the 9 1/4 wavelength type outlined above, so is good for that too.

The X30 as a 2m 3/4 wave vertical is good for working stations through satellites because of the amount RF thrown upwards.

As such, making a simple half wave dipole for 2m work, especially joining in the local club nets seemed like the ideal solution.

The components to build one were very few and far between – a dipole centre, two lengths of aluminium tube, some RG58 coax and half an hour.

20151209_120008

20151209_123447

20151209_141150

And there you have it! The hardest part was winding the 6 turns into the coax to make the choke-balun and getting it to stay there. If you’ve ever tried wresting an uncooperative snake you’ll know what I’m talking about!

Tuning the dipole down to centre frequency involved nibbling off 3mm lengths from the dipole arms until the SWR was down to 1.2:1. That proved a little problematical as I was relying on the FTL meter attached to my rig and when I got down to the predicted length all of a sudden the SWR which had been coming down nicely started to increase!

With a bit of assistance in the form of someone more knowledgeable, an antenna analyser and a trusty Oskerblock SWR200 dating from the 1970’s, all was eventually overcome. If anything it demonstrates that reliance on cutting edge tech to make things isn’t necessarily the way to go. The MFJ-269C antenna analyser wasn’t as accurate or reliable as we’d hoped and by relying on gut instinct and the two analogue meters of the Oskerblock we got there.

I’ve now got a very nice homebrew antenna that is great on both 2m and 70cm’s and can be used for both the local club net and satellite work!

20151211_112629

 

QSO Mapping #2

Having taken inspiration from Andy’s pages at Alloutput.com I’ve been progressing the idea of generating cleaner maps of my QSOs. As mentioned in my earlier posts I’ve progressed from the rudimentary maps generated by the online adif2map type solution, through to an KML import into Google Earth.

Both of these provide nice maps which allow you to click on specific contacts for more details. The problem comes, as Andy states, when you spread your wings further or you end up with a very dense saturation of an area or country.

As of today my contact map on Google Earth looks like this

Screenshot 2015-10-25 08.26.55

Screenshot 2015-10-25 08.28.25

I must admit I like the curvature of the globe representation and when you start overlaying sunlight across the landscape animation it really becomes quite surreal, however it’s always worth exploring other options.

I had a good read of Jeff’s pages at http://n1ywb.blogspot.co.uk/ and realised rapidly that I really don’t know the first thing about Python scripts but not to be defeated I had a good play with some of the ideas which are discussed and have come up with a solution which appears to work nicely.

My notes are below for reference.

I’m still logging my contacts primarily within the Fldigi logbook and manually uploading to the usual sites to gain credit for various awards.

Fldigi has an ADIF export function which generates the required ADI file. To convert this to an XML file, rather than paying for a subscription service within QRZ.com I use a standalone package to do this.

ADIF2KML by CT1GVN http://www.qsl.net/ct1gvn/adif2kml.htm does the job nicely. Ironically it’s a Python script that someone has very kindly packaged in a ready to run format. It takes your ADIF file and produces the KML file ready to load into Google Earth and the data appears in the My Places pane on the left hand side allowing you to switch various elements on and off for analysis.

For the next step I grasped the nettle and installed QGIS http://www.qgis.org/en/site/ which is a very complex package and you could make a hobby out of playing with maps very easily.

I completely missed the “Gentle Guide to QGIS” http://docs.qgis.org/2.8/en/docs/gentle_gis_introduction/ and ended up at the “Getting Started section ” which had me playing with lakes in America for a good half an hour before I had the slightest idea as to what I was doing – http://docs.qgis.org/2.8/en/docs/user_manual/introduction/getting_started.html

I downloaded the 1:10m natural earth set from http://www.naturalearthdata.com/downloads/10m-raster-data/10m-natural-earth-1/ opting for the large size Natural Earth I with Shaded Relief, Water and Drainages detail.

I must admit that all these packages and map sets are very large and chomp up disk space, however I think the level of detail certainly adds to the finished product.

From within QGIS open the NE1_HR_LC_SR_W_DR.tif from the naturalearthdata.com dataset as a Raster layer.

Screenshot 2015-10-25 16.11.21

The detail level is very nice for what I’m trying to achieve

Screenshot 2015-10-25 16.12.46

The next step is to import the KML file generated by ADIF2KML as a Vector Layer. Thankfully there is no need to edit any of its contents to remove any extraneous data as mentioned in other blogs, which is a bonus.

Screenshot 2015-10-25 16.16.55

Screenshot 2015-10-25 16.17.11

The various elements forming the vector layer can be selected depending on what you want to map. Here I’ve selected only 40m contacts which show my recent success in bagging QSO’s in Northern Ireland and Yorkshire.

Screenshot 2015-10-25 16.29.13

The finished product for this stage is below

test2

Below is with the map skewed to show European Russian contacts.

european russia

I’ve tried repeatedly to produce a great earth projection for this data but unfortunately each time I generate my globe projection it explodes quite spectacularly when you zoom in. Zooming out does not rectify the problem either which is extremely frustrating. Unfortunately I don’t have the time or the knowledge with the QGIS software to overcome this issue, so at the moment I’ll be sticking with what we’ve got.