Prototype Clock

Today I will describe how I built my prototype countdown clock, which counts down to the next SpaceX launch. It automatically updates itself using the Network Time Protocol (NTP) and a script running on my home server. This project will demonstrate how to use the panels and will provide a glimpse into the firmware libraries that are under development.

 Counting down to SpaceX DSCOVR launch attempt 1

Counting down to SpaceX DSCOVR launch attempt 1

 Interconnect on the prototype clock. Note that only one connection is made.

Interconnect on the prototype clock. Note that only one connection is made.

The hardware consists of the ten Rev 2 prototype displays, one Spark Core, and a breadboard power supply. I’ve connected the digits in pairs to make a colon for every other segment. I used the interconnects along the bottom only. It is important not to connect both top and bottom, which would connect the output of the downstream panels to the input of the panels upstream and cause the display to latch up.

The firmware is experimental, to put it kindly. I threw it together in a weekend, so it’s messy, but I will have time to rework the firmware into a nice library for Spark and Arduino while I wait for the Rev 3 panels. In the meantime, feel free to look at the firmware on Github.

The basic flow of the firmware is to constantly check for the time to advance by a second. It then recalculates the number of seconds until the target time will arrive, does calculations to get the minutes, hours, and days, and then updates the display. Please note that I used the Sparkfun Real Time Clock (RTC) library for Spark, which means that times are not in Unix time but are offset by 2208988800 seconds. This difference confused me for a while. The firmware also includes a function to update the target time. This function can be called at any point by a script on the Internet. I used a string instead of a number because the biggest number I could use was a signed integer, and I wanted to be sure I could represent more distant times if necessary.

The software is even less stable than the firmware. I used Python because I’m familiar with the language and because there are libraries to do everything I needed.  The script downloads the front page of spacexstats.com and then parses it to find the first time, which I assume is the next scheduled launch time. I used Beautiful Soup to do the parsing after referring to a few examples in the documentation. I also found a library to talk to the Spark Cores. To run the script, users will have to install these libraries. Once I had the script, I set up a cron job that runs the script once per minute.

There is much room for improvement in this design, but it was very fun building a working prototype so quickly. Please leave suggestions in the comments or make pull requests on Github.