Home > Articles > Programming > Games

This chapter is from the book

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:

  1. Use a crystal with additional caps and inverters to build a clock circuit.
  2. Use a single oscillator IC that you apply power to and it outputs a clock signal.
  3. Use a programmable timer IC that uses a few passives to set the frequency.
Figure 3.70

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

  • CDROOT:\DATASHEETS\HC49U.pdf
Figure 3.71

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

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

Figure 3.73 Oscillator implementation on experimenter board.

Figure 3.74

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

  • CDROOT:\DATASHEETS\ECS-2100_20Series.pdf

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]

and

  • 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

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:

  • CDROOT:\DATASHEETS\LM555.pdf

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020