CMOS Nixie Tube Clock Project: Part 2

It's all just logic

This is Part 2 of a multi-part series on my most ambitious electronics project to date: building a CMOS logic-based clock with a Nixie tube display. Part 1 covered the basic design goals and desired features. Today we're going to be diving right in to the design of the logic circuits. Don't worry, it's not that bad. I'll be going through the design from the bottom up, explaining the circuit and pointing out road blocks that tripped me up when I started trying to figure out how to put this thing together.

If you're completely unfamiliar with logic circuits, I suggest looking through this series of logic gate tutorials. They explain what logic gates are, how each gate works, and give typical equivalent transistor circuits. 

Wait a second...

Circuit diagram for timebase. Note that all labels with the same name are connected together. Consists of a CD4060 binary counter (upper right) attached to a quartz crystal oscillator circuit, with an extra flipflop (CD4013) tacked on.

A clock is nothing but a device that counts the number of times something happens and does the necessary division to turn that raw count into seconds, minutes, and hours. So let's start with how you divide down your time base into a 1 Hz tick for your seconds counter. One of the easiest ways to do this is with a flip-flop. There are many variations on this basic logic circuit, as you will see if you follow that link to the Wikipedia article. But we'll just concern ourselves with specifically the D-type flip-flop, which changes state every time you pulse the CLOCK input. In other words, if you feed it a string of pulses, the output will be a string of pulses with exactly half the frequency. So now let's say you have a crystal with a frequency of 32,768 Hz. If you run it through a flip flop chip, you'll get an output frequency of 16,384 Hz. If you run it through another flip flop, you get a frequency of 8,192 Hz. If you do that 13 more times (and this is why clock makers pick this particular frequency crystal oscillator), you get a train of pulses with a frequency of...(drum roll)...1 Hz. 

Weirdly, you can't actually buy a single chip with 15 flip flops on it, but you can buy one with 14 on it: the CD4060B. Helpfully, this chip also has the facility to drive your oscillator circuit, so with a single chip, three resistors, two capacitors and a clock crystal, you can generate a 2 Hz pulse train with a frequency accuracy within 1 ppm. Since we're left with a 2 Hz signal, we need one more flip flop to divide it down to the 1 Hz we need for our clock. You can't seem to buy chips with single flip flops on them, either but that's OK since we also need a flip flop to turn our AM/PM indicator light on and off (waste not, want  not). And so you get the pictured timebase circuit that outputs a 1 Hz pulse train that we can now use to count minutes and hours.

Give me a minute

Binary counter (credit: Wikimedia Commons, author: Ephert)

Binary counter (credit: Wikimedia Commons, author: Ephert)

Before we can count minutes, we have to count to 60 seconds, and every time we get there, output a pulse (to tick the minute counter over by one) and reset to zero. And we do that with (you might have already guessed) a bunch of flip flops, because another way to think of a bunch of flip flops strung together in series is a binary counter, just like the one pictured. The right-most digit (the "ones" place) ticks back and forth between 1 and 0. The second digit from the right is the second flip flop in the series, and it only flips back and forth between 1 and 0 when the first flip flop resets, in other words, every time you count to two. The third flip flop switches state every time the second one counts to two, or every time the first digit counts to two twice. You may see where this is going. Each digit represents the number of times (between 0 and 1) a given power of 2 has been counted to. You might notice, however, that the pictured counter can only count up to 31 (2^5) before it resets to zero, which tells us that in order to count all 60 seconds in a minute, we will need one more flip flop to enable our binary counter to count to 2^6, or 64. But they don't sell 6 bit binary counters in the CD4000 series; they sell 7 bit binary counters (CD4024B). Oh well, let's just roll with it.

So now we have a chip that will count to 128 for us and then reset. Great! Let's feed our 1 Hz signal from our timebase into the CLOCK input. There's only one problem: there aren't 128 seconds in a minute. There aren't even 128 seconds in two minutes. We need a way to make the chip reset to zero before it actually gets to its maximum value. Fortunately, those clever chip designers thought of that, too, and all you have to do is pulse the RESET pin "high" and the chip will reset to zero. Now all we need to do is add some circuitry to generate a reset pulse when our counter gets to 60, or in binary 0b111100 (binary numbers are typically indicated by preceding them with "0b", just so binary 100, which equals 4, isn't confused with decimal 100, which obviously does not equal 4). In other words: when output pins Q3, Q4, Q5, and Q6 on the counter chip all are outputting a "high" voltage. And there's no better way to do that than with a 4-input AND gate (well, there might be). The AND gate will only output a "high" signal when Q3, Q4, Q5, and Q6 are all "high", which will immediately reset the counter to zero. Now we just need a clock signal with a 1/60 Hz frequency to send to the minutes counter. I chose to use the output of Q6. This pin is "low" for the first 32 seconds of any given minute and "high" for the last 28 seconds of any given minute, giving you a 1/60 Hz pulse with slightly less than a 50% duty cycle. 

Seconds and minutes counter section of clock circuit. Note that all labels with the same name are connected together.The "1MIN" output of the seconds counter doesn't match the name of the "1MIN_Tick" input of the minutes counter because I have some logic in between to allow the user to insert pulses using a push button in order to set the minutes on the clock. 

Turning to the minutes counter, I'm going to switch things up on you a little bit. You might think that since there are also 60 minutes in an hour, we can just duplicate the circuit I just described and feed it the output of the first circuit. And you'd be right. But there's a reason we're not doing that: we eventually want to display the number of minutes that have passed in decimal form, and it's harder to find chips that convert 6 bit binary into decimal than it is to find chips that convert 4 bit "binary coded decimal" (BCD) into decimal. What is "binary coded decimal"? you might ask. And don't feel bad for asking that; I had no idea this was a thing, either, but it's actually pretty helpful.

Instead of encoding the whole number in binary like we were with the seconds counter, we encode each digit of the decimal number individually in its own 4 bit binary counter. So instead of encoding 45 as 0b101101, you would encode it as two separate numbers 0b0100 (4) and 0b0101 (5). You might be asking, "What the hell? That takes up more space!" At least, I did. But think of it this way: your decimal display is broken up into separate digits, so it actually makes sense to have one 4 bit binary counter count to 10 (for the "ones" place in your decimal display) and then reset and increment the next 4 bit binary counter (for the "tens" place). And so a BCD counter is just a 4 bit binary counter that already contains the logic to reset the counter at 10 instead of 16. And a "dual BCD counter" like the CD4518B in the pictured minutes counter circuit is just a single chip that contains two BCD counters, which is handy because the number of minutes (in decimal notation) is never more than a two digit number. 

I should pause here and mention a small subtlety in the design of this particular chip that we're using. The chip has three input pins: a CLOCK, an ENABLE, and a RESET. We're already familiar with the CLOCK and RESET pins from the seconds counter, but what does the ENABLE pin do? Well, it enables and disables the CLOCK pin. When ENABLE is high, a transition from "low" to "high" (but not the other way around) on the CLOCK pin increments the counter, and when ENABLE is "low", nothing happens. But there's one extra subtlety: if the CLOCK pin is "low", and the ENABLE pin transitions from "high" to "low" that also increments the counter. This turns out to be useful to us. Remember the output of our seconds counter? It's a pulse that is "low" for the first 32 seconds of a minute and then "high" and transitions back to "low" at the end of the minute. If we just hook our one-minute pulse up to the CLOCK input of our BCD, the minute counter would increment at the 32 second mark when our pulse transitions from "low" to "high". We can't be having that! Our clock would always be off by 32 seconds! But if we just wire our CLOCK input to ground and feed our one-minute pulse into the ENABLE input instead, we get the behavior we want: as soon as the seconds counter hits 60 and resets, the minute counter increments by one.

We now need two more things to make our minute counter complete: connect the two BCD counters on the chip together in series and add logic to reset the counter to zero when it gets to 60 (rather than the default of 100). The first thing is easy: just connect the output of Q4A (the most significant digit of the first binary counter) to the ENABLE input of the second binary counter, and wire the CLOCK pin to ground. Now when the first counter resets to zero (transitioning the Q4A pin from "high" to "low"), the "tens" digit of our minute counter will increment. To reset the whole counter at 60, we'll use the other 4-input AND gate on our CD4082B chip. The criterion for reset is the "tens" digit counter incrementing to 6, or 0b0110. So we wire the Q2B and Q3B pins to our AND gate. To make sure the other two inputs to the AND gate are always "high" (and thus effectively turn our 4-input AND gate into a 2-input gate), all we have to do is wire those pins to the power bus, which by definition is always "high".

Voila! A circuit that counts the number of minutes that have passed. 

Hours of Fun

24-hour and 12-hour counter circuits. The CD4518B chips are dual BCD counters. The CD4081B chip is a quad 2-input AND gate. The CD4002B chip is a dual 4-input NOR gate. And the CD4071B is a quad 2-input OR gate. For the 24 hour counter, the counter just resets to zero when it reaches 24. For the 12 hour counter, there is no such thing as 0 o'clock, so we need to force it to display "12" instead of 0. 

With all that behind us, the hour counter isn't all that complicated, as long as you are using 24 hour time. It's basically the exact same as the minute counter, but instead of resetting when the counter reaches 60, it will reset when it reaches 24. Easy peasy. 12 hour time, on the other hand, is tricksy. You might be tempted as I was initially to just wire it up to reset when it gets to 12, and that almost gets us the behavior we want. But unlike 24 hour clocks, in 12-hour time 0 o'clock isn't a thing. Well crap. How do we make our counter not do that? We fake it.

When the counter gets to 12, it resets to zero, but we put a couple extra logic chips in the way of the outputs from the counter. Specifically, the least significant digit in the "tens" place counter and the second digit in the "ones" place counter (the pins that would be high had we not reset it when it got to 12). These pins are labeled "U_12HR_Tens_A" and "U_12HR_Ones_B" in the circuit diagram to differentiate them from the corrected values that will eventually get sent to the display.

First, we use a dual 4-input NOR gate to check whether all four pins in each counter are low (i.e. the counter is reading zero). We check that both counters are reading zero by using one of the gates on our quad 2-input AND gate. Finally, we don't want to completely supersede the output of the original pins so we OR the output of our AND gate with the original pins to generate the corrected output. If we don't do this last step, at 2 o'clock and 10 o'clock the clock would read 0 o'clock, and at 11, it would read 1 o'clock. The OR gate allows the "high" state of the original counter pins through, so if the counter reads "10" or "11", the 12_HR_Tens_A pin will still be high, and if the counter reads "2" the 12_HR_Ones_B pin will still be high, allowing the binary decoder in the display circuit to show the correct time.

The final thing we need is an indicator light for AM/PM. This can be done with a flip flop connected to the output of our 12-hour correction signal. This signal will be high starting at 12 o'clock and transition to low at 1 o'clock. Our flip flop will transition on the low-high transition, exactly as the AM/PM indicator light is supposed to do.

That's all for clock design today. I hope you enjoyed this post, and remember to stay tuned for Part 3, in which I'll go over the user interface buttons and the display circuitry. If you'd like to use my design, you can download the KiCAD schematic and board files from my GitHub page. Everything is licensed under Creative Commons Non-Commercial Attribution Share-Alike 4.0

I'm very much a n00b at this, so feedback is encouraged! Feel free to leave comments on this post or contact me on Twitter or YouTube if you use the design, find something wrong, have a question about something, or just want to say 'hi'. 

CMOS Nixie Tube Clock Project: Part 1

One of the Nixie tubes from my old frequency counter

Nixie N00b

I'm starting this post after having done quite a bit of design work on this particular project, already. I acquired several Nixie tubes last year around this time in the form of a display from a broken Hewlett Packard frequency counter that I bought at an estate sale. Most of the parts in the frequency counter were pretty trashed from being in a barn for goodness knows how long, but the tubes were still in decent condition, and I'd always wanted to make a Nixie tube clock.

Before I go on, for those of you wondering what this "Nixie tube" thing is, wonder no more. They are a type of digital display popular in the 60s and 70s. Though it looks like a vacuum tube, it is actually filled with low-pressure neon. Inside each tube are multiple negative electrodes (cathodes) in the shape of numerals or characters. When one of the cathodes is energized, that cathode glows orange from the electrical discharge in the neon gas, displaying the desired character or numeral as a glowing orange outline.

The frequency counter sat in my apartment for about a month before I got around to taking it apart, and then I had eight Nixie tubes and no idea how to actually use them. Fortunately for me, Nixie tube clocks are quite the popular hobbyist project. I learned several important things: the specific tubes I have are of type IN-12, you need a high voltage DC supply (~180 V) to drive them, and almost nobody makes binary to digital converter chips that can handle those voltages anymore. But we'll come back to that later.

Breadboard version of Threeneuron's Nixie power supply

Before I started designing a clock, I needed to figure out whether the tubes actually worked or not. The piece of equipment that they came from was in no shape to even turn on enough to give me the 180 V I needed to test the tubes, and I am not a well-enough established electronics hobbyist to have a high voltage DC bench supply lying around. I would need a DC boost converter built into my clock circuit, anyway, so I looked around for good designs. 

The first one I came across was the one on Threeneuron's Pile O'Poo. I bought the components and put together a breadboard version. This worked well enough to test the Nixies, but it had stability issues that I wasn't able to determine the cause of where it would randomly drop in output voltage. I assume it was something wrong with my implementation because several projects I've come across have used this design successfully. However, I also lack the equipment to do signal analysis of a cyclic circuit like a boost converter, so I just scrapped it and tried another design. 

The design I tried next was from this Instructables article. It uses elements from several different designs (including Threeneuron's), which also meant I could reuse several of the components I had bought for the first power supply iteration. And when I bought the components and put the circuit together, its output voltage was rock solid.

Power supply from Instructables article. One thing to note, even though the rotary switch I'm using to switch the inputs on the tube is on the ground side of the Nixie tube, only one of the pins (the one connected to the illuminated digit) is actually grounded; the ungrounded pins are still floating at 60 to 100 V. Fortunately, I didn't die, but in retrospect, I should have mounted the switch such that I didn't have to risk touching the solder lugs in order to actuate it. 

Design Goals

With the tubes and power supply tested, I needed a clock design. One popular design, the Arduinix, is an Arduino shield that multiplexes the output pins of an Arduino to drive enough Nixie tubes to make a clock display. I already have the Arduino, and just writing a clock program and multiplexing the output to a Nixie display would be a nice way to get a functional Nixie tube clock. But I like to torture myself, so I decided to try to make a clock using just a bunch of binary counters and some logic gates. Hell, if Dave Jones could do it back in the 80's, I can, too.

So what does a clock need to do? Well, obviously it needs to tell time. Beyond that, there were several extra features that I wanted my clock to have:

  • Switchable between 12-hour and 24-hour format
  • Independent hour/minute set buttons (the kind of time set buttons that just run the clock forward faster annoy me)
  • A "blank display" switch to turn off the Nixie display if I don't want it to be running for whatever reason 
  • A battery backup mode that would run just the logic, but not the display
  • A display shutoff override so you can still read the time, on demand, when the clock is in battery backup mode.

And I needed to figure out how to do all of those things with switches and logic chips. Some of them are easy. The "blank display" switch can just be a switch that disconnects the boost converter circuit, so there is no high-voltage to run the tubes. The battery backup mode can be achieved with some well-placed diodes, and the battery backup display shutoff override can just be a switch that shorts out the diode isolating the high voltage supply from the battery backup. But I also didn't know the first thing about choosing the types of logic chips I needed, or even what types are available. 

The one criterion I knew I needed to fulfill was the chips had to be compatible with a 9V supply voltage, because that is the voltage needed to drive the boost converter to run the Nixies, and I didn't want to have more than two voltage levels in my circuit. A quick search on Mouser showed two things: one, I had no idea there were that many different types of AND gates, and two, that the vast majority of logic ICs that meet my voltage criterion are from some chip family whose part numbers are all CD4xxx. A little internet research led me to a page explaining how logic ICs work, and I learned that these chips are CMOS (Complementary Metal Oxide Silicon) chips rather than traditional TTL (Transitor-Transistor Logic) chips, meaning they use a different type of transistor (MOSFET rather than bipolar junction).  Aside from being compatible with the supply voltage I wanted to use, CMOS chips are also much lower power consumption, which is nice for the battery backup. So CMOS chips it is!

Lastly, my clock needed a time base, some source of regular pulses that my logic circuit could count in order to keep time. There are many options for a source of pulses, some are good for keeping time for only short periods before they drift, and some can keep time for days, weeks, years, or even millennia. Cesium fountain clocks may be fantastically accurate, but I honestly don't have that kind of cash. Fortunately, there's something that's only one ten billionth as good for less than one ten billionth the price: quartz crystal oscillators.

Quartz crystal is piezoelectric, which means it changes shape when a voltage is applied across it, and applies a voltage when its shape is changed. What this means in practice is you can tune a quartz crystal (by changing its size) to vibrate at a very specific frequency, and the natural frequency of mechanical vibration of the crystal will force the electrical circuit it's placed in to oscillate at that frequency, assuming your circuit is tuned to oscillate at a frequency in the ballpark of the crystal's natural frequency. Generally, quartz crystals can be as accurate as 1 part per million, meaning a clock running on said crystal might gain or lose a second over the course of 11 days, which is definitely good enough for some random guy's hobbyist project. 

With a power supply, a bunch of Nixie tubes, a logic chip family, and a (reasonably) accurate time base, it's time to build a clock! Tune in to Part 2 of this project, where we design a logic circuit to turn the oscillations of our quartz crystal into a nice, readable 12/24 hr time format.

Simple Box Kite

Box Kite (Credit: Pearson Scott Foresman -from Wikimedia Commons)

Box Kite (Credit: Pearson Scott Foresman -from Wikimedia Commons)

I love kites, and I've always wanted to try my hand at building some. I built a simple box kite from pine dowels and paper in high school and really enjoyed both the build process and flying (and ultimately crashing) it in the park. So, for the ABC Kite Festival in Austin this year, I decided to build another simple box kite, but as light and as cheap as I could.

If you've only ever encountered the typical diamond-shaped kite, you may be wondering what exactly a "box" kite might be. The simple answer is that instead of being the flat sail or delta-wing shape most often associated with kites, it is instead a rectangular tube structure that operates more like a rigid wind sock than a wing.

The name comes from the fact that the typical design is a long rectangular prism like the one pictured here, with a band of fabric or paper around each end to act as the sail, making a box shape.

Box kite structure design

Not having made a kite in over a decade, I wanted to make something easy and canonical just to have a bit of fun. I drew up a quick design on paper first, to get a feel for the dimensions. Going for simplicity, I opted to make the cross-spars half the length of the main spars. That way, I could just buy six standard 48'' dowel rods and cut two of them in half to have all of the structural dowel I needed. 

To attach the dowels together, I just used some of the nylon kite string to lash everything in place. I had thought about using a nylon hose barb tee fitting to effect the butt joints between the cross spars and the main spars. I think it would have been stronger without being too much heavier, but at Home Depot, one nylon hose barb tee was almost $4 and I needed eight of them, and that seemed like more than the idea was worth, given that all of the other materials together cost under $15. Perhaps I will try it on a future kite project.

Lashing all of the spars together took a couple hours, mostly because I had to figure out a workable technique. I used about 3 to 4 feet of string for every joint. I twisted the string around both spars in a cross pattern, leaving the starting end visible. At the end, I tied the two ends together and singed them briefly with a lighter to keep the knot from coming loose.

To make the spars into the correct box shape, I added rigging lines around the perimeter and across most of the diagonals and pulled them taut, again, singing the knots to keep them from coming undone, as the nylon string I was using was very slick and tended not to hold position very well.

Finally, I needed some sails. I had originally planned to use a light cloth or paper, but I hadn't had time to buy any, and I wanted to test the kite to make sure the design would work and my lashing job was strong enough to keep the kite's shape in the breeze, so I just used plastic food wrap, instead. Initially, I was thinking I would use the plastic wrap for testing and then change to another sail material when I could get some, but I decided I liked the look. In the sunlight, the sails glint when they catch the light just right, otherwise they are nearly invisible, giving the kite a kind of "deconstructed" look. The photos below show the progression from lashed spars to rigging lines to plastic wrap sails. Fully constructed, the kite weighs about half a pound and measures 48'' long by 17.5'' square.

Progression of kite build from just the spars, to spars and structural rigging lines, to complete with sails

With the kite built, it was time for testing. There are several open fields at the research campus where I work, and I grabbed one of my colleagues to help with videography and took it out for a spin. Unfortunately, the wind wasn't particularly steady. Sometimes it was blowing enough to keep the kite aloft by wind alone, but often the wind died to the point that you had to supplement the wind power with leg power, and had to land the kite when you ran out of field through which to run.

Finished kite with coat of silver paint

I also thought it would be cool if the kite could lift a small video camera and take aerial video. I bought a cheap knockoff GoPro off Amazon and lashed it to the kite with more nylon string. With the camera attached, the kite is a third again as heavy, but it still managed to fly just as well.

When the kite is flying steady, the video is pretty nice, but with it bucking in the breeze, it's not the easiest thing to watch. I also need to experiment with other methods of attaching the camera such that it can look more toward the horizon; when all the camera can see is the kite pilot running through an open field, the video is not particularly engaging. However, I edited the test footage together into a short YouTube video, with a short explanation of the kite build process at the beginning.

After testing the kite, I took it apart and painted the spars silver to make it look more retro-futurist with the clear plastic sails. The original plan for this kite was to take it to the ABC Kite Festival that was supposed to take place on March 5th. I was hoping to use it to get aerial footage of all of the other kites flying at the park. However, both the original date and the rain date got rained out this year. I still plan to take it to Zilker Park on a nice day sometime in the next month and get some use out of it. I will upload more video and possibly post another blog entry when that actually takes place.

Hello World

Well, hello there, fellow Internet denizens! After my first website more than a decade ago, I've finally gotten around to procuring myself a small hollow in the vast intertubes. If you're really curious and you won't judge my 2004 self too much there's a small taste of my old site on the Internet Archive's Wayback Machine.

This being the beginning of a new year, I believe it is customary to use this arbitrary demarcation to make promises to do things differently in the coming 365.2422 days. So, I will do my best to write a blog entry at minimum once a month about something I'm up to (one down, eleven to go!).

I plan on using this site to showcase current personal projects and share things I've learned that might help others in similar endeavors, rave about interesting things I find on the internet, and rant about annoying things I find on the internet.  I hope you'll join me and be inspired, learn something, or even teach me something in the next year.