Tag Archive for digital

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.