A hobby
project needs to be simple, so that I can sit down, stare at the
circuit for a few seconds and carry on without having to read a manual
and consult six data sheets, because then it feels like work.
Consequently, I found that thermionic valves make ideal hobby toys,
since the circuitry necessarily has to be simple. One can use a double handful of ICs and transistors in a hair brained design, but with tubes, two or three are the
practical limit and this forces one to think carefully about what one wants to do and keep it elegant.
Here is my olde skool guitar amplifier: http://www.aeronetworks.ca/2015/02/cool-amplifier.html It works a treat.
There is nothing quite like the mystical glow of a Nixie Tube. The Nixie is a special kind of neon lamp. The Neon glows in space surrounding the almost invisibly thin cathode wires. The wire itself is cold - it is the gas around it that glows and the glowing area is much wider than the wires.
A Nixie has something in common with our star, the Sun. The sun's atmosphere is mostly made of glowing Neon above a surface crust of ferrite. We cannot see the ferrite surface through all the glowing Neon - similar to a glowing Nixie, where the thin wires mysteriously disappear inside the glow.
Here is my olde skool guitar amplifier: http://www.aeronetworks.ca/2015/02/cool-amplifier.html It works a treat.
A Nixie has something in common with our star, the Sun. The sun's atmosphere is mostly made of glowing Neon above a surface crust of ferrite. We cannot see the ferrite surface through all the glowing Neon - similar to a glowing Nixie, where the thin wires mysteriously disappear inside the glow.
Four Nixie Tubes with 10 Cathode Drivers
Nixies have lately become very popular amongst bored, or retired ex-hippies and their younger unemployed hipster children. There is even now a factory for brand new super huge Nixie tubes in an old castle at Brno in the Czech Republic: http://www.daliborfarny.com/r-z568m-nixie-tube/
Controlling and powering a Nixie is not hard, but it requires high voltages and nowadays all electronics use very low voltages. This causes a safety problem, as designers try to cut corners to reduce the cost of the resulting complexity.
Safety First
The web is awash with simple Nixie supply schematics that rectify the mains directly for the high voltage supply and use series capacitors to provide a low voltage supply for the silicon logic. The argument is that since a Nixie needs a dangerous high voltage anyway, one can just as well hook it directly to the mains and since you are doing that, you can generate the low voltage the same way through a buck regulator series capacitor.
The problems with that argument is many fold:
- The mains wiring is not guaranteed to be correct and many power plugs can be inserted any which way, so there is no certainty that a particular supply wire is Live or Neutral. It can be either way around.
- The mains supply is dirty. Mains power consists of 115 or 230 Volt 50 or 60 Hz sine wave, plus a couple thousand volts of high frequency noise. This noise will pass straight through a capacitor.
- Without an isolation transformer, the high frequency 2 kilovolt noise spikes will run into your Arduino or Raspberry computer that you use to control your Nixie tubes. It will run into your expensive Oscilloscope that you use to develop the electronics and it will run into your laptop computer that you use to debug the Arduino or Raspberry and if your laptop computer is on your lap, then it can also run straight into you.
For the cost of a replacement oscilloscope or laptop computer, you could buy a lifetime supply of little mains isolation transformers and if you don't, then your lifetime may not be very long...
A direct rectified supply is only good if the circuit is extremely simple and there is nothing else connected to it, ever. It must be self contained in a closed box.
Power Consumption, Transformers and Fuses
Nixies do not draw much power, typically 2.5 mA @ 125 V = 0.312 Watt for a large one.
A little Arduino also does not draw much either. A Teensie 2.0 dissipates 27.3 mA 16 MHz 5V = 0.136 Watt. More modern ones draw half as much.Therefore a widget with four tubes and one Arduino will consume 1.4 Watt or less.
You can get a tiny mains isolation transformer at Digikey or Mouser, for example the Triad Magnetics F-367P:
- Power: 1.5 VA
- Size: 34.93mm x 28.58mm x 28.58mm
- Price: $10.32
The MOV and transformer will absorb the high voltage spikes and will ensure that your circuit will run happily for many years, without needing repairs after every thunder storm and the polyfuse will help ensure that your bad soldering will not burn your house down...
Nixie Data Sheet
The common IN8-2 looks like this:Computer I/O Control
You can control the Nixies using DIP opto-couplers such as the Toshiba TLP627-4F, or you can use MPSA42 (for the cathodes) and MPSA92 (for the anodes) transistors - or use an opto-isolator, more costly, but simpler:
A few high voltage DIP opto-isolator packages can be more compact, but a double handful of transistors and 10k resistors can be much more fun to wire up. The trannies are also a little cheaper, but with this ridiculously expensive hobby, cost is not really an issue - if it is, then you got to find something else to do!
Nixie Anode Voltage, Metal Sputter and Resistors
If you start with 115 V rms AC and rectify it, you supposedly get a high voltage supply of 162 Volt DC. However, the actual mains voltage is usually about 120 V rms and rectifies to 120 V x 1.414 = 170 V DC, which is equal to the strike voltage of a Nixie tube, so a tube can usually work off a 115 V rms mains supply, but sometimes it won't, leaving you scratching your beard. This is why most 115 V supplies use a voltage doubler to ensure that there is sufficient tension to reliably strike the lamps.
Once lit, the resulting Neon plasma has a lower resistance and the Nixie Anode needs 125 Volt to sustain the glow and the current should then be limited to about 2 mA, to keep the electron energy to a reasonable level, otherwise metal atoms can be knocked out of the Anode, causing them to sputter on the inside of the glass, making the tube dark. The manufacturer recommended maximum current rating for a Nixie tube is about 3.5 to 4 mA.
Therefore, a 230 V Anode supply is better and it rectifies to 230 V x 1.414 = 325 V DC (I have measured 350V DC). At that voltage, the Nixie will definitely strike. Note that you don't need to put a capacitor on the Anode supply: The Nixie will happily strike and glow on each half cycle (100 Hz), which is too fast for the eye to see, so it will look like a continuous glow.
If the DC is smoothed with a capacitor, then the current limiting resistor should be (325V - 125V) / 2 mA = 100 kilohm, but if you don't use a capacitor, then you would need to use about 38 k to 47 k to get a decent average glow from a rectified unsmoothed sine wave, but then you may get some sputter and reduced Nixie life from the peak current. High voltage capacitors (600V to 1000V and a MOV are needed to survive spikes) are expensive and bulky - so it is your call whether you want to buy a capacitor, or a cup of Starbucks coffee.
Note that common garden variety 1/4 W resistors are rated at 100 V, so the Nixie Anode resistor which will drop 200 V, should be made from two resistors in series, or it may eventually carbonize and smoke - 1/2 Watt resistors are rated at 200V. The wattage of the resistor should be 200 V x 2 mA = 0.4 W, so use a 1 W or 2 W resistor to avoid burning a fingertip if you would touch it - a blister on a finger tip is very sore...
If you find that multiple anodes light up at the same time - ghosting - put a pull-up resistor to the anode on the offending cathodes. A 1 M resistor may work - some happy experimenting may be required. With neon bulbs, nothing is exact, or entirely predictable, due to wide manufacturing tolerances and the old age of the devices.
The battery needs to be a higher voltage than the logic supply for the regulator to work, but it also needs to be a lower voltage than the supply, else it will power the circuit until it is run down. To handle this conundrum, regulate the 230 V AC from the isolation transformer secondary down to 12 V DC, put a 9 V battery with a blocking diode, then regulate that down to 5 V.
Errata: I have to upload a new PSU sketch. The high voltage supply needs to be half wave rectified with a 470nF capacitor for a little smoothing, to be able to use a common ground with the low voltage supply. So put a cap after the 1N4004!
Due to the high voltage, the 1M resistor should be made from two 470k resistors in series. The buck capacitor should be Self Healing Film (Type X or X2), 600V AC, Kemet PHE450PR7100JR02R06L2, or a Ballast Self Extinguishing Capacitor, so you don't burn your house down.
It is not necessary to backup the Nixie supply - they will simply glow again once the mains power comes back, so a 9 V alkaline battery will be good for a year.
// Teensie 2 - Nixie Clock Controller
// Copyright reserved under GPL version 2, Herman Oosthuysen, 2017
// Includes for interrupt routine handlers
// https://www.pjrc.com/teensy/interrupts.html
#include <avr/io.h>
#include <avr/interrupt.h>
// Teensie 2.0 Nixie Clock Pinout
// USB: Serial Port, ppogram and test
// Power: Gnd, +5V (next to USB socket)
// Pin 0: CATHODE1, output
// Pin 1: CATHODE2, output
// Pin 2: CATHODE3, output
// Pin 3: CATHODE4, output
// Pin 4, PWM: CATHODE5, output
// Pin 5, PWM, INT0: PWM Time Base, output, 976.56 Hz
// Pin 6, INT1: INT1 Time Base, input
// Pin 7, RX, INT2: CATHODE6, output
// Pin 8, TX, INT3: CATHODE7, output
// Pin 9, PWM: CATHODE8, output
// Pin 10, PWM: CATHODE9, output
// Pin 11, A10: CATHODE0, output
// Pin 12, A9, PWM: ANODE1, output
// Pin 13, A8: ANODE2, output
// Pin 14, A7, PWM: ANODE3, output
// Pin 15, A6, PWM: ANODE4, output
// Pin 16, A5: HOURS, input
// Pin 17, A4: MINUTES, input
// Pin 18, A3: ENTER, input
// Pin 19, A2: NC
// Pin 20, A1: NC
// Pin 21, A0: NC
// Pin 22: LED Seconds, output
// Pin 23: SPEAKER (Via 330R, 100UF)
// https://www.pjrc.com/teensy/td_digital.html
// https://www.pjrc.com/teensy/tutorial4.html
// Example: digitalWrite(LED, LOW); // LED on
// Example: digitalWrite(LED, HIGH); // LED off
// Example: val = analogRead(HOURS);
#define CATHODE1 0
#define CATHODE2 1
#define CATHODE3 2
#define CATHODE4 3
#define CATHODE5 4
#define CLOCK 5
#define INTERRUPT1 6
#define CATHODE6 7
#define CATHODE7 8
#define CATHODE8 9
#define CATHODE9 10
#define CATHODE0 11
#define ANODE1 12
#define ANODE2 13
#define ANODE3 14
#define ANODE4 15
#define HOURS 16
#define MINUTES 17
#define ENTER 18
#define NC1 19
#define NC2 20
#define NC3 21
#define LED 22
#define SPEAKER 23
unsigned int cathodes[10] =
{CATHODE0, CATHODE1, CATHODE2, CATHODE3, CATHODE4, CATHODE5,
CATHODE6, CATHODE7, CATHODE8, CATHODE9};
unsigned int anodes[4] =
{ANODE1, ANODE2, ANODE3, ANODE4};
// PWM is used as a time base for the clock:
// https://www.pjrc.com/teensy/td_pulse.html
// PWM pins: 4, 5, 9, 10, 12, 14, 15
// PWM is controlled with the analogWrite(pin, value) function.
// analogWrite(5, 128);
// The value is between 0 to 256, 128 is 50% duty cycle.
// The PWM signals are created by hardware timers:
// Timer 0: Pin 5 = 976.56 Hz (1024 us)
// Timer 1: Pin 4, 14, 15 = 3921.57 Hz
// Timer 3: Pin 9 = 3921.57 Hz
// Timer 4: Pin 10, 12 = 3921.57 Hz
// Timer 0, Pin 5 is the slowest, use it for the Time Base
// and link it to Pin 6 INT1, next to it.
#define TIMEBASE 1024
// Interrupt Inputs:
// INT0: Pin 5
// INT1: Pin 6
// INT2: Pin 7
// INT3: Pin 8
// Speaker:
// Beep the speaker with the tone function.
// https://www.pjrc.com/teensy/td_pulse.html
// tone(pin number, frequency in Hz, duration in ms);
#define BEEP 440
#define SHORT 250
#define LONG 1000
// Example: tone(SPEAKER, BEEP, SHORT);
// USB Serial Port:
// https://www.pjrc.com/teensy/td_uart.html
#define BAUD 9600
// Variables
unsigned int hours = 0;
unsigned int minutes = 0;
unsigned int seconds = 0;
unsigned int deciseconds = 0;
unsigned int microseconds = 0;
// Initialization:
void setup()
{
// Configure the USB serial port
Serial.begin(BAUD); // The USB port is 12 Mbit/sec
// All digital pins default to input mode.
// Set the mode of all output pins
pinMode(CLOCK, OUTPUT);
pinMode(SPEAKER, OUTPUT);
pinMode(LED, OUTPUT);
pinMode(CATHODE1, OUTPUT);
pinMode(CATHODE2, OUTPUT);
pinMode(CATHODE3, OUTPUT);
pinMode(CATHODE4, OUTPUT);
pinMode(CATHODE5, OUTPUT);
pinMode(CATHODE6, OUTPUT);
pinMode(CATHODE7, OUTPUT);
pinMode(CATHODE8, OUTPUT);
pinMode(CATHODE9, OUTPUT);
pinMode(CATHODE0, OUTPUT);
pinMode(ANODE1, OUTPUT);
pinMode(ANODE2, OUTPUT);
pinMode(ANODE3, OUTPUT);
pinMode(ANODE4, OUTPUT);
// Set all Nixie outputs off
digitalWrite(ANODE1, LOW);
digitalWrite(ANODE2, LOW);
digitalWrite(ANODE3, LOW);
digitalWrite(ANODE4, LOW);
digitalWrite(CATHODE1, LOW);
digitalWrite(CATHODE1, LOW);
digitalWrite(CATHODE1, LOW);
digitalWrite(CATHODE1, LOW);
digitalWrite(CATHODE1, LOW);
digitalWrite(CATHODE1, LOW);
digitalWrite(CATHODE1, LOW);
digitalWrite(CATHODE1, LOW);
digitalWrite(CATHODE1, LOW);
digitalWrite(CATHODE1, LOW);
// Set the clock PWM time base
analogWrite(CLOCK, 128);
// Print startup message on USB to computer screen
Serial.println("Nixie Clock, GPL v2, Herman, 2017.");
delay(LONG);
tone(SPEAKER, BEEP, SHORT);
}
// Flash each digit at 50 Hz refresh rate
// Each digit is on for about 5 ms and off for about 15 ms
#define FLASH 5
unsigned int a = 0;
unsigned int digits[4];
// Main program loop
void loop()
{
// Recalculate the digits
digits[0] = minutes / 10;
digits[1] = minutes - digits[0];
digits[2] = hours / 10;
digits[3] = hours - digits[2];
// Refresh the display
for (a = 0; a < 4; a++)
{
digitalWrite(anodes[a], HIGH);
digitalWrite(cathodes[digits[a]];
delay(FLASH);
digitalWrite(anodes[a], LOW);
}
}
// Clock Control Interrupt Routine
// https://www.pjrc.com/teensy/interrupts.html
// Interrupt period is 1024 us
ISR(INT1_vect)
{
microseconds += TIMEBASE;
if (microseconds >= 9999)
{
// 1/10 second
deciseconds += 1;
microseconds -= 10000
if (deciseconds >= 99)
{
// second
seconds += 1;
deciseconds = 0;
if (seconds >= 59)
{
// minute
minutes += 1;
seconds = 0;
if (minutes >= 59)
{
// hour
hours += 1;
minutes = 0;
if (hours >= 23)
{
hours = 0;
}
}
}
// Once a second, flash the LED
digitalWrite(LED, LOW); // LED on
}
if (deciseconds >= 2)
{
// 200 ms flash
digitalWrite(LED, HIGH); // LED off
}
}
}
This project, when controlled by an Arduino Teensie, is about as simple and low cost as I can make it. With a little bit of additional programming, one can make the thing display the time, ring an alarm, roll the numbers, scroll, flash and go crazy every once in a while, just to break the monotony.
What I thought of recently, is to make a Grandfather Clock:
It runs fast in the morning, slow in the afternoon, nods off unexpectedly and when you disturb it (with a light sensor), it blinks and catches up quickly...
I'll wait for someone else to code that up!
Also see this for more neon fun: https://www.aeronetworks.ca/2019/09/olde-skool-blinken-lights.html
- .. -- . / .. ... / --- -. / --- ..- .-. / ... .. -.. .
Once lit, the resulting Neon plasma has a lower resistance and the Nixie Anode needs 125 Volt to sustain the glow and the current should then be limited to about 2 mA, to keep the electron energy to a reasonable level, otherwise metal atoms can be knocked out of the Anode, causing them to sputter on the inside of the glass, making the tube dark. The manufacturer recommended maximum current rating for a Nixie tube is about 3.5 to 4 mA.
Therefore, a 230 V Anode supply is better and it rectifies to 230 V x 1.414 = 325 V DC (I have measured 350V DC). At that voltage, the Nixie will definitely strike. Note that you don't need to put a capacitor on the Anode supply: The Nixie will happily strike and glow on each half cycle (100 Hz), which is too fast for the eye to see, so it will look like a continuous glow.
If the DC is smoothed with a capacitor, then the current limiting resistor should be (325V - 125V) / 2 mA = 100 kilohm, but if you don't use a capacitor, then you would need to use about 38 k to 47 k to get a decent average glow from a rectified unsmoothed sine wave, but then you may get some sputter and reduced Nixie life from the peak current. High voltage capacitors (600V to 1000V and a MOV are needed to survive spikes) are expensive and bulky - so it is your call whether you want to buy a capacitor, or a cup of Starbucks coffee.
Note that common garden variety 1/4 W resistors are rated at 100 V, so the Nixie Anode resistor which will drop 200 V, should be made from two resistors in series, or it may eventually carbonize and smoke - 1/2 Watt resistors are rated at 200V. The wattage of the resistor should be 200 V x 2 mA = 0.4 W, so use a 1 W or 2 W resistor to avoid burning a fingertip if you would touch it - a blister on a finger tip is very sore...
If you find that multiple anodes light up at the same time - ghosting - put a pull-up resistor to the anode on the offending cathodes. A 1 M resistor may work - some happy experimenting may be required. With neon bulbs, nothing is exact, or entirely predictable, due to wide manufacturing tolerances and the old age of the devices.
Clock PSU With Battery Backup
If you are building a hoosammawatzit with a little processor to control the Nixies, then you will find that the slightest power interruption will cause the thing to lose the time of day and resetting it every few days will get annoying in no time.The battery needs to be a higher voltage than the logic supply for the regulator to work, but it also needs to be a lower voltage than the supply, else it will power the circuit until it is run down. To handle this conundrum, regulate the 230 V AC from the isolation transformer secondary down to 12 V DC, put a 9 V battery with a blocking diode, then regulate that down to 5 V.
Errata: I have to upload a new PSU sketch. The high voltage supply needs to be half wave rectified with a 470nF capacitor for a little smoothing, to be able to use a common ground with the low voltage supply. So put a cap after the 1N4004!
Due to the high voltage, the 1M resistor should be made from two 470k resistors in series. The buck capacitor should be Self Healing Film (Type X or X2), 600V AC, Kemet PHE450PR7100JR02R06L2, or a Ballast Self Extinguishing Capacitor, so you don't burn your house down.
It is not necessary to backup the Nixie supply - they will simply glow again once the mains power comes back, so a 9 V alkaline battery will be good for a year.
Arduino Teensie2 Clock Sketch
Here is a basic clock control routine that should get you started. You'll have to tweak the TIMEBASE to get it reasonably accurate, but don't expect high precision from a 4 MHz garden variety crystal!// Teensie 2 - Nixie Clock Controller
// Copyright reserved under GPL version 2, Herman Oosthuysen, 2017
// Includes for interrupt routine handlers
// https://www.pjrc.com/teensy/interrupts.html
#include <avr/io.h>
#include <avr/interrupt.h>
// Teensie 2.0 Nixie Clock Pinout
// USB: Serial Port, ppogram and test
// Power: Gnd, +5V (next to USB socket)
// Pin 0: CATHODE1, output
// Pin 1: CATHODE2, output
// Pin 2: CATHODE3, output
// Pin 3: CATHODE4, output
// Pin 4, PWM: CATHODE5, output
// Pin 5, PWM, INT0: PWM Time Base, output, 976.56 Hz
// Pin 6, INT1: INT1 Time Base, input
// Pin 7, RX, INT2: CATHODE6, output
// Pin 8, TX, INT3: CATHODE7, output
// Pin 9, PWM: CATHODE8, output
// Pin 10, PWM: CATHODE9, output
// Pin 11, A10: CATHODE0, output
// Pin 12, A9, PWM: ANODE1, output
// Pin 13, A8: ANODE2, output
// Pin 14, A7, PWM: ANODE3, output
// Pin 15, A6, PWM: ANODE4, output
// Pin 16, A5: HOURS, input
// Pin 17, A4: MINUTES, input
// Pin 18, A3: ENTER, input
// Pin 19, A2: NC
// Pin 20, A1: NC
// Pin 21, A0: NC
// Pin 22: LED Seconds, output
// Pin 23: SPEAKER (Via 330R, 100UF)
// https://www.pjrc.com/teensy/td_digital.html
// https://www.pjrc.com/teensy/tutorial4.html
// Example: digitalWrite(LED, LOW); // LED on
// Example: digitalWrite(LED, HIGH); // LED off
// Example: val = analogRead(HOURS);
#define CATHODE1 0
#define CATHODE2 1
#define CATHODE3 2
#define CATHODE4 3
#define CATHODE5 4
#define CLOCK 5
#define INTERRUPT1 6
#define CATHODE6 7
#define CATHODE7 8
#define CATHODE8 9
#define CATHODE9 10
#define CATHODE0 11
#define ANODE1 12
#define ANODE2 13
#define ANODE3 14
#define ANODE4 15
#define HOURS 16
#define MINUTES 17
#define ENTER 18
#define NC1 19
#define NC2 20
#define NC3 21
#define LED 22
#define SPEAKER 23
unsigned int cathodes[10] =
{CATHODE0, CATHODE1, CATHODE2, CATHODE3, CATHODE4, CATHODE5,
CATHODE6, CATHODE7, CATHODE8, CATHODE9};
unsigned int anodes[4] =
{ANODE1, ANODE2, ANODE3, ANODE4};
// PWM is used as a time base for the clock:
// https://www.pjrc.com/teensy/td_pulse.html
// PWM pins: 4, 5, 9, 10, 12, 14, 15
// PWM is controlled with the analogWrite(pin, value) function.
// analogWrite(5, 128);
// The value is between 0 to 256, 128 is 50% duty cycle.
// The PWM signals are created by hardware timers:
// Timer 0: Pin 5 = 976.56 Hz (1024 us)
// Timer 1: Pin 4, 14, 15 = 3921.57 Hz
// Timer 3: Pin 9 = 3921.57 Hz
// Timer 4: Pin 10, 12 = 3921.57 Hz
// Timer 0, Pin 5 is the slowest, use it for the Time Base
// and link it to Pin 6 INT1, next to it.
#define TIMEBASE 1024
// Interrupt Inputs:
// INT0: Pin 5
// INT1: Pin 6
// INT2: Pin 7
// INT3: Pin 8
// Speaker:
// Beep the speaker with the tone function.
// https://www.pjrc.com/teensy/td_pulse.html
// tone(pin number, frequency in Hz, duration in ms);
#define BEEP 440
#define SHORT 250
#define LONG 1000
// Example: tone(SPEAKER, BEEP, SHORT);
// USB Serial Port:
// https://www.pjrc.com/teensy/td_uart.html
#define BAUD 9600
// Variables
unsigned int hours = 0;
unsigned int minutes = 0;
unsigned int seconds = 0;
unsigned int deciseconds = 0;
unsigned int microseconds = 0;
// Initialization:
void setup()
{
// Configure the USB serial port
Serial.begin(BAUD); // The USB port is 12 Mbit/sec
// All digital pins default to input mode.
// Set the mode of all output pins
pinMode(CLOCK, OUTPUT);
pinMode(SPEAKER, OUTPUT);
pinMode(LED, OUTPUT);
pinMode(CATHODE1, OUTPUT);
pinMode(CATHODE2, OUTPUT);
pinMode(CATHODE3, OUTPUT);
pinMode(CATHODE4, OUTPUT);
pinMode(CATHODE5, OUTPUT);
pinMode(CATHODE6, OUTPUT);
pinMode(CATHODE7, OUTPUT);
pinMode(CATHODE8, OUTPUT);
pinMode(CATHODE9, OUTPUT);
pinMode(CATHODE0, OUTPUT);
pinMode(ANODE1, OUTPUT);
pinMode(ANODE2, OUTPUT);
pinMode(ANODE3, OUTPUT);
pinMode(ANODE4, OUTPUT);
// Set all Nixie outputs off
digitalWrite(ANODE1, LOW);
digitalWrite(ANODE2, LOW);
digitalWrite(ANODE3, LOW);
digitalWrite(ANODE4, LOW);
digitalWrite(CATHODE1, LOW);
digitalWrite(CATHODE1, LOW);
digitalWrite(CATHODE1, LOW);
digitalWrite(CATHODE1, LOW);
digitalWrite(CATHODE1, LOW);
digitalWrite(CATHODE1, LOW);
digitalWrite(CATHODE1, LOW);
digitalWrite(CATHODE1, LOW);
digitalWrite(CATHODE1, LOW);
digitalWrite(CATHODE1, LOW);
// Set the clock PWM time base
analogWrite(CLOCK, 128);
// Print startup message on USB to computer screen
Serial.println("Nixie Clock, GPL v2, Herman, 2017.");
delay(LONG);
tone(SPEAKER, BEEP, SHORT);
}
// Flash each digit at 50 Hz refresh rate
// Each digit is on for about 5 ms and off for about 15 ms
#define FLASH 5
unsigned int a = 0;
unsigned int digits[4];
// Main program loop
void loop()
{
// Recalculate the digits
digits[0] = minutes / 10;
digits[1] = minutes - digits[0];
digits[2] = hours / 10;
digits[3] = hours - digits[2];
// Refresh the display
for (a = 0; a < 4; a++)
{
digitalWrite(anodes[a], HIGH);
digitalWrite(cathodes[digits[a]];
delay(FLASH);
digitalWrite(anodes[a], LOW);
}
}
// Clock Control Interrupt Routine
// https://www.pjrc.com/teensy/interrupts.html
// Interrupt period is 1024 us
ISR(INT1_vect)
{
microseconds += TIMEBASE;
if (microseconds >= 9999)
{
// 1/10 second
deciseconds += 1;
microseconds -= 10000
if (deciseconds >= 99)
{
// second
seconds += 1;
deciseconds = 0;
if (seconds >= 59)
{
// minute
minutes += 1;
seconds = 0;
if (minutes >= 59)
{
// hour
hours += 1;
minutes = 0;
if (hours >= 23)
{
hours = 0;
}
}
}
// Once a second, flash the LED
digitalWrite(LED, LOW); // LED on
}
if (deciseconds >= 2)
{
// 200 ms flash
digitalWrite(LED, HIGH); // LED off
}
}
}
This project, when controlled by an Arduino Teensie, is about as simple and low cost as I can make it. With a little bit of additional programming, one can make the thing display the time, ring an alarm, roll the numbers, scroll, flash and go crazy every once in a while, just to break the monotony.
What I thought of recently, is to make a Grandfather Clock:
It runs fast in the morning, slow in the afternoon, nods off unexpectedly and when you disturb it (with a light sensor), it blinks and catches up quickly...
I'll wait for someone else to code that up!
Also see this for more neon fun: https://www.aeronetworks.ca/2019/09/olde-skool-blinken-lights.html
- .. -- . / .. ... / --- -. / --- ..- .-. / ... .. -.. .
Have fun, but be safe!
Herman
ReplyDeleteWOW just what I was looking for. Came here by searching for %keyword% craigslist des moines