Author Topic: Nixie Tube Clock Project  (Read 9955 times)

0 Members and 1 Guest are viewing this topic.

Offline PotatoBoxTopic starter

  • Regular Contributor
  • *
  • Posts: 129
  • Country: ca
Nixie Tube Clock Project
« on: December 12, 2016, 04:18:55 am »
Hi,

I've been interested in nixie tubes for quite a while and I think they look really nice. I've decided to make a nixie tube clock with IN 14 tubes or IN 12 (still deciding on which one I should use).

Now, I looked onto ebay for some 74141 IC's to drive the tubes and they are pretty cheap.

I want to use an Arduino for this project and I've got an idea on how I should program it. Since I will need to count to binary to 9, I've had an idea for the code. So we would have 4 digital pins set to outputs. In the loop, it would start at all the pins are low (binary number 0) then a delay of 1000 milliseconds then it would switch pin 1 as high and all the other pins to low (binary number 1) then a delay of 1000 milliseconds and so on and so forth until we reach binary number 9 at which it starts over again. We would fed the 4 digital pins of the arduino into the inputs of the 74141.

Would this be accurate enough for a clock?


 

Offline PotatoBoxTopic starter

  • Regular Contributor
  • *
  • Posts: 129
  • Country: ca
Re: Nixie Tube Clock Project
« Reply #1 on: December 12, 2016, 04:55:13 am »
No, it would not be accurate enough for a clock. You have several options. One would be to count pulses from a crystal oscilator or derived from the mains supply if you aren't afraid of mains voltages. At each pulse an interupt routine would count the pulses and at a certain value (ie one second) update the time and display it. If you don't use an interupt routine to track the time you will have to tweak the software loop very carefully to ensure every path through it is a known fixed length so that it always takes the same time to go around once. Can be done but very fiddly. If you make a change somewhere you will need to adjust every other path through the code as well to be the same length. Packing the code NO-OPs is one way and then add or delete them as needed.

A second way is to use a battery driven real time clock module (RTC) to keep time and just read the current time from it for regular display each second.

Then there are more esoteric ways like a GPS module or an internet time server.

Personally I would go with the RTC module method.

Have a look at this link https://learn.adafruit.com/adafruit-ds3231-precision-rtc-breakout/overview


Could I use a 32.768 kHz crystal and divide that down to 1 hertz with a 4060 and a 4027 flip flop?
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12852
Re: Nixie Tube Clock Project
« Reply #2 on: December 12, 2016, 11:43:43 am »
Arduinos tend to use a crappy ceramic resonator instead of a 16MHz crystal, so their millis() timer tick is not an accurate millisecond.  It is possible to calibrate out a lot of the error, but ceramic resonators have poor temperature and long term stability so no matter how well your code gilds the turd, you will do well to get the error down to a few seconds a day. 

One timekeeping reference that hasn't been mentioned yet is your national grid mains frequency.  In 1st world countries the grid frequency is tightly controlled so that even though the frequency is permitted to vary with total grid load within a certain tolerance, the total number of cycles per day is far more tightly controlled so that mechanical mains synchronous timers or clocks are accurate over periods >>24H.  If you take an AC output wallwart, and rectify and smooth it to power your circuit, you can tap the AC from before the bridge rectifier via a resistor, low pass filter it, clamp it with a 4.7V Zener and feed it to a comparator to get an approximately squarewave reference signal at the lline frequency suitable for feeding to your MCU.   Its best used to repeatedly calibrate your system clock over a 24H period, midnight to midnight to compensate for drift in the system's primary oscillator. 
 

Offline PotatoBoxTopic starter

  • Regular Contributor
  • *
  • Posts: 129
  • Country: ca
Re: Nixie Tube Clock Project
« Reply #3 on: December 12, 2016, 12:20:36 pm »
Well, I had thought of using logic chips instead of an arduino. I was going to use a 4017 decade counter but the problem is, it counts in decimals not binary so the 74141 wouldn't work with it.

Is there any IC to get around this problem if I were to use logic chips instead of an arduino?
 

Offline klunkerbus

  • Supporter
  • ****
  • Posts: 162
  • Country: us
  • Electrical Engineer (retired early)
Re: Nixie Tube Clock Project
« Reply #4 on: December 12, 2016, 12:36:50 pm »
I second Wilfred's suggestion on using an RTC module, and specifically agree with the DS3231.  The built-in temperature compensation goes a long ways to eliminating drift.  I have three projects running that use an earlier DS3231 board from Adafruit (the Chronodot) for a time source. The longest has been running for a few years.  If the time has drifted, it hasn't drifted by much.

Back in my discrete chip logic design days, I tried the power line frequency as reference source approach.  Even with filtering, power line noise spikes caused that clock to run fast, noticeable on a daily basis.  Futzed with the filtering some, but never did resolve it.
 

Offline PotatoBoxTopic starter

  • Regular Contributor
  • *
  • Posts: 129
  • Country: ca
Re: Nixie Tube Clock Project
« Reply #5 on: December 12, 2016, 12:45:30 pm »
Ok, Ill use the RTC.
 

Offline CJay

  • Super Contributor
  • ***
  • Posts: 4136
  • Country: gb
Re: Nixie Tube Clock Project
« Reply #6 on: December 12, 2016, 02:29:08 pm »
Arduinos tend to use a crappy ceramic resonator instead of a 16MHz crystal

Interesting, I'm not sure if the cheap clone ones I have use a crystal or a ceramic clock source, I'd just assumed it was a crystal, not that it will make a great difference to me as I only really use them as a quick bodge solution (a particularly tasteless and gaudy Illuminated Christmas squirrel with WS2812 LEDs because nothing conveys the spirit of Christmas better than an epileptic fit inducing 12" tall acrylic squirrel. Except perhaps a pole dancing reindeer).

For the OP:

I'd recommend using something like the Dallas RTC chips with I2C but beware, because the device is powered by the battery, if you switch off power during a read or write the RTC can become unresponsive when you power you main circuit back up.

When you power it on again you need to complete the unfinished read/write, the way I did it was to perform a 'reset' sequence, basically send it half a dozen clock pulses followed by a stop condition and then it will respond when you start talking to it in a meaningful way.
 

Offline Cliff Matthews

  • Supporter
  • ****
  • Posts: 1910
  • Country: ca
    • General Repair and Support
Re: Nixie Tube Clock Project
« Reply #7 on: December 12, 2016, 03:33:50 pm »
Ok, Ill use the RTC.
The QTouch library has "external synchronization" to cut 50/60 Hz interference.. one wonders if inductively a simple piece of wire (like a 70's clock radio) would be enough? http://www.atmel.com/Images/doc8207.pdf
 

Offline PotatoBoxTopic starter

  • Regular Contributor
  • *
  • Posts: 129
  • Country: ca
Re: Nixie Tube Clock Project
« Reply #8 on: December 12, 2016, 08:44:44 pm »
The RTC is all nice and dandy, but the libraries for it that I see have lots of code that is useless for this project. All I need this thing to do is to track the seconds. So the code that specifies the day of the week, the month etc, is of no use.

So, for the code, could I use an if statement for each second. For example, I would have if seconds is equal to 0, then pin 1,2,3 and 4 are low. Then the next if statement would be if seconds equal to 1, then pin 1,2,3, are low but pin 4 is high. and so on and so forth. Will this work without causing a lot of delay? or is there a better way to do this?
 

Offline CJay

  • Super Contributor
  • ***
  • Posts: 4136
  • Country: gb
Re: Nixie Tube Clock Project
« Reply #9 on: December 12, 2016, 09:11:22 pm »
So, don't use thelibrary, but configure the RTC to output a pulse per second and sync from that.

I guess it depends how accurate you want it to be but if you're concerned about accuracy then some stable source of PPS would be a good place to strt if you insist on emulating hardware with software.
 

Offline PotatoBoxTopic starter

  • Regular Contributor
  • *
  • Posts: 129
  • Country: ca
Re: Nixie Tube Clock Project
« Reply #10 on: December 12, 2016, 09:25:37 pm »
So, don't use thelibrary, but configure the RTC to output a pulse per second and sync from that.

I guess it depends how accurate you want it to be but if you're concerned about accuracy then some stable source of PPS would be a good place to strt if you insist on emulating hardware with software.

Emulating? Im not emulation anything. I still want to use the RTC chip.
 

Offline Paul Moir

  • Frequent Contributor
  • **
  • Posts: 926
  • Country: ca
Re: Nixie Tube Clock Project
« Reply #11 on: December 12, 2016, 10:25:03 pm »
You'll probably want to directly access the RTC so you can use it's battery backup.  You'll loose this function if you count seconds from it.

Setting the output:

 n = seconds_from_RTC;
 select_nixie_tube(0);
PORTA = 1 << (n % 10);    // Use with individual segment drivers
PORTA = (n % 10);              // Use with 74141
 sleep(A_FEW_MILLISECONDS);
 select_nixie_tube(1);       
PORTA = 1 << (n / 10);    // Use with individual segment drivers
 PORTA = n / 10;     // Use with 74141
 sleep(A_FEW_MILLISECONDS);
...

(Or, if you're looking at a bunch of IF statements, you may want to use a CASE statement)

One last push for the GPS time:  you don't necessarily need to build much of an interface to set the time with this.  :)
     
« Last Edit: December 12, 2016, 10:29:33 pm by Paul Moir »
 

Offline CJay

  • Super Contributor
  • ***
  • Posts: 4136
  • Country: gb
Re: Nixie Tube Clock Project
« Reply #12 on: December 12, 2016, 10:37:16 pm »
Well it appears you want to just use the seconds from the RTC and do the rest in software so it does seem you're giving up a lot of functional hardware only to replace if with subroutines...

The RTC is seriously easy to use, it outputs BCD which, once you've stripped out the unwanted data, you could, if you wanted, output directly to the 74141 as they're a BCD to decimal converter.

The only functons you need to implement then is time setting.

It even takes care of AM/PM if you want it to.
 

Offline PotatoBoxTopic starter

  • Regular Contributor
  • *
  • Posts: 129
  • Country: ca
Re: Nixie Tube Clock Project
« Reply #13 on: December 12, 2016, 10:44:38 pm »
Well it appears you want to just use the seconds from the RTC and do the rest in software so it does seem you're giving up a lot of functional hardware only to replace if with subroutines...

The RTC is seriously easy to use, it outputs BCD which, once you've stripped out the unwanted data, you could, if you wanted, output directly to the 74141 as they're a BCD to decimal converter.

The only functons you need to implement then is time setting.

It even takes care of AM/PM if you want it to.

Alright, how would I be able to output the BCD to the 74141?

Another thing, I had just realized it but there is no carry out pin on the 74141 so I cannot daisy chain them. So I'd need to connect each 74141 directly to the microcontroller... which will require 24 digital I/O pins which the arduino does not have...

Is there another microcontroller I could use that will be good for this?
« Last Edit: December 12, 2016, 10:56:09 pm by PotatoBox »
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12852
Re: Nixie Tube Clock Project
« Reply #14 on: December 12, 2016, 11:35:31 pm »
An Arduino Mega would have enough I/Os or use three 74HC595 shift registers as a 24 line output expander.
 

Offline PotatoBoxTopic starter

  • Regular Contributor
  • *
  • Posts: 129
  • Country: ca
Re: Nixie Tube Clock Project
« Reply #15 on: December 13, 2016, 04:14:13 am »
An Arduino Mega would have enough I/Os or use three 74HC595 shift registers as a 24 line output expander.

I will try with the shift register. But with the 74595, I will need 8 clock pulses before it has 8 bits of data loaded. Now, won't I have to run the shift registers of a faster clock pulse (8 hertz?) so that the registers will be loaded before the clock pulse goes to the 74141 and carries the data from the register to the 74141?

So 8 hertz since 1 hertz is equal to one pulse a second and we need to load 8 bits of data before the 1 second has elapsed and triggering the pulse. Right?
« Last Edit: December 13, 2016, 04:17:05 am by PotatoBox »
 

Offline EEVblog

  • Administrator
  • *****
  • Posts: 37728
  • Country: au
    • EEVblog
Re: Nixie Tube Clock Project
« Reply #16 on: December 13, 2016, 06:57:45 am »
Back in my discrete chip logic design days, I tried the power line frequency as reference source approach.  Even with filtering, power line noise spikes caused that clock to run fast, noticeable on a daily basis.  Futzed with the filtering some, but never did resolve it.

Could have been the hot water modulation causing it? (if you have that in the US)
My mains derived clock was the most accurate clock I ever owned.
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12852
Re: Nixie Tube Clock Project
« Reply #17 on: December 13, 2016, 08:02:42 am »
... or use three 74HC595 shift registers as a 24 line output expander.
I will try with the shift register. But with the 74595, I will need 8 clock pulses before it has 8 bits of data loaded. Now, won't I have to run the shift registers of a faster clock pulse (8 hertz?) so that the registers will be loaded before the clock pulse goes to the 74141 and carries the data from the register to the 74141?

So 8 hertz since 1 hertz is equal to one pulse a second and we need to load 8 bits of data before the 1 second has elapsed and triggering the pulse. Right?
You need to update the shift registers a lot faster than that as there are 24 bits of data to be loaded.  Its almost certainly easiest to simply use SPI.transfer() to send three bytes at the default Arduino 4MHz SCLK.  Even with the overheads of loading the next byte to be transferred, that should only take a few tens of us.  The rest of the time is occupied running any 'housekeeping' tasks, and waiting for the next 1Hz clock pulse.
 

Offline CJay

  • Super Contributor
  • ***
  • Posts: 4136
  • Country: gb
Re: Nixie Tube Clock Project
« Reply #18 on: December 13, 2016, 10:10:38 am »
Either shift registers (74HC595) to 74141 or decode to decimal in software and use the TPIC6B595 as Dave is considering/decided in his Nixie videos (coincidentally I found the same chip while browsing Mike's Electric Stuff website and was about to order a tube to play with)
 

Offline PotatoBoxTopic starter

  • Regular Contributor
  • *
  • Posts: 129
  • Country: ca
Re: Nixie Tube Clock Project
« Reply #19 on: December 13, 2016, 10:22:30 pm »
Could I use the shiftout command with this?
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12852
Re: Nixie Tube Clock Project
« Reply #20 on: December 13, 2016, 10:35:27 pm »
Yes, but its considerably slower than the hardware SPI, although, with only three bytes to update that isn't really a problem.

One approach that might simplify your code would be to  ignore the RTC 1 PPS signal, and just read the RTC and update the daisychained  '595 shift registers in the Arduino loop() function, followed by delay(50);
That would update the display approximately 20 times a second, w2ith the actual values only chaging when the RTC seconds increments.  The 50ms timing jitter between the RTC second update and the display update will be unnoticeable to a human eye.
 
The following users thanked this post: PotatoBox

Offline PotatoBoxTopic starter

  • Regular Contributor
  • *
  • Posts: 129
  • Country: ca
Re: Nixie Tube Clock Project
« Reply #21 on: December 16, 2016, 12:09:40 pm »
Anyone know if nixie tubes will solder on to a perfboard? Im worried that the solder leads wont line up with the perfboard holes.
 

Offline NivagSwerdna

  • Super Contributor
  • ***
  • Posts: 2495
  • Country: gb
Re: Nixie Tube Clock Project
« Reply #22 on: December 16, 2016, 02:29:02 pm »
So, don't use thelibrary, but configure the RTC to output a pulse per second and sync from that.

Yeap that's the approach I use for the clock sitting on my desk.  Uses something like eBay auction: #http://www.ebay.co.uk/itm/400624291795

I read the time at start-up and otherwise just increment a second counter using the 1Hz output

There is a small project at https://github.com/lucadentella/RTCSetup which helps getting the right time into your module to start with.

For longer term you might need a way of keeping the clock in sync with the world...  (and then there's always DST to worry about)... oh the joy of clock projects...
 

Offline linux-works

  • Super Contributor
  • ***
  • Posts: 1996
  • Country: us
    • netstuff
Re: Nixie Tube Clock Project
« Reply #23 on: December 16, 2016, 02:38:06 pm »
I suggest you look into the cheap ublox gps modules.

my diy nixie clock uses gps to set a battery-backed ds3231 rtc module (for hold over) and I'm quite happy with the auto-set feature of gps.  you have to set the timezone but that's all.


Offline PotatoBoxTopic starter

  • Regular Contributor
  • *
  • Posts: 129
  • Country: ca
Re: Nixie Tube Clock Project
« Reply #24 on: January 01, 2017, 05:15:12 am »
I've been contemplating about using TTL logic or an Arduino. I mean, if I were to use a crystal and divide it down to a 1 hertz signal, will it seriously be THAT inaccurate to be worth caring about? Like if it's a few seconds a year, then I could care less. Also, I've never used an arduino, and this project, should I go with an arduino, would be my first project with it, whereas with the TTL logic, I already have a pretty good idea of how to make my clock with TTL logic, with a few 4017 IC's and some clever use of logic gates.

Opinions?
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12852
Re: Nixie Tube Clock Project
« Reply #25 on: January 01, 2017, 08:13:06 am »
I've been contemplating about using TTL logic or an Arduino. I mean, if I were to use a crystal and divide it down to a 1 hertz signal, will it seriously be THAT inaccurate to be worth caring about? Like if it's a few seconds a year, then I could care less. Also, I've never used an arduino, and this project, should I go with an arduino, would be my first project with it, whereas with the TTL logic, I already have a pretty good idea of how to make my clock with TTL logic, with a few 4017 IC's and some clever use of logic gates.

Opinions?

Arduinos typically suck for timing accuracy because they use a ceramic resonator rather than a crystal however some Arduino clones use a real crystal for the main MCU.   With careful calibration, you can keep time on an Arduino to a few seconds per day, but if you want to do any better you need either a RTC or a high accuracy low frequency external clock pulse.   Also, unless significantly modified, it isn't easy to provide battery backup to most Arduinos as they aren't optimised for low power consumption.  This means that an Arduino based clock is typically over-complex compared to one built around a 'bare' ATmega328P.

Crystals really aren't that good for timekeeping.  A typical MCU crystal has a tolerance of +/-30 PPM, which is about 15 minutes per year. Careful trimming and close temperature control can improve that by about one order of magnitude, but if you want to do better than that you need to sync with one or more atomic clocks - and its most cost effective to let someone else fund and maintain them, hence the popularity of GPS receivers for timekeeping or NTP over the internet.  There are also various broadcast timesignals on the LW or MW bands but there's also a lot of interference on those bands and unless you have a background in Ham DX receiver construction or are near enough to a well funded timesignal station to get a very strong signal, its a PITA.

It's really awkward to build an accurate 'retro' clock in pure logic with no MCUs, FPGAs or other 'cheats', as to get anything better than crystal accuracy rapidly gets expensive, both to build and to run.  Probably the cheapest option is to divide down the output of a Rubidium oscillator module off EBAY . . . .
 

Offline PotatoBoxTopic starter

  • Regular Contributor
  • *
  • Posts: 129
  • Country: ca
Re: Nixie Tube Clock Project
« Reply #26 on: January 01, 2017, 05:26:13 pm »
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12852
Re: Nixie Tube Clock Project
« Reply #27 on: January 01, 2017, 06:48:45 pm »
You linked to an ordinary oscillator module (not a TCXO :-//) with a +/-30ppm crystal - that's up to 2.6 seconds/day or 15 3/4 minutes/year.  |O

Its hard to find a low frequency TCXO that can hold better than +/-5 PPM long term and that is still a potential error of just over 5 minutes/year.
 

Offline PotatoBoxTopic starter

  • Regular Contributor
  • *
  • Posts: 129
  • Country: ca
Re: Nixie Tube Clock Project
« Reply #28 on: January 01, 2017, 06:55:59 pm »
You linked to an ordinary oscillator module (not a TCXO :-//) with a +/-30ppm crystal - that's up to 2.6 seconds/day or 15 3/4 minutes/year.  |O

Its hard to find a low frequency TCXO that can hold better than +/-5 PPM long term and that is still a potential error of just over 5 minutes/year.

Oh, I thought I filtered digikey to find TCXO's... Oh well.

Well I think I'll just use a ds3231 and use the SQW output to count the 1 hertz pulses.
 

Offline PotatoBoxTopic starter

  • Regular Contributor
  • *
  • Posts: 129
  • Country: ca
Re: Nixie Tube Clock Project
« Reply #29 on: January 02, 2017, 10:35:53 pm »
When prototyping with the nixie tubes, does it matter what kind of gauge wire should I use for the alligator clips? The particular nixies I'm using require 170 volts to power but only 2.5 to 3.5mA of current.
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12852
Re: Nixie Tube Clock Project
« Reply #30 on: January 03, 2017, 12:12:23 am »
Gauge doesn't matter (within reason - it needs to be robust enough to survive general handling on the bench, but flexible enough that the wires don't unduly stress component pins or leads), but the wire's insulation voltage rating does.
 

Offline PotatoBoxTopic starter

  • Regular Contributor
  • *
  • Posts: 129
  • Country: ca
Re: Nixie Tube Clock Project
« Reply #31 on: January 03, 2017, 01:57:09 am »
Gauge doesn't matter (within reason - it needs to be robust enough to survive general handling on the bench, but flexible enough that the wires don't unduly stress component pins or leads), but the wire's insulation voltage rating does.

Found these cheapo ones on ebay. There doesn't seem to be a rating, will these be alright?

http://www.ebay.ca/itm/10pcs-50cm-Double-ended-Crocodile-Clips-Cable-Alligator-Clips-Wire-testing-wire-/400985352399?hash=item5d5c96e8cf:g:zCgAAOSwBLlVBPl9
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12852
Re: Nixie Tube Clock Project
« Reply #32 on: January 03, 2017, 02:21:37 am »
Its a gamble - I've seen cheap Chinese import clip leads made with wire that was so badly made the actual wire was off-center in the insulation to the point that strands could occasionally be seen at the surface.  Other colours in the same pack were fine . . . .

You should either use clip leads made up with at least 200V rated wire from a reputable supplier or Hi-Pot test *ALL* cheap leads you buy. Even so, with cheap leads, they aren't safe to handle with power on, and should not be left lying on anything that could be damaged if they short out.   

Make sure your HT supply is current limited or fused at 50mA.
 

Offline PotatoBoxTopic starter

  • Regular Contributor
  • *
  • Posts: 129
  • Country: ca
Re: Nixie Tube Clock Project
« Reply #33 on: January 03, 2017, 02:35:45 am »
Its a gamble - I've seen cheap Chinese import clip leads made with wire that was so badly made the actual wire was off-center in the insulation to the point that strands could occasionally be seen at the surface.  Other colours in the same pack were fine . . . .

You should either use clip leads made up with at least 200V rated wire from a reputable supplier or Hi-Pot test *ALL* cheap leads you buy. Even so, with cheap leads, they aren't safe to handle with power on, and should not be left lying on anything that could be damaged if they short out.   

Make sure your HT supply is current limited or fused at 50mA.

As for the power supply, I was just planning on buying one of these modules which converts 12-20v to HV.
http://www.ebay.ca/itm/171374739771?_trksid=p2060353.m2763.l2649&ssPageName=STRK%3AMEBIDX%3AIT

I'm just going to use an old wallwart and cut off the leads for the 12-20v input.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf