3.11 Clock Generators
The topic of discussion is the core of all digital logic systems and computers—the clock. Nearly all digital computer systems are synchronous machines; they use a base clock signal and step through logic, programs, and states based on this clock. Computer clocks are from KHz to GHz these days. Figure 3.70 shows the schematic symbol for a clock and simple 1.0MHz signal that you might find in an old Apple II (I think it was 1MHz). Additionally the clock in this example is symmetrical; that is, the amount of high/low time is equal and the total time per cycle is the period T=1/f = 1/1MHz = 1μS. Therefore, we know that the high and low cycles are 500nS each. The amount of time a clock is high relative to its total time is called its duty cycle. To generate a clock signal you need an oscillator of some kind; there are a lot of ways to build oscillators, but their construction is beyond the scope of this book. We are simply going to use pre-made oscillator systems. Our choices are generally the following:
- Use a crystal with additional caps and inverters to build a clock circuit.
- Use a single oscillator IC that you apply power to and it outputs a clock signal.
- Use a programmable timer IC that uses a few passives to set the frequency.
Figure 3.70 Clock and signal.
Choice 1 used to be the de facto standard, and many microprocessors and microcontrollers allow you to attach a standard crystal to two pins along with some bypass capacitors and the crystal will oscillate. Figure 3.71 shows an image of a typical crystal, but remember this is NOT an oscillator; it is only used as part of an oscillator circuit. Also, on the CD located at
Figure 3.71 Typical crystal package.
you can find a datasheet with application notes for a common brand of crystals. Now, the pro of using an oscillator IC is that you only need a couple caps to bypass it if you are connecting it to a microprocessor or microcontroller, but if you want to build your own oscillator circuit that is based on a crystal, it’s much harder, takes more parts, and is really hard to get working. Therefore, I never use crystals anymore; they may be cheaper, but I prefer pre-made oscillator ICs as shown in Figure 3.72. Here you see a full can and half can design. They are the same just with different packages. These are very simple to get working; you just buy the oscillator frequency you want with the proper logic levels (most are TTL/CMOS and powered with +5), apply power to the corner pins, and the oscillator roars into operation and puts out a perfect square wave.
Figure 3.72 Oscillator circuit.
Figure 3.72 shows the circuit for a simple oscillator circuit, Figure 3.73shows the circuit on a experimenter board, and finally Figure 3.74 shows an output from an oscilloscope of the signal (an o-scope shows voltage as a function of time, so you can see high speed signals). Also note I used a 3.579445 MHz color burst clock for fun.
Figure 3.73 Oscillator implementation on experimenter board.
Figure 3.74 Output of oscillator on o-scope.
The only problem with oscillators is that they are pretty expensive: around $2.00 in high quantities (100 or more) to $5 in low quantities, 1 to 10. This is why people try to use crystals with analog components for oscillators, but the problem is that if you want to change the frequency of a crystal based oscillator, you might not be able to, since each crystal frequency requires slightly different de-coupling caps that might be soldered into your board and non-removable, whereas with a oscillator IC you just pull it out of a socket and put another in. So my suggestion is to use oscillator ICs and not crystals. Also, on the CD located in
you can find a datasheet with application notes for a common brand of oscillators (notice some oscillators even have output enable pins, so you can tie 10 different oscillators’ outputs together and then only enable one of them digitally!).
3.11.1 The 555 Timer
No electronics book can be without at least some mention of the 555 timer chip. The 555 is a standard 8-Pin DIP; Figure 3.75 shows an excerpt from the National Semiconductor datasheet for the 555 (LM555 is their part #). In any case, the 555 is an amazing little device. It’s not the most accurate thing in the world, but it has a lot of different modes of operation; astable, monoastable, time delay, etc. Basically, you can use it to create a constant clock with varying duty cycle, or one shot pulse applications; the applications are really limitless. Referring to the applications notes, the circuit for astable (free running oscillation) is shown on Page 7, Figure 4. A transcription of this is shown in Figure 3.75. So basically, you need two resistors Ra, Rb; a capacitor C; and a small bypass of 0.01μF to control the output of the chip. If you refer to Page 8, Figure 5 of the datasheet you will see the math and analysis for the astable operation; it states that the frequency of period and frequency of oscillation are
Equation 3.6: 555 timer period.
- T = [0.693*(Ra + 2*Rb)*C]
- F = 1/T = (1.44)/[(Ra + 2*Rb)*C]
And the duty cycle is D:
- D = Rb / (Ra + 2*Rb)
So more or less you can use the equations to set the frequency of your oscillator and desired duty cycle, but the cool part about it is that for testing purposes, the 555 is wonderful, since if you replace Ra and Rb with a potentiometer (adjustable resistor) then you can adjust your clock speed! Of course, the 555 can’t operate very fast (referring to the datasheet there is a typical rise/fall of 100ns for the charging/discharging circuit, so that’s about 200ns absolute minimum per cycle or 1/200ns = 5MHz maximum clock rate). But, for testing purposes this is more than enough. For example if two potentiometers are used for Ra (200K) and Rb (200K) along with 1.0μF cap for C, this gives us a maximum period of
- T = (0.693*(Ra + 2*Rb)*C
- = (0.693*(200K + 2*200K)*1μF = 415ms
Figure 3.75 The 555 timer.
Therefore, the slowest this thing can go is 1/T = 2.4Hz (with these POTs). Of course, the fastest it can go is 5MHz since we can adjust the pots down to near 0 ohms if we wish. However, this gives you an idea of the relationship between the resistor values and the period/frequency of the oscillation. So if you needed a delay of minutes then you are going to need hundreds of μF for the cap and meg ohms for the resistors.
The full datasheet for the 555 can be found on the CD here: