Nixie clock

Nixie clocks are really beautiful pieces of equipment, but interfacing high voltage (250 VDC) obsolete components with 5 V microcontrollers is not an easy task. I came across many designs on the internet that use obsolete chips to solve this problem, but these chips are expensive and really hard to find. My design uses no obsolete components, except for the Nixie tubes, of course.

1

Main board

3

The main board is based on the Atmel ATMEGA328P-PU microcontroller. The code was written in Arduino IDE and an Arduino UNO was used for programming the microcontroller. The date and time are set using three buttons (Set, +, -). The clock also has a RTC ( DS3231 ) that keeps running when the clock loses power. It uses a supercapacitor that is charged while the clock is plugged in. (it works about a month without external power)

main_layout

Power supply

The power supply consists of a 9 VAC wall adapter, a small 12 V – 220 V transformer (used to step up), a rectifier bridge and filter capacitor for the anode voltage and another rectifier bridge, filter cap and 7805 regulator for the microcontroller, RTC and the driver.

Nixie driver

The data from the microcontroller comes as BCD (parallel). There are 4 wires that select which digit is to be displayed that go into a BCD decoder, then to the cathodes of the tubes through the cathode output stages that use one NPN transistor each. Since the tubes are multiplexed, all the corresponding cathodes are wired in parallel. The tubes are powered one at a time but because the refresh rate is high enough they look like they are permanently turned on. In order to select which tube is on I used the same principle as for the cathodes, but the output stages are different because the PNP transistors are on the hot side (250 V to the emitters). I used optocouplers to drive the PNP transistors.

nixie_layout

 

The code

Note : The microcontroller runs Arduino code although it does not have an Arduino bootloader on it. (the bootloader is not needed)
The code first checks if there is valid date and time data in the RTC. If data is found, the Time library gets the time from the RTC, then the clock starts running. If no data is found, the tubes display “00” and the user should set the time using the buttons. (time is set on both the microcontroller and the RTC, of course) The microcontroller also updates its time from the RTC once a day because it is less precise than the temperature compensated RTC.
Time is displayed by first turning on one of the NPN (cathode) transistor through the decoder. Then, the corresponding tube is powered for a short period of time by applying 250 V to its anode through the decoder and the anode output stage. Then the algorhythm moves to the next tube and so on and cycles through all tubes in order to make them appear turned on continuously. This is done because you cannot turn multiple tubes on while they’re multiplexed. (google multiplexing for more detail) Once every 20 seconds the time shifts left one digit at a time and then the date shifts in from the right and stays for a few second, then the clock displays time again.

You can post my designs anywhere else as long as you provide a link to the original source or metion me as the author.

The project files are available on my github account.

Contact : Stelian Saracut – stelian at saracut dot ro

Flappy chip (Arduino game)

Introduction

Flappy Chip is a small game running on the Arduino Uno
board (or standalone atmega328 microcontroller). The purpose of the game is to make the chip pass by as many tubes as you can without hitting them, by pressing the button which makes the chip climb (otherwise it falls). The score represents the number of tube pairs that have been avoided.

Hardware

The graphic LCD display that I used comes from an old Nokia 3310 cellphone. It is connected to the board using 5 resistive voltage deviders (one for each pin) which act as logic level converters. They are needed because the LCD driver works on 3.3 V whereas the microcontroller works on 5 V. The pins used for the display are digital pins 3 to 7 which have the following functions :

  • pin 3 – LCD reset (RST)
  • pin 4 – LCD chip select (CS)
  • pin 5 – Data/Command select (D/C)
  • pin 6 – Serial data out (DIN)
  • pin 7 – Serial clock out (SCLK)

The button is connected to pin 2, which is pulled up internally. When the button is pressed, it pulls the pin to the ground, which triggers an interrupt that changes the position of the chip.

 Software

Each graphic element was drawn in Paint, saved as a monochrome bitmap and converted to hex values using Image2Code. The bitmaps are stored in the Flash memory of the microcontroller. In order to put elements in front of the background, I had to make solid black bitmaps that are dislpayed negatively so that they clear the pixels of the background where the elements need to be displayed.(otherwise the front elements and the background mix) The whole graphic section is based on the Adafruit PCD8544 and GFX libraries, which makes it easy to use the Nokia display.

After displaying the startup image, the MCU waits for the user to press the button which starts the actual game. Then, the ISR that modifies the chip position is attached and the gameloop begins and runs as long as the chip ,,is alive”. Each time the gameloop is executed, the display is cleared, then the backround is displayed, followed by the chip. The maximum number of the tubes is 8 (4 pairs), since 4 sets of variables have been declared for this purpose. The game starts with one pair. The pairs are cycled in and out, gradually decreasing distance between the tubes and gradually adding more tubes until all four pairs are needed.  A series of if statements checks whether one of the tubes have gone offscreen and makes the corresponding variable false. Then if the rightmost tube is at the desired distance from the right margin of the screen, a new pair of tubes is reintroduced by reinitializing their corresponding variables. The vertical position is set at random. Another series of if statements moves the onscreen tubes to the left by one pixel. Afterwards, the tubes and the score are displayed. Then, the coordinates of the chip and the coordinates of the tubes are compared and in case of collision the alive variable is set to false and procedure dead is called which makes the chip fall. The chip is not allowed to hit the margins of the screen so if that happens it is considered ,,dead” as well. Finally, the score is incremented as each pair of tubes is avoided, the chip’s vertical position is incremented (so that it falls unless you press the button) and the delay keeps the game from running at lightning speed (or not really, with only 16 MHz clock speed). After the gameloop, the button interrupt is detached and the score is compared to the highscore (if there is one in the EEPROM). If there is no highscore, or your current score is higher than the highscore, a new higscore is written in the EEPROM so that it will not be lost when the MCU loses power. And just in case you become addicted to this game, you don’t have to worry about EEPROM wear out because a memory wear leveling algorithm writes the highscore at a different adress each time.

Download project files