Nixie Tube Clock Project - Page 1
Forum section: electronics / beginners

author: PotatoBox
author_rank: Regular Contributor
timestamp: December 12, 2016, 04:18:55 am
content: 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?

author: PotatoBox
author_rank: Regular Contributor
timestamp: December 12, 2016, 04:55:13 am
content: Quote from: wilfred on December 12, 2016, 04:39:50 amCould I use a 32.768 kHz crystal and divide that down to 1 hertz with a 4060 and a 4027 flip flop?

author: Ian.M
author_rank: Super Contributor
timestamp: December 12, 2016, 11:43:43 am
content: 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.

author: PotatoBox
author_rank: Regular Contributor
timestamp: December 12, 2016, 12:20:36 pm
content: 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?

author: klunkerbus
author_rank: Unknown
timestamp: December 12, 2016, 12:36:50 pm
content: 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.

author: PotatoBox
author_rank: Regular Contributor
timestamp: December 12, 2016, 12:45:30 pm
content: Ok, Ill use the RTC.

author: CJay
author_rank: Super Contributor
timestamp: December 12, 2016, 02:29:08 pm
content: Quote from: Ian.M on December 12, 2016, 11:43:43 amInteresting, 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.

author: Cliff Matthews
author_rank: Unknown
timestamp: December 12, 2016, 03:33:50 pm
content: Quote from: PotatoBox on December 12, 2016, 12:45:30 pmThe 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

author: PotatoBox
author_rank: Regular Contributor
timestamp: December 12, 2016, 08:44:44 pm
content: 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?

author: CJay
author_rank: Super Contributor
timestamp: December 12, 2016, 09:11:22 pm
content: 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.

author: PotatoBox
author_rank: Regular Contributor
timestamp: December 12, 2016, 09:25:37 pm
content: Quote from: CJay on December 12, 2016, 09:11:22 pmEmulating? Im not emulation anything. I still want to use the RTC chip.

author: Paul Moir
author_rank: Frequent Contributor
timestamp: December 12, 2016, 10:25:03 pm
content: 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 driversPORTA = (n % 10); // Use with 74141sleep(A_FEW_MILLISECONDS);select_nixie_tube(1);PORTA = 1 << (n / 10); // Use with individual segment driversPORTA = n / 10; // Use with 74141sleep(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.

author: CJay
author_rank: Super Contributor
timestamp: December 12, 2016, 10:37:16 pm
content: 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.

author: PotatoBox
author_rank: Regular Contributor
timestamp: December 12, 2016, 10:44:38 pm
content: Quote from: CJay on December 12, 2016, 10:37:16 pmAlright, 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?

author: Ian.M
author_rank: Super Contributor
timestamp: December 12, 2016, 11:35:31 pm
content: An Arduino Mega would have enough I/Os or use three 74HC595 shift registers as a 24 line output expander.

author: PotatoBox
author_rank: Regular Contributor
timestamp: December 13, 2016, 04:14:13 am
content: Quote from: Ian.M on December 12, 2016, 11:35:31 pmI 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?

author: EEVblog
author_rank: Unknown
timestamp: December 13, 2016, 06:57:45 am
content: Quote from: klunkerbus on December 12, 2016, 12:36:50 pmCould 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.

author: Ian.M
author_rank: Super Contributor
timestamp: December 13, 2016, 08:02:42 am
content: Quote from: PotatoBox on December 13, 2016, 04:14:13 amYou 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.

author: CJay
author_rank: Super Contributor
timestamp: December 13, 2016, 10:10:38 am
content: 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)

author: PotatoBox
author_rank: Regular Contributor
timestamp: December 13, 2016, 10:22:30 pm
content: Could I use the shiftout command with this?

author: Ian.M
author_rank: Super Contributor
timestamp: December 13, 2016, 10:35:27 pm
content: 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.

author: PotatoBox
author_rank: Regular Contributor
timestamp: December 16, 2016, 12:09:40 pm
content: Anyone know if nixie tubes will solder on to a perfboard? Im worried that the solder leads wont line up with the perfboard holes.

author: NivagSwerdna
author_rank: Super Contributor
timestamp: December 16, 2016, 02:29:02 pm
content: Quote from: CJay on December 12, 2016, 09:11:22 pmYeap that's the approach I use for the clock sitting on my desk. Uses something likeeBay auction: #http://www.ebay.co.uk/itm/400624291795I read the time at start-up and otherwise just increment a second counter using the 1Hz outputThere is a small project athttps://github.com/lucadentella/RTCSetupwhich 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...

author: linux-works
author_rank: Super Contributor
timestamp: December 16, 2016, 02:38:06 pm
content: 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.

author: PotatoBox
author_rank: Regular Contributor
timestamp: January 01, 2017, 05:15:12 am
content: 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?

author: Ian.M
author_rank: Super Contributor
timestamp: January 01, 2017, 08:13:06 am
content: Quote from: PotatoBox on January 01, 2017, 05:15:12 amArduinos 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 . . . .

author: PotatoBox
author_rank: Regular Contributor
timestamp: January 01, 2017, 05:26:13 pm
content: Can't I just use a TCXO for this?Like one of these?http://www.digikey.com/product-detail/en/abracon-llc/ACO-32.768MHZ-EK/535-9214-5-ND/675409

author: Ian.M
author_rank: Super Contributor
timestamp: January 01, 2017, 06:48:45 pm
content: 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.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.

author: PotatoBox
author_rank: Regular Contributor
timestamp: January 01, 2017, 06:55:59 pm
content: Quote from: Ian.M on January 01, 2017, 06:48:45 pmOh, 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.

author: PotatoBox
author_rank: Regular Contributor
timestamp: January 02, 2017, 10:35:53 pm
content: 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.

author: Ian.M
author_rank: Super Contributor
timestamp: January 03, 2017, 12:12:23 am
content: 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.

author: PotatoBox
author_rank: Regular Contributor
timestamp: January 03, 2017, 01:57:09 am
content: Quote from: Ian.M on January 03, 2017, 12:12:23 amFound 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

author: Ian.M
author_rank: Super Contributor
timestamp: January 03, 2017, 02:21:37 am
content: 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.

author: PotatoBox
author_rank: Regular Contributor
timestamp: January 03, 2017, 02:35:45 am
content: Quote from: Ian.M on January 03, 2017, 02:21:37 amAs 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%3AITI'm just going to use an old wallwart and cut off the leads for the 12-20v input.