Pure TTL Clock

The second half of my circuits and systems lab class this quarter has been an introduction to digital logic.  Unfortunately, over winter break my dad gave me the TTL Cookbook by Lancaster, which I then read a few times, so I've been spending the last four weeks of lecture catching up on my pleasure reading.  The lab projects for the class have been pretty rudimentary (compared to my other projects), so I've had quite a bit of free time in lab to help other groups and work on my own projects.

Flipping through the TTL Cookbook a few weeks ago, I found a schematic for a crystal oscillator (page 170), and it hit me: Once you get a crystal to oscillate, it isn't much more to get it to count time, WITHOUT using a microcontroller!  All of my clocks so far have essentially been a real time clock chip (eg DS1307) connected to a controller (eg ATMega168) which is then connected to a bunch of LEDs of some creative configuration to show time [1] [2] [3] [4].  You do that enough times, and it stops being all that challenging, and easy hobbies are boring hobbies, right?

So what's the challenge?  7400 series digital logic consists of a couple hundred different integrated circuit chips, starting from 7400 and counting up (highest I've seen in real life is 74595).  Each chip does a single logical operation, so one may output the logical AND of two inputs (output HIGH if both inputs are HIGH), where another is 4 flip flops chained together to make a divide by 16 counter.  Before the era of the PC, it wasn't uncommon for a hobbyist to buy a bag full of TTL gates and build himself a nice little computer.  Unfortunately, when each individual IC only does one thing, doing anything useful generally takes quite a few ICs, and you'll need a pretty good collection of them before trying to do anything doesn't consist of buying every single part you need (25-70 cents a piece isn't much, but does add up).  Comparing this project to your typical 8 pin RTC chip, I'd say this implements 5% of the functionality (no calendar functionality, no I2C, etc) at the cost of a few orders of magnitude more board space (6 columns vs half an inch), and a few orders of magnitude in power requirements (600mA vs less than 1.5mA).

Reading this clock is relatively easy, compared to most of my other clocks.  It's in 24 hour time, and seconds, minutes, and the 1's of hours are all decoded nicely by 7 segment displays.  Unfortunately, I ran out of breadboard space, so the 10's of hours had to settle for a pair of LEDs: One LED is lit for 10 + n hours past midnight, and both LEDs are lit for 20 + n hours past midnight (The schematic below shows the little bit of cleverness that I did with a pair of diodes to make that happen).  This means the picture above reads 16:36:39 (4:36PM).

Power consumption for the entire clock is relatively high, which is expected for this many TTL gates.  At 5V, it draws somewhere between 550mA and 650mA, depending on how many LED segments are lit, so plan on running it with a pretty stiff power supply.

Click any of the pictures to enlarge.

  • I did a surprising good job in the video of rattling off part numbers, with the one exception of the 1's digit of the minutes.  The counter is not a 7493 or the 74120 which I corrected myself with, but is actually the 74160 divide-by-10 counter, which is the same as for the second's 1's place.
  • With the button debouncers, the RC response times were calculated for use with 555s, but when I switched to a 74123 I just used the same values without recalculating it.  I think it's quite a bit faster than a quarter second now.
  • I live next to the railroad tracks; I'm sorry.

Working from right to left in the pictures:
On the top right is a 32.768kHz quartz crystal.  This is a convenient frequency because it is a power of 2 (215, for those of you reading at home).  This means that if you divide the output of this crystal by two 15 times, you get down to a relatively stable 1Hz signal (The crystal is spec'd for 20ppm, and the measured drift on it is at least on that order of magnitude).  The amplification of the crystal is done by a 4001 CMOS NOR gate (Not technically TTL, I'm sorry!), which then feeds a chain of three 74161 divide-by-16 gates, and half of a 7493, which divides it by another eight.

Once divided down to 1Hz, the rest of the clock is simply a matter of counting seconds, minutes, and hours, and displaying them.  The seconds stage consists of nothing more than a 74160 divide-by-10 and a 7493 wired as a divide-by-6, which feed a pair of 7447 BCD to seven segment decoders for display.  The 7493 normally divides by 16, but I used a 7408 AND gate between the 2 and 4 output lines, such that when the counter (which signifies the tens of seconds digit) reaches six, the AND gate goes high, resets the counter, and pulses the carry line to the minutes stage.

The minutes stage is just like the seconds stage, with the singular complication that most clock users have this almost indecent expectation that they can plug in a clock all willy-nilly any time of day, and then expect to have some ability to change the time on the clock to the current time.  What nerve, right? That means we have to like, have buttons and stuff...

Unfortunately, TTL counters and buttons don't mix very well.  You don't realize it, but when you push a button, it will sit there and bounce a couple times before it settles down and looks like a single voltage to the counter.  This is a problem, because instead of advancing the clock one minute every time you press the minute button, it can advance two, eight, twenty, or even forty times.  This is a real drag, and needs to be fixed.  To fix this, I used a 74123 dual monostable multivibrator.  Monostable multivibrators are useful because you can kick it once (or a whole bunch of times, in this case), and it will output a single, clean, square pulse for a defined amount of time (defined by the resistors and capacitors connected to it).  This means it can debounce the messy button presses, and turn them into clean square waves to advance the minutes and hour counters.  The 74123 output is combined with the carry signal from the seconds stage by a 7432 OR gate.  I originally had the debouncing implemented by a pair of 555s, which probably made more sense than the 74123, but I had never used a 74123 before, so I decided to have some fun (pretty sick idea of fun, right?).

The hours stage is unfortunately an entirely different bucket of fish.  Not only do we have to use the other half of the 74123 and another 7432 OR gate to let the user advance the hours, and have the first counter carry and reset at 10, but we want both 7493 counters to reset when the clock reaches the end of the day (at 24 hours).  This means another AND gate connected to the 20 and 4 lines, fed to the reset on the 10's counter, and combined with the 1's reset signal through another OR gate.  Pile on top of all of this the fact that I was quickly running out of breadboard space, and you can see my problem.

So there it is.  An entire clock, built from little more than AND & OR gates, flip-flops, and BCD to seven segment decoders.  It was a fun little project, but now that I've proven that I can do it, I think I'm going to go back to my nice little DS1307 RTCs and AVR microcontrollers, thank you very much.


  1. Real men build clocks out of bare transistors.


    Only 1250 parts!

  2. Real men build clocks out of only one microcontroller.



  3. Wouldn't the 744060 be a pretty decent TTL to use for dividing the crystal down? You'd be left with 2hz after it, but that could pretty easily be corrected in the next counter on.

  4. The 744060 would possibly be very useful, yes. I was doing this project entirely out of stock at my college's circuits lab, and they only have one rack of TTL gates, so they don't stock anything that exotic. The goal wasn't to make the clock as small as possible (I'd just use an AVR in that case), but was simply an exercise in TTL logic.

  5. What would be interesting is with a little Boolean algebra, reduce the circuit to the the least amount of TTL -

  6. There isn't much than can be reduced. It's all just one giant divider chain with a few AND and OR gates sprinkled throughout. With a lot of work, you might be able to combine a few of the counters, but that would be at the cost of having to decode back out to BCD for the 7447 decoders, so I don't expect it to be any simpler.

  7. I'm guessing other students, your lab technician, and lecturer all hate your guts for knowing so much.
    Wow! so impressive... seeing things like that make me regret going for software jobs instead of hardware!

  8. amazing stuff.
    can i ask how old you are?

  9. @Simon: Pretty much, though the other students have figured out that I can explain stuff better than the TAs, so they're coming to me instead of them.

    @Anon: I'm 20, and a junior in college majoring in mechanical engineering.

  10. Nice clock!
    Can I ask a question?
    I am making a 12 hour digital clock, my problem is, How could I turn the 12hour directly to 1hour? (it should skip the "00" in h0ur). Im using 74393,74157..Etc...
    Any reply would be grately appreciated.. Thanks.!

  11. @Kenneth: That's the hard part, which I skipped due to lack of board space. You really have two options:

    1. Have the hour counter go from 0-11. On the data lines between the counter and the decoders for your display, add logic to test for the value 0, and OR in the value 12 when that's the case. I'd expect it to be a many-input NAND gate and two OR gates (one for the 2 line, another for the 10 line)

    2. Less elegant solution, but have the counter go from 0-12, and on reset trigger some delayed clock signal to increment the counter from 0 to 1 very quickly after 12:59. This also has the disadvantage of delaying the counter reset an hour past the AM/PM transition, making that feature more difficult as well. I would expect this to consist of little more that one or two triggerable monostable oscillators, so that the first pauses a second after reset, then triggers the second to pulse the counter input for the hours.

    Hopes that all nudges you in the right direction towards solving your problem.

  12. Thanks Kenneth.. :)

    Actually the clock that I've constructed functions just like of what you said in #2.

    This clock that I'm constructing is to be
    defended on a panel so I want 1H to be displayed after the 12H. To implement this, as what I read on some forums, you need counter that has parallel load function. Now, I buy 2pcs 74160 and will be experimenting its function.. Could you help me for this piece of ic's??

  13. Well that's probably easier than either of my two solutions... It should be pretty simple then. Hard wire the inputs for 1, then simply use the parallel enable pin instead of the reset pin.

    Since the 74160 is synchronous, I would watch for it resetting early. Depending on how you're wiring it, it may reset after 11 instead of after 12, because the transition from 11->12 looks like 13 for just a moment. Asynchronous, or "ripple" counters do not suffer from this issue (7490, 7493). I never really solved the sync issue personally, and just switched to async counters where needed. Just keep reading data sheets and play with it.

  14. Good day!

    Just want to say a Big Thanks to you! I already made the 1H to be displayed after 12H.
    You can see it on my facebook accnt.


  15. What values of DC voltage you applied to 4001 and other ICs ? I am seeing there is only one voltage source.

  16. What is the big circular brown component near the crystal? Capacitor? Why there is also a zener diode? I think you did not mention it in circuit diagram. Again I am seeing a capacitor between first two breadboards (from right side). What is that for? Thanks.

  17. @Anonymous: I'm running everything at 5V, which is standard for TTL.

    The third capacitor by the crystal and the electrolytic on the bottom of the first board are for power supply filtering. TTL gates make a lot of noise, which can bother other gates. There should be more of those scattering throughout the circuit, but I got lazy.

    There is no zeners in this circuit.

  18. How did you select the values of capacitors and resistors used to make crystal oscillator? Is there any formulae? I did not find. I have seen making this oscillator cicuit (using same 32.786kHz quartz crystal) with diffferent values of Resistors and Capacitors to get 32.786kHz square wave.

  19. @Anonymous: I'm not claiming this is right, but I got it to work with matching the time constant of the resistor and the capacitor to the frequency of the crystal, so 2.2Mohm * 15pF = 33us = 30.3kHz ~ 32kHz. This is probably wrong, but the original values for the circuit I found were for 2MHz, and those didn't work, and these values seemed to work, having an approx drift below 100ppm.

  20. Can you suggest any way by which I can stop the clock at any time and then reset the clock (each display individually) to any desired time and then start again from my desired time. i thought a process by connecting them to ground by push button but it is causing other problems when simulating in Proteus ISIS. Thanks.

  21. you can get the clock to roll over from 12 to one using the load and not the clear

  22. This is great and it is really going to help me out with my lab final (1/2 of my lab grade depends on a clock similiar to this one).
    However, I need to incorporate a sixth LED in place of your diodes, any suggestions?

  23. I'm working on clock, like your (without uC), but with alarm, unfortunately binary alarm (eg. 20:30) = (0010, 0000, 0011, 0000)...i had problem with crystal resonator and 4060 (14-stage ripple binary counter)..becouse i bought hcf4060. it must be COMS (cd4060). But i think this is not accurate. I think to use ds32khz. (http://www.datasheetcatalog.org/datasheet/maxim/DS32kHz.pdf)

  24. could you please specify the pin numbers too

  25. Nope. Me going back and redoing the entire schematic would be a lot of work, and I would invariably make mistakes. You looking up the pinouts from the datasheets isn't too much work, and inevitably educational. Good luck. :-)

  26. hi kenneth! i just want to know if what to do if i want to do a digital clock countdown timer.. i was really amazed with what you did by simply using tll IC's.. please please please.. give me some insights of what to do with my project.. it is a minutes and seconds only... here is my e-mail evol_morhima19@yahoo.com please kenneth... i'll wait for your response...


Post a Comment

Popular Posts