Presentation

The Nixie Clock-o-Meter is pretty much what the name implies: it’s a clock, first and foremost, that uses Nixie tubes to display information. It’s also a thermometer, and a hygrometer. It comes with a couple bells and whistles as it is, and aims at being a cost effective design (save for the cost of the tubes themselves, of course). And oh, did I mention just how cool it looks? :)

closeup

Licensing

This project is licensed under a Creative Commons BY-NC-SA license.

Disclaimer

The information and methods described herein are provided “AS-IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED. Use the concepts, examples and information at your own risk. There may be errors and inaccuracies, that could be damaging to your devices. Proceed with caution, and although it is highly unlikely that accidents will happen because of following advice or procedures described in this document, the author does not take any responsibility for any damage claimed to be caused by doing so.

Design goals

My design goals were primarily geared toward feature-completeness and design efficiency:

  • KISS design
  • Powered from mains, with low overall power usage and high efficiency
  • Must provide time, date, temperature and humidity information
  • Must be easy to setup, and easy to tweak
  • Must use a reduced number of components
  • Must be reliable and safe
  • Should provide DCF77 synchronisation capability

In terms of power usage, the proposed design draws just about 1W when operating at full nixie brightness, and around 0.2W in standby mode. This makes it suitable for 24/7 operation.

Schematic

Here’s the schematic of the current design:

schematic

Schematic explanation

The brains of this design is a PIC16F882 (the schematic says 883 but the code actually fits a 882 when building in “Pro” mode). Around the PIC are several functional blocks: power (power source and power generation for the nixies), inputs (RTC clock, sensors), and outputs (nixie drivers). Let’s take a closer look.

Power

Power on this design is composed of two distinct parts (low and high voltage), all starting from the “input” power coming from mains, stepped down through a 230-9V transformer TR1 and rectified by the classic rectifier bridge B1. F1 is a 200mA slow-blow fuse whose purpose is to cut power in case “something goes wrong” down the circuit (typically if there’s a short due to component failure or miswiring). There’s no EMI filtering or fuse protection on the primary side of the transformer: these can be added as necessary “upstream”, e.g. inside the device casing, and I wasn’t aiming for any kind of EMI certification with this project :) C1, a low-ESR reservoir capacitor, provides the bulk of the ripple filtering for the rectified 9V DC feed.

Rectified power is then diverted toward two separate sections: the typical LM7805 voltage regulator (IC3) that provides a regulated +5V DC that feeds all the electronic devices of the design; and a boost converter built around IC5, a NE555 timer wired in astable mode, that provides the necessary voltage to drive the nixies.

The design of this boost converter is fairly straightforward, and amply described in this excellent article. My implementation features some minor differences I will explain here. The RC network formed by C13, R35, R38 gives an oscillation frequency of about 32kHz. That drives the gate of T14, a FQP11N40C MOSFET. I selected this particular transistor because of its extremely low Qg (28nC) (which reduces transition time), and its good RDS(on) (0.53Ω) and COSS (about 100pF at the target VDS). These characteristics dramatically reduce switching losses and thus improve the efficiency of the converter (see this article for an in-depth analysis of efficient switching PSU for nixies). C9 and R42 form a simple snubber network for T14: without it the instanteneous output spike voltage when L1 is switched off could exceed the avalanche breakdown voltage of the MOSFET.

Note: the NE555 MUST be of the bipolar variant, and not a CMOS implementation (such as the LMC555). CMOS versions cannot match the current drive capacity of the bipolar version (over 200mA), which is essential to ensure the MOSFET is firmly driven and doesn’t spend too much time in the transition region: this would generate high switching losses and make this device very hot.
I also recommend not socketing this IC: sockets introduce stray capacitances and can reduce the stability and efficiency of the converter.

T14 switches the inductor L1, chosen to be 220μH to reduce saturation effects and heat dissipation, based on an expected average current drain of around 10mA (a 100μH coil would probably work too). C16, a low-ESR capacitor, acts as a proximity reservoir for the inductor. D2 is a BYV26, an ultra-fast avalanche diode. The key characteristic of this element is the Reverse Recovery Time: it must be as fast as possible to reduce losses. The BYV26 is spec’d at 30ns. It’s worth mentioning that a “regular” rectifier diode (such as the 1N400X family) is absolutely not suitable. D2 delivers charge into C18, a high voltage, low-ESR reservoir capacitor, which is in turn further smoothed by C10.

The generated voltage is then applied to an adjustable voltage divider formed by R33, R34, R39. This divider is adjusted such that when the voltage at TP2 reaches the desired value, the voltage on the wiper of the trimmer is just enough to bias T13 on (current is set by R39 to be sufficient for driving the transistor’s base), which is connected to the NE555’s CV input: as it turns on, the voltage on that input drops, delaying the next pulse (this is pulse-position modulation). This negative feedback effectively stabilizes the voltage around the target value, with very good accuracy (to the extent permitted by the components’ temperature coefficient). Finally, the Reset input of the NE555 is connected to the PIC to make it possible to turn on/off the HV generator programatically. Note that the logic levels on that pin are 5V logic high (despite the NE555 operating from V+) and yet it still works. The internal schematic of the NE555 explains why: the Reset pin is connected to the base of PNP transistor whose emitter is standing approx 2 VCEsat above ground, so it can indeed be controlled without logic level adaptation.

One of the key reasons why I chose not to generate and control the switching frequency from the PIC itself is because it would have put additional burden on the PIC, and the voltage control would not have been as simple as this, especially when considering safety (left unchecked, a boost converter like this can produce much higher voltages). I also elected not to drive the nixies from mains for obvious safety reasons. As for choosing the NE555, it came down to two important points: first, it’s cheap. Second, it’s unlikely to ever go out of production :)

Note: it is essential that the resistors used here are all rated for 200+ V DC. Should R39 fail open, the negative feedback loop is broken and the voltage will be uncontrolable, likely blowing up C18 to boot. Properly rated resistors are very reliable, but the paranoid hacker can increase reliability by using two resistors of double the value in parallel.

Inputs

Let’s now take a look at the input sources. First, the 9V AC line is tapped and routed through R44, C15 and D3 and connected to the T0CKI input of the PIC. R44 and C15 form a low-pass filter with a cutoff of about 220Hz, to remove unwanted transients. R44 also sets the maximum current flowing at a few hundred μA, while D3, a zener diode, protects the PIC input pin: the T0CKI input is protected by a clamping diode to VSS but it doesn’t have a clamping diode on the positive side. This feeds in a level-adjusted 50Hz signal that is used as a time-base for TMR0.

The PIC is clocked via an 8 MHz crystal (Q1). I chose this frequency because I had a large stock of those, and because it gives an instruction clock frequency of 2 MHz, which is convenient for timing calculations in the PIC firmware. Next we have PH1, a photo-resistor which is used to sense ambient lighting. It is connected as a divider bridge (with R47) to the PIC AN1 analog input to be processed by the ADC.

Then comes the IS471F, a proximity sensor IC that relies on an infrared diode. It is a provision on the design to enable e.g. proximity turn on of the clock. Likewise, the DCF77 header is ready to accomodate a DCF77 transceiver. It is connected to the PIC’s RS232 RX pin since the transceivers output the DCF77 data in serial form. Two switches are also included to control and set the clock.

Finally, there is the “meat of the business”: the RTC clock (IC6) and the temperature and humidity sensor (IC7). Both are I2C devices: a PCF8523 from NXP for the clock, and a HIH8120 from Honeywell for the temperature/humidity combo. The RTC IC is feature-full, provides timers and alarms functions and can operate from battery backup power, with very low backup current drain. Backup power is provided by C14, a super capacitor. R43 prevents over-current when charging the capacitor, and D1 prevents the capacitor from feeding the rest of the design when power is removed. R45 and C20 ensure that the fall rate of the +5V input at pin 8 remains within the detecting circuitry’s spec. The HIH sensor is a convenient solution to collect environmental data in a digitized form. It sets the maximum speed on the I2C bus as it is the slowest of the two devices, with a top clock frequency of 400kHz.

Note: regarding D1, the proposed part in this design is a 1N4148, a very common small signal diode. However, these diodes have a fairly “high” reverse leakage (around 25nA getting worse with temperature and illumination conditions). I say “high” here because the PCF8523 has a backup current drain which is also in the nA range. Thus, for better backup battery life, a low leakage diode should be sought. A common option consists in using a 2N3904 with B and C connected together as the diode’s anode, and E as the cathode. In fact, even the MPSA42 in this configuration can perform better than a 1N4148.

Outputs

As further detailed in the next section, the design uses a multiplexing system to reduce component count, pin and power usage, and simplify routing. The PIC addresses each nixie tube individually and in turn, and lights the appropriate cathode as required.

IC1, a 74HC238 3-to-8 demultiplexer enables a mutually-exclusive selection while reducing pin usage at the PIC. It’s paired with IC2, a CD4028 BCD decoder that in turn drives the bases of the cathode driver transistors. This too greatly reduces pin usage at the PIC, while being also convenient as the data presented by the RTC clock is provided in BCD format. Finally, LED1 gives visual feedback about the current power state of the clock.

Nixies specifics

The nixies mode of operation is amply documented on the internet (this website and his author were especially helpful), so I will focus on the bits that are specific to this design. First, the 330kΩ are pulldown resistors that have been added to speed up the discharge of the anode drivers at turn off time (more on that below). They have a marginal impact on power usage (wasting about half a milliamp) but a tremendous one on turn-off recovery time (making it an order of magnitude faster).

The design multiplexes the nixies: the nixies’ anodes are isolated from the control logic via high-voltage opto couplers (TLP627), and the cathodes are connected to a single bus which is driven by a series of high VCEO NPN transistors (MPSA42). The anode driver section determines which nixie is struck at any one time, and the cathode drivers select which cathode of said nixie is lit.

The anode resistor values are calculated based on target high voltage drive value and the nixies’ dynamic current requirement (for multiplexed operation). The IN-18s are driven through a single limiting resistor (R13), which is made possible by the fact that no two nixies can be on at the same time (provided that turn-off time is accounted for). T11 and T12 drive the upper and lower dots of the colon separators, as well as the left and right comma of the IN-14s. The resistor values for the colons anodes (R1, R2, R3, R4) and the anodes (R6, R7, which are common to the colons and the commas) are a compromise to sastisfy the drive requirements of both the colons and the IN-14’s commas. The left colon being driven from the IN-18s’ section, it goes through one more resistor (R13) but that does not make it look signficantly dimmer than the right colon.

Note: as it turns out, using optocouplers for the anode drivers – while looking safer and more convenient on paper – turned out to be a suboptimal choice: I had greatly underestimated the switching time of these devices (which have Darlington outputs, and that clearly does not help switch-off time). It is especially bad at turn off because of the high VCE voltage involved and the very high impedance of the load: turn-off time typically exceeds 1.5ms, which has a very negative impact on the maximum refresh rate of the display multiplexing. The 330kΩ pulldown resistors help achieving this figure, which goes into the tens of milliseconds without them!
In my next design I will use transistors to drive the anodes as well as the cathodes.

Update: I have eventually created a small drop-in replacement for the optos, based on high-voltage MPSA42/92 transistors (in their SOT-23 variant: FMMTA42/92). It’s in fact a hackish retrofit for how the anode drivers should have been designed in the first place, but it works well. I provide the schematic as well as a working layout. The 100k and 470k resistors are type 0805, while the 33k is type 0603. Assembly is tedious but feasible. I have also updated the PIC firmware to accomodate both options (optos or transistors). I have replaced the TLP627s on my device with these retrofits.

Layout

Here’s a two-sided through-hole layout that fits on 25 x 10 cm PCB.

board

Comments

The layout is far from perfect, because its primary design goal was “aesthetics”. Very little consideration has been given to EMI: the ground plane is constrained in many places, return currents are all over the place.

The driving element was of course the nixies’ position. I wanted to have the high voltage part of the design as separate as possible from the low voltage control logic, and since this design is all about the nixies to begin with, it felt natural to have them at the front, the view uncluttered from any visual distraction.

Next, I wanted the upper side of the PCB to look nice and tidy as I didn’t really plan to hide it (there will either be no casing, or a transparent one). Combined with some further consideration (the photoresistor must not be exposed to device-generated light, the temperature sensor must not be picking up device heat, etc), and the general organization of the design in functional blocks, the layout ends up closely matching the schematic, with an emphasis on tidy component layout.

The temperature sensor is located on the underside of the PCB, like the photoresistor which is thus isolated and not too close to the switches so that a passing hand will not disturb it too much. The DCF77 connector is on the edge of the PCB for easy connection. High voltage generation is self-contained as as far as possible from the control logic. Component placement in that section focuses on electrical efficiency and safety (reducing the potentially dangerous area). The ground plane is interrupted under the coil to reduce induced current spikes. The cathode transistors are laid out in a nearly symmetrical “fan-out” fashion. No consideration has been given to homogeneity of component orientation: simplifying the layout was the priority there. There’s a small patch of copper around the horizontally-mounted 7805: the intent is to help with heat dissipation, although that really isn’t necessary.

NOTE ABOUT SAFETY:
While the device is isolated from mains via the transformer, and the high-voltage generator cannot put out much current, it still produces a high-enough voltage to give a jolt to anyone touching the wrong parts. Prudence is advised.

Software

Pic firmware

This design relies on a custom-designed firmware for the PIC. The firmware source is abundantly commented so I’ll keep this section short. The timekeeping is entirely left to the RTC clock. It is polled every second and the display is updated with the new value. The nixie multiplexing is handled by an interrupt routine that executes at 10kHz, while the cycling through the various display modes is also handled by an interrupt routine which is triggered every 20s.

The firmware features a “boot sequence” that is only executed at first power on. It serves no other purpose than to entertain the viewer, looking like the whole device is “warming up” before it can operate :) The firmware implements dimming control (by skipping up to 3 consecutive strike cycles). The interrupt routine is made unusually complex by the need to wait for the optocouplers to actually turn off (which is achieved by implementing a delay of 8 interrupt cycles between each nixie strike, resulting in a overall refresh rate of about 140Hz at full brightness). Cathode protection is provided by iterating through all cathodes (15ms each) every 10s.

The firmware uses the ambient light sensor to turn off the nixies in complete darkness (assuming nobody will be using the clock under those circumstances). The proximity sensor is currently unused as I didn’t take the time to find the ideal hardware setup for it. Full colons are blinked at 1Hz during time display and lower dots are static during date display. Once a full display sequence (time / date / temp / humidity) has been completed, the display is put to sleep for a minute before starting the next sequence. All of this is adjustable in the firmware source, and will eventually be adjustable on the running device.

A complete sequence from the power on time can be seen in the following video. Note that due to the multiplexing, the display looks dimmer on the video than it is to the naked eye:

The code path for the settings is orthogonal to the main() loop as none of “normal operation” routines are necessary nor desirable to execute during settings. DCF77 support is not yet implemented, neither are timer/alarm functions.

Note: the current firmware is mostly written in C (this sped up and eased the development process), and while it is “optimized” to work around some of XC8’s shortcomings (resulting in sometimes unusual constructs), it is suboptimal in many ways. That said, given Microchip’s compilers ludicrous bloating of the generated machine code (see this article for details; bottom line: Microchip should figure out they are not in the business of selling software), I will gradually move the code to hand-written assembly.

Firmware files

Here are the current MPLAB-X project files archive. This is tested and working, but not final. The code features a specific function, IN14tl(), which is a workaround for a buggy prototype PCB I used to develop the project: the IN14 pinout was wrong (by the look of things, top view and bottom view were confused by whoever made the “russian-nixies” CAD library, and I didn’t notice until it was too late). It will not be part of the final release.

Picture of a completed unit

Built from a slightly different prototype PCB.

top
front