# SMD Nixie Clock

By thernxt123 (Instructables, Featured / Contest Winner)

Background: I initially wanted to build something because I was looking for a project to do, and finally wanted to do a project with SMD components. The considerably smaller size of the SMD components would allow me to make smaller PCBs. I had built a word clock several years back, and thought that another clock would be fun. Nixie tubes also just look really nice.

## Step 1: Gather Materials

To build this clock, you will need the following:

Materials:

- 6x [IN-14](http://www.ebay.com/itm/Lot-of-6pcs-IN-14-NIXIE-TUBES-100-GARANTY-WORKING-IN14-/141770629073) Nixie Tubes
- 2x [IN-3](http://www.ebay.com/itm/10pcs-IN-3-NOS-NIXIE-TUBES-100-GARANTY-WORKING-IN3-INS-1-IN-14-IN-18-/141804242605) Nixie Indicator Bulbs (they come in a pack of 10)
- 1x [ATMega328P](http://www.mouser.com/ProductDetail/Atmel/ATMEGA328P-AU/?qs=sGAEpiMZZMvqv2n3s2xjscfa4zIkTHJIJIWLupw%252bFlg%3d) Microcontroller
- 2x [HV5622](http://www.mouser.com/ProductDetail/Microchip-Technology/HV5622PG-G/?qs=sGAEpiMZZMu4IE1U96nMDnWIO8wnmVQJdRAtv47kznw%3d) High Voltage Shift Register
- 1x 78L05 5 V Voltage Regulator
- 1x [DS3231](http://www.mouser.com/ProductDetail/Maxim-Integrated/DS3231SN/?qs=sGAEpiMZZMtpeOq%2f1QMb1dMUzmKwAGb51ObNWgZ7I10%3d) Real Time Clock
- 1x [CR2032](http://www.mouser.com/ProductDetail/Linx-Technologies/BAT-HLD-001/?qs=sGAEpiMZZMtT9MhkajLHrnz%2fFPUZSgO1koSsSyYdFD4%3d) Battery Holder and Battery
- 2x 4.7K Resistors
- 2x 120K Resistors
- 6x 27K Resistors
- 1x 10K Resistor
- 60x Machine-tooled Female Headers
- 1x Main PCB (see next step)
- 1x [High Voltage Power Supply](http://www.ebay.com/itm/Authorized-Dealer-NCH6100HV-High-Voltage-DC-Power-Supply-for-Nixie-Tubes-/182031863746)
- 3x Right Angle Push Buttons (I had some on hand; I didn't remember where I got them from.)
- 1x Barrel Jack Connector
- 1x 12 V Barrel Jack Power Supply
- Wires with female headers on the end
- 4x 4-40 Screws
- 4x 4-40 Nuts
- Some wood

Tools:

- Soldering Iron
- Flux
- Flush Cutters
- Needle-nose Pliers
- Isopropyl Alcohol
- AVRISP Programmer
- Saw, Router, Drill
- Optional: CNC Mill / Laser cutter / 3D Printer etc. (if you have access to one)

I ordered some of the electronics components from Mouser, and the rest I had on hand (can also be ordered from Mouser, Digikey, or your other favorite part distributor). The PCB was fabricated by OSHPark. The power supply board and Nixie tubes were from eBay.

## Step 2: Designing PCB

I had to learn how to use KiCAD because the free version of Eagle doesn't support boards larger than 4" x 3.2".

The circuit uses an ATmega328P for the brains, and two HV5622 high voltage shift registers provide the necessary control lines to independently control each tube's digits without multiplexing. A DS3231 RTC provides the accurate timing, and three buttons allow for user configuration. Several passives are used for pull-up resistors on the I2C lines, current-limiting resistors for the Nixie tubes, and filtering capacitors.

I designed this board to be the same width as the high voltage boost converter board so it will fit into a box nicely at the end. You can buy the PCBs from [OSHPark](https://oshpark.com/shared_projects/nlSfLdLr) (sold in batches of three). The KiCAD files are also available on GitHub and in the PCB.zip included with this lab. Feel free to modify them or use them to etch your own PCBs at home.

I didn't design the high voltage boost converter and ordered it from eBay. It will connect into the main PCB and supply it the necessary voltage for running the Nixie Tubes.

(I would recommend redoing the layout for this board, especially with regards to the high voltage sections, to ensure sufficient clearance between other wires.)

## Step 3: Soldering and Setting Up the HV Booster

Pay attention to which corner of the ICs have pin number one (denoted by a small circle), and line them up with the number "1" on the silkscreen. The DS3231 lines up with a notch.

Known PCB errata to fix when assembling:

- (0) Break open the socket pin rows and extract the actual metal pins — they make really good sockets for Nixie Tubes, allowing you to swap a tube out if one goes bad. The pins can be a tight fit in the holes.
- (1) The package outlines already in KiCAD didn't exactly match the components. The HV5622's had longer legs than normal; trim some of the leg to fit the footprint.
- (2) The digit-separating lamps (the small IN-3s) have a rear metal shield — switch the position of the current-limiting resistor and the tube to flip the tube's orientation. Pay close attention to the polarity of the small IN-3 tubes (arrow at the base pointing + to -).

The 10K resistor is the pull-up resistor for the reset pin by the ATMega328. The 4.7K resistors by the RTC are pull-ups for the I2C bus. The 120K resistors limit the current of the small IN-3 bulbs, and the remaining 27K resistors limit the current of the main numerical IN-14 Nixie tubes.

Before testing the circuitry, set up the high voltage boost converter. Run the tubes at the lowest voltage that still lights every digit completely — with the 27K resistor in parallel with the digit, slowly raise the voltage until each digit lights fully. You will need to set the voltage to around 160 V.

CAUTION: BE CAREFUL WHEN DEALING WITH HIGH VOLTAGES. The tubes run at roughly 160–170 V.

Use the right type of flux (electronics flux, not plumbing flux) and clean all flux residue off the board with isopropyl alcohol — residue caused erratic digit behavior at high voltage.

## Step 4: Cleaning Up and Connecting All Other Components

Straighten the vintage Nixie tube legs with needle-nose pliers so they all point downwards and are parallel, trim to equal length, and socket them. Be patient — you don't want a leg to break from repeated bending.

## Step 5: Programming

I programmed the clock in C in AVR Studio. The code is broken into three modules: initialization, button inputs/states, and clock state. A function called writeOut makes it easy to output whatever you want to the display — set a six-element array to the digits and pass it in.

Compile the code using AVR Studio, or from the command line with avr-gcc, and upload it using an AVRISP connected to the programming header in the middle of the clock. I used the Timer library and DS3231 library to get the code working quickly.

The clock has four functions: time (default), date, temperature (from the RTC's sensor, nearest quarter degree Celsius), and timer. Every minute in time mode the clock does a cycling animation to prevent cathode poisoning in the Nixie tubes.

The base code is available on GitHub: https://github.com/njeff/nixie-clock (also included with this lab as nixie-clock-code.zip).

## Step 6: Debugging

After the code is running, make sure all the functions work. You may want to adjust the voltage of the HV booster since all Nixie tubes are made slightly differently and some digits may not be fully lit.

## Steps 7–9: Case and Final Assembly

Make a case (wood, CNC, laser cutter, 3D printer — whatever you have). The main PCB is the same width as the power supply board so both fit in one enclosure. Remeasure the PCB before cutting pockets; mark and drill mounting holes for the power supply board and main board, holes for the three buttons, and a hole for the barrel jack. Mount the HV power supply and barrel jack first, then the main board, then fit the top cover around the tubes with screws for easy disassembly.
