A Project By Tianyu Liang and Guangyuan Li.
For this project, we designed all the circuits and the software by ourselves. For the power supply, we have to use two different power supplies. One is about 170V for the nixie tube, the other is 5V for the RPi. Theoretically, we can get 120*1.414=170V from standard voltage. So we will use a full bridge rectifier and a smooth circuit to get a 170VDC. For the 5V power, we will use an external power or a transformer (depends on the budget). Next problem is the control of the clock. To control the six nixie tubes, we need to control 6*10=60 pins using the RPi. To achieve this, we used at least eight 74HC595,the 8-bit parallel-out shift register. Also used transistors that can tolerate high voltages as switches to control the tubes and also use them to do the insulation work. We also want to add some back lights at the bottom of the tubes to make the clock look more fancy or use the lights to realize other functions. For the software part, we need to generate waveforms to drive the shift registers to control the number shown in the tubes. Also we need to make an interface that can let us change time and do other things.
Each Nixie tube requires 10 control pins and LED backlights require 4 control pins, which means we need 64 total control pins, which is outnumber the available GPIO pins provided by one RPi. We used 8 TI 74HC595 shift registers to solve this problem, and the package of one shift register is shown in Figure 1. U1 represents the first shift register unit and Pn_m represents the control signal to tube n pin m.
The function of the shift register here is to take in serial data from RPi and decode it to parallel data, which is used to control the tubes and the backlight.
The pins that need to be controlled by RPI are SER, RCLK, SRCLK and SRCLR, where RCLK, SRCLK and SRCLR are shared by all shift registers and each SER is controlled by one GPIO pin.
SER pin is the serial data input and QA to QH are parallel outputs.
SRCLK is the clock of the serial data. RCLK is used to control the output register. When there is a positive edge on the RCLK,
the output register will pop the converted data in the buffer to the output. SRCLR is used to clear the data we input to the buffer.
It is triggered when low. So we have to pull up this pin using a 10k resistor as shown in Figure 1.
The Output Enable pin is pulled down using a 10k resistor to make sure the output of the shift register will alway be enabled.
For the parallel data output pins, we also pulled down using 10k resistors to make sure the output is a logic zero when there is no signal output.
The correctness and functionality of shift register was simulated using FPGA before the PCB was sent for manufacturing, and the simulation timeline is shown in Figure 2.
We used FPGA to do the timeline test because it is much easier to program this in verilog. As shown in Figure 2,
the SRCLK(sclk) is always ticking. When the 8-bit data is transferred(we transferred 10100110), we pulled up the RCLK(rclk).
After a clock cycle, we pulled down the RCLK(rclk) and pulled down SRCLR(nCLR) to clear all the data in the buffer. After another clock cycle,
we pulled up SRCLR(nCLR) and one transfer is completed.
The nixie tube we used for our clock is IN2, and the schematic of the nixie tubes is shown in Figure 3
Each nixie tube has 11 pins, and 10 among them are cathode which light up each plate represeting the number in the tube, while
the remaind one is a cathode that finishe the circuit.
The anode of the nixie tube is connected to 170V through a resistor. The reason why we put a resistor here is that we can measure
the voltage drop between the resistor to get the current. So the value we used for the resistor is 1Ω. The cathode of the tubes are
connected to a header which will finally connect to the collector of a BJTs on the driver board.
We used BJTs to let the output pins of shift registers to drive nixie tubes. The only important spec when choosing BJTs here is that it should tolerate high collector voltage, so we chose MPSA42. Its collector-base voltage is 300V which is perfect for the nixie tube clock we built, and the schematic of BJT wiring is shown in Figure 4. We have six blocks in our circuit for the 60 cathode pins of the six tubes. Since there are 4 pins left, we used the remaining 4 pins to control the back lights of the clock.
The LEDs we used are dual color SMD LEDs, six BLUE-GREEN LEDs and six RED-YELLOW LEDs in total. We put one LED each under each nixie tube so that we will have four different colors and can combine these four colors to make new colors. Each LED is driven by two BJTs. To make layout less difficult, we used one BJT to drive three LEDs, so there are eight BJTs in the driving circuit of LEDs.
As shown in Figure 5, one LED control signal connects to six pins in six dual-color LEDs. A dual-color LED has two control pins and each color is controlled by one
pin. This means that we have four control signals, each controls one kind of back lights in all six nixie tubes.
We also added a header between the output of the shift register and the LED driving circuit.
The reason we did that is if we don’t want to use shift registers to control the LEDs for example making the leds breathing,
we can disconnect the headers and connect the control pin to other signal sources.
We directly draw voltage from the wall and use a full bridge rectifier and smoothing circuit to convert AC to DC. The circuit is shown in Figure 6.
Since we are dealing with high voltages, safety is very important. A fuse at the hot wire is necessary. Also we put all the circuits into a metal closure, which is connected to the earth and also wrapped by duct tape. Then we put the whole system into a plastic box to make a double insulation. After we finished the project, we realized that we needed to use a transformer at the power supply to insulate the whole circuit and the wall. Besides a transformer has intrinsic impedance, when there is a short circuit, it will limit the current to some extent. However, the capacitors will still have charge in them when the power is off, so the discharging of capacitors are also necessary. Since the impedance of the anode of the nixie tubes are very high, we parallel the whole system with two 51k resistors. The reason why we use two 51k resistors instead of one 100k is that we only have the 0.25w resistors. It is always important to calculate the power when choosing resistors for circuits using high voltages.
Figure 7 and 8 each shows the front and top vision of our nixie clock, it can be noticed that the PCB connects to each part of the clock locates in a box which is wrapped with duct tape, and the box is double insulated in a plastic container, which has an open hole allowing cable connection from the Rpi.
Driver Loading Function
There are several goals that we need to accomplish in the driver program. The first one is to program the timeline that we can output data to the shift registers. The code is shown in write_register function in the Code Appendix. We also pull up and pull down the GPIO pins according to the timeline shown in Figure 2.
The second thing we need to do in the driver program is that we need to map the pins. For example, we need to write a program to map what we want the nixie tubes to show to what data we should write to the registers. The functions are shown in load_to_serial_buffer function. And there is an array called data which contains all the data that we need to transfer for each number we want tubes to show.
For the user interface, we used the pygame library and the piTFT. We used event.get to detect each movement we made to the touch screen. There are six different interfaces in total: the main page, set current time page, set alarm clock page, stopwatch control page, number input page and LED manual control page. Each page is shown from Figure 9 to 14.
The main page allow user to navigate between different control interfaces. The set current time interface allow user to manually set current time
or automatically adjust time to local time on RPi, and the manual option will redirect to time input interface which allow user to input time and
change the display on the tubes. The alarm clock page will also allow user to manual input the one alarm clock time that will be stored locally and
an option to enable/disable the alarm. If the alarm is enabled, the "Enable alarm" pushbutton will light up as an indication, and back to normal if
disabled. In the stopwatch control panel, it allow user to start the stopwatch, pause it, resume and clear, which is the standard functionality of a
normal stopwatch. The backlight panel allow user to manually set the backlight on the tube to either one of the four color.
All functions we used in this project are attached in the Code Appendix.
Set Current Time Function
We defined an array in the program that contains the information of time(hour, minute, second), which increaments by 1 after each second. We outputed numbers according to the numbers stored in the array. So if we want to change the time displaying, we just need to change the value of the array. We programmed two ways for setting current time.
The first way is setting current time manually, which redirects to the time input page control panel, which stores the time inputed in the array corresponding to the user interaction on PiTFT. The other way is to update the time according to the local time of RPi. We wrote a function to read the local time from RPi using python datetime library and output the time to the array.
Set Alarm Function
We defined another array to store one alarm time. The alarm time is manually inputted using the similar method as we did in the set current time method. Also we defined a parameter to check the current time with the alarm from time to time, if the time matches, the backlights on the tubes will flash as the alarm. We also allow user to maunally set the alarm on or off, it the alarm clock is disabled, it will not alarm but the presetted time is still stored.
The stopwatch function will clear the tube numbers when it is called and we have the last two tubes represent represent tens of milliseconds instead of seconds for the stopwatch. Also the middle two tubes represent seconds and first two tubes represents minutes now. When the start pushbutton of stopwatch control panel is pressed, the tube numbers will start to increament and paused when the pause pushbutton is pressed. Then we can resume the counting by pressing the start again. If clear is pressed at any time, the tube numbers will be cleared and keep couting or paused depends on the previous state.
The overall schematic of both shift registers wiring and tube board wiring is shown below
The tests of our hardware system have been first simulated using FPGA before we build the PCB. Due the the complexity of the hardware wiring, it is
unlikely to build it on the protoboard, so we choose the PCB fabrication, and the final PCB board met exactly as our simualtion result.
The software tests of this project were perfomed on Raspberry Pi. We started by writing each function alone on seperate python file and have them functionality verified before combining to the main code file. Then we performed main code simulatiion on the nixie clock and have everything verified before the demonstration of this project.
The nixie tubes and the back lights work exactly as planned, and the functionality of our final code meet our expectation as well. This means that the overall design meets our plan. However, due to the lack of experience on projects with such high voltage, we made several small mistakes during the building and these will be solved in the future work. Overall, despite there are still some flaws in the final product, it is still an interesting clock that can be placed for decoration and it is a pleasing experience to build this clock.
There are several small mistakes that need to be modified. For the circuit with BJTs, we forgot to put a resistor at the base to limit the current.
Without this resistor, the shift register will not function well in extreme conditions such as the outputs are all 1. Besides, we misdrew the
package of the BJT, so we need to correct it in the future. We also need to use a transformer in the power supply because rectifying the voltage
directly is very dangerous.
One thing that we need to add in the future is that we will build a boost circuit so that we can just use a usb port to power the clock and it is much safer. Since RPi is powerful, we can explore what other functions can be realized on the six nixie tubes.
Designed the overall hardware architecture and hardware drive.
Designed the software functions and tested the overall system.
|Inductor 30mH||1||from the lab|
|IN-2 nixie tube||6||25|
|PCB(printed by JLC PCB)||2||10|
|Wires and connectors||N/A||from the lab|
|Raspberry Pi 3 model B||1||from the lab|
|piTFT||1||from the lab|
data.py, which contains data that we use for corresponding shift register value to tube number
main.py, main code that includes all function we used in our project