BCD Clock


What is it?

This is a binary clock display (BCD) clock that I built of my own design.  It is similar to one my sister bought for me as Christmas gift a couple years ago from ThinkGeek.  However, instead of some boring little LEDs, this clock employs much cooler blue-phosphor neon lamps and has the full 6 x 4 display array instead of leaving out the four extra lights you need just to build a BCD clock.  I designed all of the electronics (based on ATmega328 MCU) and wrote all of the software myself (C#).  It currently has 10 different animations in addition to the initial turn-on animation, but I am hoping to add some more in the future.








The case I built for this clock ended up being one of my favorites.  The design is very simple, and was straightforward to fabricate.  I chose to make the front-plate out of black G10, which I think looks really nice.  The G10 is very rigid, so I only needed an 1/8" thick piece to get the structural strength needed.  The lamps are held by black rubber grommets.  Since these small neon-lamps do occasionally fail, the mounting method had to be non-permanent.  I drilled the holes significantly undersized to make for a very tight grip on the lamps.  In fact, you have to use a few drops of isopropyl alcohol as a lubricant to either insert or remove the lamps.  The sides of the case are aluminum, and as always, all surfaces are machined to make it look as "technical" as possible.  In keeping with my tradition of displaying the electronics, I made the back plate out of clear acrylic.  I probably could have used something thinner, but I had a bunch of 1/4" thick material on hand, so I just used that.  All in all the case came together very well, and made for a surprisingly compact unit. 








How does it work?

As I mentioned, I did all of the design work for this project.  I knew it would be based around an ATmega328 and the project would be developed with an Arduino.  I didn't want to multiplex the neon-lamps since they are already a bit dim to begin with, so an array of shift registers would allow me to directly control each of the 24 lamps.  To drive the lamps I needed a high-voltage supply and I decided to use a NeonNixie supply instead of using transformers and/or multipliers.  Although it keeps the design more simple, the NeonNixie supply introduces quite a bit of electrical noise which made for some problems later on that I had to be solved with some software.  I was determined to reinvent the wheel on this project, and avoided using any of the "Clock" Arduino libraries and instead wrote all of the time handling software from scratch.  In the future I'll probably use the libraries...




Click on image to see full size schematics



The hardware is pretty straightforward.  The ATmega328 receives a 60Hz clock signal and after figuring the current time, sends out the display information to a 24-bit shift register (three discrete 8-bit shift registers).  The lamps themselves are switched using trusty MPSA42 NPN transistors.  There are only two switches to set the clock, so each one has their own dedicated pin on the ATmega.  I splurged on a complete crystal resonator so I didn't have to hook-up discrete capacitors for the crystal.



Click on image to see full size schematics



The power supply for this clock is about as straightforward as it gets.  The power comes into the case as 16VAC from a wall-wart.  I chose an AC wall-wart so that you get the safety of mains isolation but you still have access to the 60Hz timing signal which the power company does a lovely job of regulating.  The AC is rectified in a diode bridge then filtered.  The raw DC voltage (~24VDC) is supplied to the NeonNixie HV supply and also to an LM7805 +5VDC voltage regulator.  Since the raw DC voltage is nearly 20 volts above the 5 volts needed for the logic, I use 220 Ohm, 5 Watt resistor in series with the voltage regulator to keep from overheating the regulator.  Finally, to provide power  to the ATmega in the event of a power failure, there is a 1F super-capacitor that can power the ATmega for at least six hours. 



Click on image to see full size schematics



Generating the clock signal proved to be trickier than I might have guessed.  I wanted something super simple to keep the board space and part count way down.  I found a circuit similar to what I ended up using that essentially converts a sine-wave to a square wave.  The thing that really attracted me to this design was the isolation from the AC input so that I could leave the AC floating on the diode bridge.  The problem is that this doesn't actually generate a square-wave.  What it really generates is more like a sloppy trapezoidal-wave.  The ATmega is looking for a falling edge, but the edge of waveform falls so slowly that the interrupt is often triggered more than once per edge, which obviously screws up the timing (makes the clock run fast).  It might have been OK, but with the addition of switching noise from the NeonNixie supply, the falling edge is no longer monotonic, which absolutely garauntees that the interrupt will trigger multiple times.







In the preceding oscilloscope trace, you can see the poorly formed square wave, and in particular, can see the slow as molasses fall-time (400us).  You can also see the switching noise imposed on the waveform, particularly at the HIGH and LOW values.  The solution ended up being a software fix that some kind folks on the Arduino forum helped develop.  The idea is to "debounce" the clock-signal interrupt.  The first time the interrupt is triggered on the falling edge, the program disables interrupts until the waveform has finished falling and returned back to the HIGH state.  It is sort of a jankety fix, but it works, so I'm happy.  In the future, I won't be using this design again for generating a 60Hz square wave though!







Once I had the design all worked out and tested, it was on to fabrication.  Everything turned out well in the end, but it was a lot of tedious work to get everything onto such a small board.  In the photo above you can see the NeonNixie supply on the right and the clock circuit is in the middle.







It never looks as good as having a real PCB made, but using these small perfboards is way, way cheaper, and probably faster since I am never making more than one.  I tried using some free layout software, but the software was so poor, it quickly became apparent that it wasn't going to save me any time.






I'm a fan of using single-hole pad perfboard rather than strip board.  Instead of cutting copper traces to make the desired layout, I just run "traces" of solder along a line of pads.  With a bit of practice it goes pretty fast, but even better, you undo mistakes with a solder pump.




Improvements for the future:
  • Don't use the optocoupler design for generating a 60Hz clock signal.  It turns out the ATmega chips have internal clamp diodes to allow zero-crossing detection with a minumum of components.  USE IT!
  • Develop an actual snubber circuit to reduce the switching noise produced by the NeonNixie HV supply.
  • Include an FTDI header so that the chip can be programmed in-situ.  For this arrangement I had to pull the ATmega out of its socket each time I wanted to reprogram: stupid!



Some more photos:




5:59:49




These blue-phosphor neon lamps are pretty cool.  Lots more character than LEDs!



The fly-cut aluminum looks totally different depending on the lighting conditions.



It looks really good at night! (During one of the animation sequences)



Comments