Home‎ > ‎

NTP Synced Nixie Tube Clock

posted Jun 4, 2009, 1:38 PM by Evan Blair Quirk   [ updated Jun 5, 2009, 4:02 PM ]

A clock constructed using vintage nixie display tubes that is able to fetch the current time from the internet via NTP.

Nixie tubes are gas filled display tubes that were popular in early electronic devices. They have a single anode, and a number of cathodes which are connected to the numerals contained in the tube. When a high voltage source is connected to the anode and one of the cathodes is grounded, the corresponding numeral is surrounded by an orange glow. They are currently popular among electronics hobbyists because of their unique looks.

NTP, the Network Time Protocol, is a protocol for computers and other networked devices to negotiate with a server to retrieve the current UTC time.

Finished clock


Videos:

Clock Digit Crossfading, New Date Display


Clock Starting


Clock in 24 Hour Mode, Old Display Date Feature


Clock Cathode Poisoning Prevention


Design Considerations:

Constructing a clock using nixie tubes is nothing new. It has been done countless times, to the point where it is almost considered a rite of passage for an amateurs in electronics. I was interested in building a nixie clock, but I wanted to do something different, something you couldn't find in a kit. Eventually I decided on building a nixie clock that would be able to fetch the time automatically. I decided to do this via NTP. This led to the development of several design considerations:

Hardware and Software Components:

By deciding to use NTP for time synchronization, I decided that software would be a significant design aspect. The software would have to have knowledge of TCP/IP protocols, mainly UDP for NTP synchronization. The software would also have to convert the UTC time into format suitable for output. Hardware would have to include all components needed for display as well as those for network communication. Having both hardware and software components would also help me to learn as much as I could from the project.

Open Source:

Because of the rapidly increasing scale of this project I decided I would use existing open source code and design wherever possible. In addition, all code would be released under an open source license so that others could learn from and extend it.

Hardware Simplicity:

Wherever possible, I would attempt to make my circuit board as simple as possible. This was primarily because this project would be my first attempt at working with and producing my own circuit boards. As such, I would be making a single sided circuit board with all through hole components. In addition, in any case possible, software simplicity was to be sacrificed for hardware simplicity. I didn't want to have a board full of jumpers. Traces on the circuit board would be placed where they fit, and any undesirable connections would be fixed in software.

Modularity:

As my first electronics design project, I was guaranteed to have problems on this project. I would build each major section of the hardware separate. This way, if there was an error on one of the boards I wouldn't have to remake all of them.

Design:

Hardware:

Tuxgraphics NTP Clock:

While researching I found an NTP synced clock on tuxgraphics.org. It turned out to be a perfect base for my clock, and the entire project was open source. It utilized an Atmel ATMEGA168 microcontroller to communicate over SPI to an ENC28J60 ethernet chip. I would be able to reuse the network code and just write a new display component suitable for driving the nixies.

Overall Design:

ENC28J60 and Support Hardware:

Ethernet Schematic

The configuration for the ENC28J60 is fairly standard, as per the tuxgraphics configuration. The ENC28J60 requires a 3.3V Vcc so both the microcontroller and it share a 3.3V supply. Communication with the microcontroller is done over the four pin SPI interface. The ENC28J60 is also linked to the INT0 pin of the microcontroller for external interupts. Additionally, the ENC28J60 provides the clock for the ATMEGA168. The ENC28J60 is clocked at 25mhz and an internal frequency divider divides it into a 12.5mhz clock. This is slightly out of spec for the ATMEGA168 as it is specified to be capable of 0-10MHz @ 2.7-4.5V and 0-20MHz @ 4.5-5.5V. However, in practice there seems to be no problems with running at this slightly higher clock. A "Magjack" is used to supply the required magnetics and leds in a form integrated into an ethernet jack. The microcontroller and ethernet support hardware occupy one of the three major circuit boards

Nixie Tubes:

I decided on IN-14 nixie tubes, manufactured in the former Soviet Union. They were chosen for their medium size and affordable price at approximately $3 + shipping per tube. A translated datasheet indicated that they required a 170 volt power supply and comsumed 2.5mA of current. I would use a total of six tubes, two for hours, two for minutes, and two for seconds. I decided to order a professionally made circuit board from nixieclocks.de to mount the nixie tubes on as I was not sure how fine a level of detail I would be able to achieve by making my own. This is the second major board.

High Voltage Power Supply:

High Voltage Power Supply Schematic

I based my HV power supply off a common design for a switch-mode boost converter. It is constructed around a 555 configurable oscillator. Switch-mode power supplies are notoriously difficult to implement and as such I borrowed the circuit design from a kit sold from ledsales.com.au. Fully explaining the operating principles of switch-mode power supplies is outside the scope of this project, but wikipedia has an informative article on the subject.The high voltage power supply occupies the last major circuit board along with the anode control hardware described in the next section.

Nixie Tube Control Hardware:

Although the microcontroller is responsible for controlling the six nixie tubes in my project, it cannot directly interface with them. It operates at 3.3V and the nixie tubes require a voltage of 170V. As such, an intermediary would be required between the microcontroller and the tubes to direct the flow of high voltage. The most common configuration is an intermediary controller on the cathodes, either through discrete components (transistors, resistors) or via the 74141 IC. This is known as a direct drive display. In my case, I would be using controllers on both the anode and cathodes. This configuration is used to facilitate a process called multiplexing. In a multiplexed display, the tubes are never actually all on at the same time. Instead, they are lit up in rapid succession. This happens at a frequency higher then the refresh rate of the human eye so the display simply appears to be continuous. Multiplexing is advantageous because it extends a tube's lifespan and requires less pins then a direct drive configuration. The multiplex configuration I chose is called a 2x3 multiplex. This means that two tubes are on at a time and that there are three sets of two tubes.

I decided to use the 74141 IC for controlling the nixie tube cathodes. The 74141 is a BCD (binary coded decimal) decoder. This means that it takes a nibble (half a byte or four bits) as input, decodes its binary equivalent, and switches the corresponding cathode connection to ground. For my 2x3 multiplex I would need two 74141 ICs, one for each of the two tubes that would be on at the same time. The cathodes of the six tubes are split into two groups, with each groups cathodes being commonly connected. Anodes from each group is paired such that when one anode pair is connected to high voltage, one tube from each cathode group will be controlled by a 74141.

When it came time to do board layout, I ran across a slight problem laying traces for the 74141 ICs. The nixie tube board cathode connections were in sequential order while the 74141 ICs cathode connections were scrambled. Rather then run a bunch of jumpers to order the 74141 connections I decided to connect them where they made sense. I would do output adjustments in software. For example, if I wanted to display a 0, I would have to send the 74141 a binary 2.

Anode Control Hardware

Switching the anode pair was to be done with discrete components as there is no 74141 equivalent for controlling high voltage anode connections. Instead PNP and NPN high voltage transistors would control the flow from the 170V high voltage power supply. The shown 22k resistor is reduced from the usual 33k resistor used in other designs because the microcontroller supply is 3.3V instead of the typical 5V.

Schematic:

Schematic

Software

Keeping Time:

Keeping track of time is a relatively simple matter. In this case, it is kept in a 32-bit variable in unix time. Unix time means that the variable describes the number of seconds enlapsed from midnight UTC on January 1, 1970. We'll only be syncing our time variable with an NTP server every hour, so we still need to increment the time variable locally. This is done by generating a timer interrupt every second, during which the time variable is incremented.

Main Function Design:

Despite being simplified, the following pseudo-code main function closely follows the actual flow of the nixie clock software.

main() {
initialize();
while(1) {
recieve_packet();
if no packet {
if time not set { request_ntp(); }
time_conversions();
display( hourh, minl , anode_pair_1 );
display( hourl, sech , anode_pair_2 );
display( minh, secl , anode_pair_3 );
if minutes = 59 { request_ntp(); }
}
else { interpret_packet(); }
}
}

Code Explaination:

The first pseudo-function, initialize(); , contains a number of operations that essentially initialize the clock. First, the microprocessor's clock source is set to the ENC28J60. Over SPI the ENC28J60 is instructed to increase its clock output to 12.5mhz. Next, stored options are read from an eeprom. Then the ethernet layer is started. Finally the pins for the anode and cathode controls are configured as outputs.

While(1) { essentially means loop forever. This means that any code contained here will be looped as long as the clock is on.

In this second pseudo-function, recieve_packet(); , the microcontroller asks the ENC28J60 for any packets that it has recieved. If there is no new packet, a routine is executed, which we'll focus on in a moment. In the case that there is a new packet, another pseudo-function, interpret_packet(); , is executed. There are two main possibilities for the nature of this packet. Either it can be a packet containing new configuration options, or it can contain an NTP response from a server. If it contains new configuration options, the new options are written to the eeprom, the new options are loaded into memory, the time variable resets and the clock requests a new NTP packet. If the packet contains an NTP response from a server it is converted into unix time and then stored in the time variable.

Backtracking, if there is a no packet received, a series of actions happen. First, the clock checks to make sure that time is set. If it is not, the clock requests a new NTP packet. Next a pseudo-function called time_conversions(); is called. time_conversions(); converts unix time into a readable time in the configured timezone. It separates each of the six digits to be displayed. The six digits of the clock are mapped to variables from left to right. ( hourh, hourl, minh, minl, sech, secl ) Following this, the display(); function is called three times, one time for each anode pair. The display function maps the input, which is what we want to appear on the tubes, to the adjusted output values. By sending these adjusted output values to the 74141 IC we fix the incorrect cathode connections to the nixie tubes. Finally the software checks to see if it is 59 minutes after the hour. If it is, the microcontroller requests a resyncronization with the NTP server.

The end effect of this code is that because there is rarely a recieved packet, the display code is looped endlessly. This is responsible for the multiplexing effect and gives the illusion of a continuous display.

Configuration:

Configuration of the nixie clock is handled through a web browser. There are three configuration pages: http://(clockip)/config, http://(clockip)/options, and http://(clockip)/timing. The config page handles network configuration such as clock ip and timeserver ip. The options page is responsible for display options such as 12/24 hour time, and blank lead zero.The timing page configures the multiplex delay (tweak to eliminate ghosting) and the powersave mode.

Config:

Options:

Timing:

Single Board Version:

Taking advantage of the lessons I learned constructing my original nixie clock, I recently finished construction of a single board version. Technically it uses two boards, one to hold the nixie tubes and one with all control logic. However, I only needed to produce the control board as the tube holder board was purchased. The two boards are coupled via pin header and spacers.

Pictures:

Board Layout:

Both board bottom and top are availible in PDF format under the attachments section.

Partslist:

Resistors:

4x      50ohm
3x 270ohm
4x 10k
3x 22k
3x 470k
1x 2.7k
3x 100k
1x 1k
1x 56k
1x 470ohm
1x 220k
1x 2.2k
1x 1k trimpot

Capacitors:

1x      330uF (pol)
4x 10nF
2x 18pF
2x 10uF (pol)
1x 2.2nF
1x 100pF
1x 2.2uF, 250V (pol)

ICs:

1x      ATMEGA168
1x ENC28J60
1x 3.3V Regulator
1x 5V Regulator
1x 555 Timer
2x 74141

Others:

3x      MPSA 92
3x MPSA 42
1x IRF740
1x UF4004
1x BC547
1x MagJack
1x 4.7uH Inductor
1x 100uH Inductor
1x 25mhz Crystal
Ċ
bottom.pdf
(173k)
Evan Blair Quirk,
Jun 4, 2009, 2:09 PM
ċ
ntpnixieclockh1.tar.gz
(35k)
Evan Blair Quirk,
Jun 4, 2009, 2:10 PM
Ċ
Evan Blair Quirk,
Jun 4, 2009, 2:13 PM
Ċ
top.pdf
(127k)
Evan Blair Quirk,
Jun 4, 2009, 2:09 PM
Comments