Wednesday, June 28, 2017

Cold Cathode Display Tubes - Nixies

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.

 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 problem 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.  It can also run straight into you.
So, after a little while of happy debugging - POOF!
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...

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
Then, put a MOV (Littelfuse V10H250P) and polyfuse on the transformer (Littelfuse 250R080Z), rectify the 230V for the high voltage supply (1N4004 or 1N4007 Diodes), use a 1 uF (Self healing film, 600V AC, Kemet PHE450PR7100JR02R06L2) capacitor to feed the low voltage supply (BZX85C5V6 zener diode) and crucially, ground the secondary for safety of life, limb and test equipment.

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 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: 
 



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.  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 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 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.  The wattage of the resistor should be 200 V x 2mA = 0.4 W, so use a 1 W or 2 W resistor to avoid burning a fingertip if you would touch it.

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.

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!




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, 600V AC, Kemet PHE450PR7100JR02R06L2.

It is not necessary to backup the Nixie supply - they will simply glow again once the mains power comes back, so a 9V 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!


- .. -- . / .. ... / --- -. / --- ..- .-. / ... .. -.. .

Have fun, but be safe!

Herman

No comments:

Post a Comment

On topic comments are welcome. Junk will be deleted.