| ★ wanayoo — archive 1999 http://howstuffworks.com/digital-clock.htm | Nouvelle recherche | Portail wanayoo |
How a Digital Clock Works
The Basics High Level View
At the heart of the
clock there is
a piece that can generate an accurate 60 hertz (60 oscillations per second) signal.
There are two ways to generate this signal:
by Marshall Brain
Chances are that in your bedroom you have a digital clock beside your bed.
Have you ever looked at it in the morning
and thought, "I wonder how this
thing works?" On the morning that you ask that question you will be very glad to have
this edition of How Stuff Works
nearby, because this edition explains exactly how a digital clock (or wristwatch) works. In fact, this
edition of HSW even shows you how to build your own! To understand how a digital clock
works you have to get inside and see exactly what is going on, and in order to do that you will
learn everything you need to build
one yourself for about $30. So let's get started!
If you have read the How Stuff Works article on pendulum clocks, you know
that all clocks (regardless of technology) have a few required components:
A digital clock is no different. It simply handles these functions electronically
rather than mechanically. So in a digital clock there is an electrical power supply (either
a battery or 120 volt AC power from the wall).
There is an electronic timebase that "ticks" at some known and
accurate rate. There is an electronic "gearing mechanism" of some sort - generally a digital
clock handles gearing with a component called a "counter". And there is a display,
usually either LEDs (light emitting diodes) or an
LCD (Liquid Crystal Display).
Here is a quick overview of the components of a digital clock at a high level.
The 60 hertz signal is divided down using a "counter". When building your own clock a typical
TTL part to use is a 7490 "decade counter". This part can
be configured to divide by any number between 2 and 10, and generates a binary number
as output. So you take your 60 hertz time base, divide it by 10, divide
it by 6 and now you have a 1 hertz (1 oscillation per second) signal. This 1 hertz signal,
obviously, is perfect for driving the "second hand" portion of the display. So far the clock looks
like this in a block diagram:
Many clocks do not display seconds. In that case the same divide-by-10-then-divide-by-6 sequence is used to generate a signal with a 1-cycle-per-minute freqency. If the clock does display seconds then the output of the counters needs to drive a display. The two counters produce binary numbers. The divide-by-10 counter is producing a 0-1-2-3-4-5-6-7-8-9 sequence on its outputs, while the divide-by-6 counter is producing a 0-1-2-3-4-5 sequence on its outputs. We want to display these binary numbers on something called a "7-segment display". A 7-segment display has 7 bars on it, and by turning on different bars you can display different numbers:
To convert a binary number between 0 and 9 to the appropriate signals to drive a 7-segment display, you use a (appropriately named) "binary number to 7-segment display converter". This chip looks at the binary number coming in and turns on the appropriate bars in the 7-segment LED to display that number. If we are displaying the seconds, then the seconds part of our clock looks like this:
The output from this stage oscillates at a frequency of one-minute-per-second. You can imagine that the minutes section of the clock looks exactly the same. Finally the hours section looks almost the same, except that the divide-by-6 counter is replaced by a divide-by-2 counter.
Now there two details left to figure out if you are building a real clock:
Building Your Own Digital Clock
The best way to understand the different components of a digital clock and how they work together
is to actually walk through the steps of building your own clock. Here we will build
just the "seconds" part of the clock, but you can easily extend things to build a complete
clock with hours, minutes and seconds. To understand
these steps, you will need to have read the How Stuff Works
articles on Boolean logic
and Electronic gates. In particular the
Electronic gates article introduces you to TTL
chips, breadboards and power supplies. If you have already played around with
gates as described in that article, then the description here will make a lot more sense.
The first thing we need is a power supply. We built one in the How Stuff Works article on Electronic gates. In that article we used a standard wall transformer that produced DC power and then we regulated it to 5 volts using a 7805. For our clock we want to do things slightly differently because we are going to extract our 60 hertz timebase from the power line. That means that we want an AC rather than a DC transformer, and we will use a part called a bridge rectifier to convert the AC to DC. Therefore we need the following parts for the power supply:
| Part name | Jameco part # |
| 10 volt AC 400ma transformer | 147993 |
| Bridge rectifier | 103018 |
| 7805 5 volt regulator (TO-220 case) | 51262 |
| Two 470 microfarad Electrolytic Capacitors | 93817 |
| 5.1 volt Zener diode | 36097 |
| 1K ohm Resistor | 29663 |
A few notes on the parts used:
As we saw in the article on electronic gates, the power supply is the most difficult part! To create the rest of the clock you will need:
Let's look at the 7490 briefly to see how it works. Here is the pin out:
The 7490 is a "decade counter", meaning it is able to count from 0 to 9 cyclically, and that is its natural mode. That is, QA, QB, QC and QD are 4 bits in a binary number and these pins cycle through 0 to 9, like this:
QD QC QB QA 0 0 0 0 0 0 0 1 0 0 1 0 0 0 1 1 0 1 0 0 0 1 0 1 0 1 1 0 0 1 1 1 1 0 0 0 1 0 0 1
In this diagram, the left two 7490s divide the 60 hertz signal from the power supply down by a factor of 60. The third 7490 takes a 1 hertz signal as input and divides it by 10. Its four outputs drive normal LEDs in this diagram. The fourth 7490 divides the output of the third by 6, and its three outputs drive normal LEDs as well. What you have at this point is a "second hand" for your clock, with the output of the second hand appearing in binary. If you would like to create a clock that displays the time in binary, then you are set! Here is a view of a breadboard containing a divide-by-10 counter, a divide-by-6 counter and a set of LEDs to display the output of the counters in binary:
If you want to display the time as numerals, you need to use the 7447s. Here is the pinout of a 7447, as well as the segment labeling for a 7-segment LED:
You connect a 7447 to a 7490 like this:
You will need to have the pinout for the specific LED display that you use so that you know how to wire the outputs of the 7447 to the LEDs in the 7-segment device. [Also, note that the 7448 is equivilent to the 7447 except that it drives common cathode displays. Ground the common cathode of the LED in that case.]
You can see that by extending the circuit we can easily create a complete clock. To create the "minute hand" section of the clock all that you need to do is duplicate the "second hand" portion. To create the hour hand portion you are going to want to be creative. Probably the easiest solution is to create a clock that displays military time. Then you will want to use an AND gate (or the R inputs of the 7490) to recognize the binary number 24 and use the output of the recognizer to reset the hour counters to zero.
The final piece you need to create is a setting mechanism. On a breadboard it is easy to set the clock - just move the input wires to drive higher-frequency signals into the minute hand section of the clock. In a real clock you would use pushbuttons or switches and gates to do the same thing.
If you happen to take your bedside clock or watch apart, one thing you will notice is that there are probably not 15 TTL ICs inside. In fact, you may not be able to find a chip at all. In most modern clocks and watches all of the functions of the clock (including the alarm and any other features) are all integrated into one low-power chip (in a watch the chip and display together consume only about a millionth of a watt). That chip is probably embedded directly into the circuit board. You might be able to see a blob of black plastic protecting this chip. That one chip, however, contains all of the components we have discussed here integrated into one very small device.
Now you have a complete understanding of how digital clocks work! The next time you look at the clock beside your bed or your digital wristwatch, you can do so with a new respect for what is going on inside! If you would like to advance to the next level and see how to build a digital clock with a microcontroller, see the HSW Microcontroller Article.
If you have ever wondered why there are 24 hours in a day or 60 minutes in an hour, see How Time Works!
![]() |
How Stuff Works (http://www.howstuffworks.com) is a production of Howstuffworks.com, Inc. P.O. Box 40492 - Raleigh, NC 27629 See http://www.howstuffworks.com/contact.htm for contact information |
© 1999 Howstuffworks.com, Inc. All rights reserved.