Tag Archive for clock

24 hours in a day

Like many of you feel, it’s simply not enough :)

What I’m referring to is the slight issue with 24 not being a multiple of 10 and using two decade counters for an hours display for a clock. Normally, I can set a 4017 counter to reset when it hits any of its digits without issue. In this particular case, the 1s hour digit has to count to 10, increment the 10s, reset, count to 10 again, increment the 10s again, reset and then count to four at which time both hours counters need to be reset.

This is a tad more difficult than counting out 60 seconds and 60 minutes in which the counters can reset themselves without caring what the others are doing. For the hours, I have to have them conditionally reset which brings up a whole bunch of interesting thoughts on digital logic.

This is really my first real foray into digital electronics that wasn’t some silly LED chaser or other such dinky toy. The 4521 and 4017 chips are digital CMOS chips and thus only accept inputs and generate outputs as either DIGITAL HIGH (about 5Vdc or DIGITAL LOW (a certain threshold beneath that). The 4521 (as explained in previous posts) divides the crystal frequency down to 1Hz pulses that are HI for half the cycle and LOW for the other half (a square wave). Every time the 1s of seconds counter receives a HI pulse from the 4521, it increments a digit by making its next sequential output HIGH and making the previous one (as well as the other outputs) LOW. It does this until it hits it’s reset point, which is dictated to where it’s RESET pin is tied to. If it’s tied to ground it will count to 10 and reset. Optionally, it can be tied to any other digit to set the reset point. When it hits this point, it sets the 0 output to HIGH, the others to LOW and sends a HIGH pulse out of it’s CARRY OUT output pin. This carries a signal to the next counter’s CLOCK input causing it to increment and the cycle goes on.

All very logical, which is what you would expect from a chunk of digital electronics. In this light, the solution to the 24 hour reset problem would be a logical one.

Since the 1s of hours digit needs to count to ten twice, we need to tie the RESET pin to ground. Since the 10s of hours needs to count to three and then reset, we tie it’s RESET pin to its 3 output pin. So now we have a case where the two counters will count to 30 or exactly 6 hours more than the length of a day on planet earth. Not a very good clock if it falls behind six hours per day and displays cryptic times like “27:45″.

What’s going to solve this is a conditional reset of both counters. Using our logic we can say that IF 10s == 2 AND 1s == 4 THEN reset both counters. In order to do this, when the 1s just turns 4 and the 10s is at 2, we need to take both RESET pins HIGH so they both go to 0.

Off the top of my head I can think of two possible ways to do this. One being digital the other being somewhat analog. The first would be to take the above logical statement literally and use an AND gate, which is one of the basic logic gates and available in a convenient IC package of 4. I could use something like a 4081 quad AND gate or make AND gates from the 4011 quad NAND gate (you can make any gate out of a bunch of NANDs). Same goes for the equivalent 7400 TTL series ICs. It’s two inputs would be the 1s 4 output, and the 10s 2 output, the true condition taking both reset pins HIGH. Bit of a problem to figure out how to disconnect the 1s reset from ground though. I’m thinking on it.

Another, simpler solution is suggested by the original schematic for the nixie clock, which ties both RESET pins together with some circuitry voodoo to basically perform the same task. What appears to have happened is the 1s digit is shifted over a nudge so that the reset pin can be removed from ground and be solved using a flip flop in combination with the other reset pin. The modification to this circuit to make it a 24 hour clock is something I still need to decipher but is basically the AND logic as described above.

Few hours later

It appears someone else has ran into the same issue and even done up a clearer schematic to illustrate how the hours resetting works for a 24 hour clock. here:

24 hour 4017 wiring

This is a snippet from this schematic LEDSales in Australia (not Austria heh) who interestingly also carry the schematic and sell kits for both this and the power supply for the nixies that I’m using. From what I can see here, they’ve modified the one over at Mike’s Electric Stuff (or vice versa or who knows where the original one came from) in a way that agrees with his notes on the original I have.

It sort of makes sense, from looking at it. The two reset pins are indeed connected but how and why this works I haven’t a clue! I am assuming that it is balanced to only reset if both the 10s hours is 2 and the 1s hours is 4 (as explained above, ok that works) but how the 1s hours resets when it has to count to 10 twice is a mystery to me. I also don’t get that 4148 diode, why it’s there and why it’s biased that way.

The only way to find out is to build it of course! To the lab!

20 minutes later

Well waddaya know? It works! Fantastic. Wired it up according to that schematic and it does indeed count to 24. Mind you, I still don’t understand WHY it works. The reversed biased diode, resistor and cap and what these are actually doing are not obvious to me. Perhaps I’ll submit it to the EEVBlog forum and let the experts there explain it to me in layman’s terms.

That’s it for the timer! Another module is ready to rock. I guess I’ll just figure out how to set the time, a simple pair of push-button momentaries to increment the hours and minutes should do it. Since I probably won’t include a seconds display, there’s no reason for a seconds hold switch. Probably the most challenging part of this build will be finding a suitably nice case for it. I’ll talk about that in a soon-to-come post.

10 Minute Clock

I briefly had a chance to mess about in the lab last night just to continue doing some tests for my nixie clock project. I’m pretty sure I have a firm handle on how the 4017 decade counter works and the timebase is working beautifully. I also did a quick current measurement of my Hivac XN11 nixie tubes to be sure the power supply can handle them.

I first did a simple test of adding to my previous circuit with the addition of two more 4017 decade counters. I had run out of them and was forced (oh poor me) to go out shopping for more. I bought about 20 of them thinking I’ll make good use of these chips in other projects down the road. The result, before I ran out of space on my large breadboard, is a 10 minute clock that counts seconds and one digit of minutes before resetting. Video of the result is below. I used the 16Hz output from the timebase so it’s more exciting than watching paint dry or beards grow.

So yeah, that works. I’ve also been mulling over how to get the hours to reset at 23:59. Though it’s easy to get one counter to reset when it hits any number, it’s more difficult to get two counters to reset conditionally. What I mean by this is that the hours digit must count to 10 twice, then count to 4 while the 10s of hours digit counts only to 2 then resets at 3. When the 10s of hours resets, the 1s of hours should reset when it hits 4.

This I can make possible by linking the reset signals of both chips together though how I will actually do this isn’t quite clear to me yet. The original schematic I’ve had for years, found over at Mike’s Electric Stuff, suggests that I connect the two together and use an RC plus a diode to actuate the reset. The 24 hour clock instructions are written (the schematic is for 12 hour clock) rather than diagrammed so I’m trying to decipher what they mean without melting anything. It would mean that I can ditch the 4013 flip flop entirely from the circuit, being unnecessary.

It’s on the list for this evening’s entertainment. I’ll modify my 10-minute clock to simulate the hours digits for testing.

I had also given some thought to adding two more digits to the clock, which would be easy to do provided I had more nixie tubes. I was gifted a pack of 4 so that is rather limiting. I’ve found a potential source here in Toronto so I may investigate adding a seconds display to my clock. Or I may not. Reason below.

Power to the nixies

The original nixie clock schematic linked above is great I am sure, but it did scare me a bit in that it used un-isolated mains power to both power the circuit and provide a clock for it. I am not quite confident enough to mess with that especially given a certain degree of klutziness of which I am prone. My alternative was to use the schematic for a kit I found that is a power supply for nixies and neon lamps which is pretty cool. It is much safer to my mind and I can use a wall wort to power the thing. One limitation of this little switchmode converter is that I read somewhere it has a max current output around 10mA which is not much at all.

Fortunately, though they require a high voltage to operate, nixies draw very little current. I read somewhere that a typical max current rating of your run-of-the-mill nixie is about 2.5mA. Using the 33k resistor (recommended for the XN11) and 170V I am able to get the things to light up nicely. A quick current measurement from my multimeter gives me the joyous news that it draws a measly 1.25mA. So technically I can power up to 8 of them. Being the cautious sort, I would limit myself to 6 of them and/or a neon lamp to indicate the flashing colon.

I think what I will probably end up doing is just stick with the 4 digit clock and use ultra-bright blue LEDs underneath them to indicate that seconds are indeed being counted. After all, a seconds display is nice to look at when you are playing with a clock, but annoying in every other conceivable circumstance.

The LED under-lighting idea came from photos of numerous nixie clock projects and looks pretty damn cool. It would be a simple matter to add 4 ultra-bright LEDs in any colour I choose, then use a simple NPN transistor to switch them on and off to the 1Hz or 2Hz signal (whichever looks better). The addition of a capacitor would also give them a fading effect rather than an annoying blink. Going to look super-cool!

Fried crystals mmmm

Parallel to my power supply project are two others, both requiring an accurate timebase.

These are my nixie tube clock and my frequency counter (which I will probably combine with my function generator that I will also build).

The two, being time-based, are inherently related. The nixie clock happens to use the mains frequency as a timebase and I really do not like the idea of using an un-isolated mains if I can possibly avoid it. The frequency counter schematics I have all seem to use a crystal timebase which seems more logical. After all, if all of our clocks and watches rely on them, why can’t my nixie clock?

With the mind to use the same time base circuit for both projects, I thought I’d quickly whack it up on the breadboard and see what I get.

I first tried the timebase from Miguel Pedroso‘s cmos frequency counter project. I liked the look of this project, as it seemed simpler than the other one I was looking at which looks scanned from an old electronics magazine. Also, it uses the more modern 4000 series cmos chips rather than the 74HC ones (which I am sure are good too). Anyway, his timebase was deceptively simple, involving only a CD4521 24-stage divider, a 4.194304MHz crystal, a trimmer cap, and a 10pF cap. Great, I like simple.

So I build it up and immediately notice something wrong. It’s not oscillating. What’s more, the 7805 regulator powering the thing is heating up, which it most definitely should not. I tried fiddling with it, checking my wiring, swearing at it, nothing worked. It could have been a dodgy trimmer cap or some other mistake of mine, after all Miguel Pedroso seems to have got his working fine and he did warn me the thing was touchy.

Reaching a dead end, I figured I’d try another schematic I found in a forum, which seems to agree with many others I find floating around the internet. Posted here:

1Hz timebase

My sincerest apologies to the original author and the gentleman (or woman) who posted and cleaned it up. I have forgotten where I found it.

Anyway, I build this up and the bloody thing still doesn’t work! On a whim, I swap the crystal out for another one and behold! My ‘scope starts twitching hi and low every second – making a 0.5Hz square wave. Joy.

I tried the original crystal and discovered it is indeed dead. For all I know, it could have always been dead, or it could have been fried due to the absence of resistors connected to the crystal in Mr. Pedroso’s diagram. Either way I got it working!

Even more fun, I noticed the other output pins on the 4521 give you different divisions of time. It appears I can get 0.5Hz, 1Hz, 2Hz etc. Handy!