The Trump time-to-go clock

By Peter Kent. Posted

On 20 January 2017, Donald J Trump was inaugurated as the 45th President of the United States of America. I remember the date well, because that was the day I stumbled across Nixie tubes for the first time. Out of these seemingly unrelated events emerged the Time-To-Go Clock, Trump Edition.

Like countless others, I felt a compelling need to say something about the new Commander-in-Chief. Spilling out more polarising words seemed pointless, however. Instead, I’d make something that would, literally and figuratively, speak for itself. 

The Clock’s defining feature, broadly hinted at in the name, is that it can display the time to any future event. In the case of the Trump Presidency, the US Constitution helpfully provides the exact time and date when his term of office will end. Of course, it is possible President Trump could be re-elected, in which case the clock can be easily set to the end of his second term (or any other date) without further programming. 

Somewhat conceitedly, the clock has its own dedicated website, which lists its major features as follows:

•  Optional cycling through time, date, Trump administration days-to-go, and Trump administration hours, minutes, and seconds-to-go

•  Simple, menu-driven setting using an LCD and website provided by the clock’s own server

•  Celebrates President Trump’s affinity for Twitter by tweeting the time left for his Administration at a random time each day

•  Uses Russian IN-14 Nixie tubes and Soviet-era military-grade toggle switches

• Uses an IR motion detector to turn off the tubes if no one is around to see them, and logs activity on the clock’s website

• Full operating instructions are also on the website

• Time and date obtained from the internet 

• Colour and brightness of LED backlights can be easily configured by the user

• 12/24-hour display choice

My first thought was to go with what I will politely refer to as the Trump Aesthetic – ‘Versailles-built-in-Blackpool’ perhaps sums it up best.

The big drawback to this approach was that I intended to display the clock in my own house. I have nothing against Blackpool – I am from there – or even Versailles, which is quite nice too. It’s simply that combining two equally wonderful things does not necessarily square the output.

So in the end I elected to give the clock a more Cold War beaten-up military vibe with a repurposed B&K A/V systems controller as an enclosure.

Stripping back the front panel revealed just what I had to work with

THE BUILD

Components – driver board and tubes

As a newbie to Nixie tubes, I wanted to cut down the risk of a total project failure. I also wanted to complete the project fairly rapidly.

For these reasons, I decided to base the clock on a pre-built driver board which was designed as an Arduino shield. I bought mine from GRA & AFCH in Ukraine. The board came pre-populated with IN-14 Nixies and was under $100, shipping included. 

The enduring appeal of using Nixie tubes in clock displays is not difficult to fathom. Despite their ineffable beauty, they are an obsolete technology, a physical embodiment of the passage of time, and a reminder of all things lost and irretrievable. 

Using the B&K as an enclosure was meant to amplify this theme. Solid and well-made, it might have provided many more years of service, but the lack of internet connectivity and HDMI connections simply overwhelmed it. 

The one thing that didn’t quite fit in was the faceplate of the B&K. It was far too nice. Fortunately, removing this exquisitely machined chunk of aluminium revealed a utilitarian steel panel ideal for my purposes. In all likelihood, you do not have a spare B&K Reference 30 A/V System Controller lying around. Do not despair. Just about any new or repurposed metal box will do – I’d recommend something at least 250 mm × 150 mm × 75 mm though, especially if you intend to include a four-line LCD and the other features I ended up with.  

Components – the rest

Arduino Mega or clone equivalent – although GRA & AFCH say the Clock shield would work with an Arduino Uno, in my implementation I needed the pins and extra processing grunt of the Mega.

Arduino Ethernet shield or clone – if I were to do this project again I’d probably try to use an ESP8266-based board for connectivity, but at the time I was more comfortable with the Ethernet shield.

I2C 20 × 4 LCD module. The display serves several useful purposes. It indicates what mode the Nixie tube display is in, greatly simplifies setting the future time being monitored, and indicates the time the clock has (or will) tweet that day. Another reason I included it though was as an example of a display technology that spelled the end for the Nixie. More practical, much cheaper, but hardly a thing of beauty. Take your pick.

Rotary encoder. The Clock shield comes with some momentary button switches which can be used for setting the clock. However, the additional functions of the clock would make button control alone very cumbersome and in any event they are not accessible in my enclosure design. The B&K actually uses a very nice rotary encoder as part of its own control scheme which I could have reused. However, the B&K’s encoder did not incorporate a momentary switch, which meant you could not easily select an option dialled in using the encoder. 

Toggle switches add a more tactile experience than push-buttons

Switches. The rotary encoder working with the LCD display allows many setting and control functions to be combined in a user-friendly way. However, for some functions you just cannot beat the convenience and satisfaction of flipping a sturdy toggle switch.

Potentiometer. Used to control dimming of the backlight on the LCD display.

IR motion sensor. Some Nixie clock implementations use a timer feature to turn the tubes off at night or other set intervals. This doesn’t seem entirely sensible to me – much better to use this $5 motion sensor, which works incredibly well. The clock also logs the last detected motion on its website, a feature which I find very useful for reasons that need not detain us here.

12 V 1 A power supply. The driver board shield is designed to take 12 V power from the Arduino Vin pin, so a 12 V supply is a must.

Miscellaneous consumables such as jumper wire, crimp connectors, grommets, heat shrink tubing, etc.

That might sound like a lot, but with a bit of careful shopping the whole lot (minus the enclosure) can be had for not much more than $150.

Tooled up

All you need to complete this project is a drill (ideally with a step bit), a soldering iron, a multimeter, and various hand tools. As with most projects, if you have more stuff, you will probably find a use for it. I drew upon many different resources for the coding side of things, primarily Google. Other search engines are available.

Step drill bits are great for making holes in thin material

I removed some of the B&K’s electronics and power supply to give me plenty of room to work. The hardest part by far (and even this wasn’t too difficult) was drilling the six holes for the Nixie tubes in the top of the case. Two additional, smaller, holes are also required for the digit-separating neons. Alignment of all these holes is obviously very important and this is the one time when not having the board pre-populated would help. I considered various ways to get the alignment right but in the end used the simplest method. After drawing a line across the case where I wanted the tubes, I turned the board and tube assembly upside down and marked where the tip of each tube met the line. I then centre-punched these marks, drilled pilot holes, and got to work with the step bit. 

This is not the first project where I wished I had a drill press, but it is certainly doable without.

The great advantage of the step bit approach is that it allows you to dispense with all that measuring malarkey and just keep going until the holes are the right size. That said, using digital calipers is a more convenient way to check the hole size as you go along.

Unless you have a machine shop, or are a lot handier than me, you will still end up with slightly misaligned holes. This is not really an issue since the holes need to be little bit bigger than the tubes (we will be applying around 180 volts of direct current to the tube pins, so contact with a metal case would not be good).

Oversizing the holes also provides space for including an insulating grommet where the tube pins pass through the case. Conveniently, the grommets will also hide minor misalignment issues. 

Although the driver board was designed to be an Arduino shield, I couldn’t install it like that for this project. For one thing, it couldn’t be stacked with the Ethernet shield. For another, I figured I might as well mount the Arduino and Ethernet shield so their external connections (power, USB, and Ethernet port) would be accessible from the rear of the case. This actually greatly simplified mounting of the driver board and tube assembly, which could be secured to the underside of the case with small nuts and bolts. 

Connections between the driver board and the Arduino (and the Arduino and Ethernet shield) would now be all by jumper wires, with the Arduino and Ethernet shield mounted separately to the bottom of the case.

With that taken care of, I needed to figure out where to put the LCD display and switches. The B&K enclosure had a rectangular cut-out in the front panel almost exactly the right height for the display. The cut-out was too long, but I solved that problem with a piece of black metal mesh removed from an old speaker.

The front panel also had nine square holes where various buttons had been located. Nine holes meant nine switches, to which I assigned the following names and functions:

DST Quick way to switch between DST (BST) and Standard Time (GMT). Depending on the time server being used, this may not be strictly necessary

12/24 Selects 12-hour or 24-hour display formats on the Nixie and LCD displays

Tweet If the clock has not tweeted that day, it will tweet immediately

Web Starts the clock’s web server (mainly for configuration and instructions

Tubes Off Turns off Nixie tubes

Red Turns off red LEDs

Green Turns off green LEDs

Blue Turns off blue LEDs

Edit Mode Puts clock in edit mode (effectively, this changes the operation of the rotary encoder so it can be used to change the future event being monitored)

Frankly, if there were fewer cut-outs, I could have dispensed with some of these or assigned them to the encoder. But their convenience means they do get used more, especially changing the LED backlight colours. 

Finally, I installed the rotary encoder, LCD dimming potentiometer, and motion detector in various other existing or newly created holes. 

Staying informed

You can see the code at hsmag.cc/nSTnRR. A not inconsiderable advantage of buying the GRA and AFCH driver board is that they offer some sample code to run a clock using the board. That said, since I needed to make some fairly significant modifications to this code, it was important to start with an understanding of how their code works.

Nixie tubes have ten elements, one for each digit, but only light one at a time

First, some basics. Nixie tubes work in a similar way to an array of ten LEDs with a common anode (at least, for a tube that can display the digits 0–9). Each LED represents one digit, so you can light any LED/digit by applying the requisite voltage to the anode, then grounding the cathode of the LED you want to display. In this arrangement, you can just connect each LED cathode to an Arduino pin (through a resistor, of course) and drive the appropriate pin low to turn on that LED. Since the Arduino keeps pretty good track of elapsed time, switching on each LED sequentially in one-second intervals is not much more complicated. Already we are well on the way to making a clock! To make a working Nixie-based clock, however, we still need to overcome three obstacles:

• Nixie tubes require around 180 V DC to light up; an Arduino cannot source or switch anything like that.

• A clock displaying hours, minutes, and seconds requires control of six tubes. If we persist with the approach above, we’ll need 60 pins just for switching the Nixies; even an Arduino Mega has only 54 I/O pins.

• While the Arduino keeps pretty good track of elapsed time, it doesn’t actually know what time it is.

Since we’ve already moved on to discussing the code, let’s just note that the driver board solves obstacle one by stepping up the 12 V from the Arduino’s Vin pin to the required voltage.

The second obstacle is overcome by a mixture of hardware and software. On the hardware side, the driver board has three shift registers, each with 20 high-voltage outputs. Connected in series, these registers can therefore do the necessary switching of all six tubes without multiplexing. 

On the software side, we need to tell the registers which of their pins to switch. This is done by converting the digits to display on the clock (held in the stringToDisplay variable) to a 64-bit variable, then sending that data via SPI in eight byte-sized chunks to the registers. This is handled by some clever bit manipulation in the doIndication function (courtesy of GRA and AFCH). 

Last, we can crack the third problem by using a library of time-related functions (TimeLib) and getting the current time from an internet time server.

Computers, microcontrollers, and the like establish what time it is by counting the number of seconds from a reference point, for example 1 January 1970. The TimeLib library helps deal with the tedious mental arithmetic needed to figure out what the time and date is if, for example, it is 1 516 365 708 seconds since the beginning of 1970. The code also uses the TimeLib library to calculate the time to the future event being monitored.

And that’s about it for the central task of displaying current time and time to the end of the Trump administration. 

The clock cycles through different ways of displaying the time left

Twittering

In addition to establishing a dedicated Twitter account, setting up the Twitter feature requires including an authorisation token in the code. While it would be easy to have the clock tweet at a fixed time each day, that would be very boring – the hours, minutes, and seconds to go would always be the same. So the code uses the randomSeed function to pick a particular second on each day to fire off the tweet. A bit of care is needed to make sure the tweet is grammatically correct whether the time units are singular, plural, or zero.

SERVER AND WEBSITE

The clock has an ‘external’ site created on and hosted by Squarespace. As part of the whole project, I wanted some decent-looking internet presence and this was a quick way to realise that. Of more interest to readers here, however, the clock also has its own internally hosted site. This provides a convenient place to include an instruction manual, a place to configure the future event name to be sent to the LCD, and a log of the motion detection. It also has a free widget that counts down the time to the end of the Trump administration from timeanddate.com. On one level, it’s a bit depressing that this information is so easily available after the not inconsiderable effort invested in building the clock. On the other hand, the widget is not a Nixie clock, and it does provide an independent time check. Unlike the Squarespace site, there’s nothing fancy about the ‘internal’ site, though I did use some Bootstrap templates to make it look halfway decent. The internal site (which can be made available over the internet using a free hostname and dynamic DNS address from no.ip.com) is only available when selected by the user. 

Quite a bit of code is used to manage the display and rotary encoder. This is fairly straightforward – take a look at the previous code link if you want to dive into the nitty-gritty.

With so many switches and other controls, some labelling was required. I’ve never figured out how to do this even halfway satisfactorily. For this project I ordered a couple of metal dog tags customised with the words I needed. Cut up and appropriately ‘distressed’, these went at least some ways to complementing the overall design.

While this build took quite a bit of time and effort, each part of it is fairly straightforward, and you could start with a simpler display. It can also be reused many times – there will always be some future joyous event to which you’ll want to count down.  

From HackSpace magazine store

Subscribe

Subscribe to our newsletter