Sie sind auf Seite 1von 4

World Academy of Science, Engineering and Technology 42 2008

Development and Implementation of Microcontroller-based Digital Clock


Pan Thu Tun

AbstractElectronic clocks have predominately replaced the


mechanical clocks. They are much reliable, accurate, maintenance free and portable. In general, there are two kinds of electronic clocks. They are analog clock and digital clock. But digital clocks are more common and independent of external source. It would be needed the controlled devices and implementation of software for microcontroller control system because the hardware devices cannot do any desired task to execute. In this paper, the microcontroller-based digital clock is constructed with PIC16F877A and its software program is written with CCS C program language. Various types of digital clocks and modules are available in the market nowadays but this clock is different at least in the accurate time. To be controlling in microcontroller is only the feature of the clock. The input frequency is taken from the 50 Hz clock frequency circuit. To show the time, seven-segment Light Emitting Diodes (LEDs) and four LEDs are used.

observation, aided the development of other machine technologies and brought significant revisions in the way people think about and behave in time. The first public clock that struck the hours was made and exerted in Milan in 1335. The oldest servicing clock in England is that at Salisbury Cathedral, which dates from 1386. About 1500 Peter Henlin, a German locksmith, began to made small clock driven by a spring.

KeywordsActuate Time, CCS C Program Language, Electronic Clocks, Mechanical Clocks, Microcontroller.
I.

INTRODUCTION

IME is such a fundamental concept that it is very difficult to define. To measure time is needed something that will repeat itself at regular intervals. The number of intervals counted gives a quantitative measure of the duration. The earliest references for the measurement of the time are the moon and sun. When the sun and the moon were not visible, it was impossible to know the exact time. So, clocks were developed to measure out the hours between checks with the sun and the moon. The process of measuring time has progressively become more accurate, and the devices more localized ever since. In our modern time, the time is predominately measured by mechanical, and recently by electronic clocks. All clocks measure time, but different clocks can have status or importance. Many centuries have been spent devising method for the determination and measurement of time. Historically, clocks and watches of all sorts lie at an important crossroads of science, technology and society. Changes in timekeeping technology have influenced the character of scientific

Fig. 1 Block diagram of the system

The first electronic clock is quartz clock. It is made with a piece of quartz like liquid crystals which eventually composed watch displays. Quartz vibrates equally at thousands of times a second when subjected to an electrical current. Electronic clock at those vibrations divides then down to minute, second and fraction of seconds to show time on the dial or display. Quartz clocks provide more accurate than any mechanical timekeeper. In this paper, the more accurate clock using microcontroller is presented. II. DESIGN CONSIDERATION FOR SOFTWARE IMPLEMENTATION In the software implementation process, initialization processing, LED display processing, time adjustment processing and time signal processing are considered.

Manuscript received May 31, 2008. This work was supported in part by the Ministry of Science and Technology, Union of Myanmar. Pan Thu Tun is with the Mandalay Technological University, Mandalay, Myanmar. Contact Phone: 095-2-88704(Electronic Engineering Department), Fax: 095-2-88702( Office,MTU) (e-mail: panthutun@gmail.com).

362

World Academy of Science, Engineering and Technology 42 2008

In LED display process, one digit is controlled in the one millisecond interval. LED is turned off first to prevent an afterimage. The processing of tens of hour is rather complicated. In the time adjustment processing, the first fact to notice is whether or not the selected LED is on. If it is to increase the time, it will turn the switch clockwise and the switch would be counter clockwise if it is to decrease. In the time signal processing which counts up a clock, every units of hour are renewed if the checking of a time signal is done.

Fig. 2 Flowchart of the initialization processing

First, the required mode is initialized. In this process, RA, RB and RC ports are defined with the appropriate input or output mode. The RA port combines analog input and digital input or output. RA port is used as the digital input or output mode. RB1 port is used for the time signal control and other RBs are used for the inputs. The RC port is used for the LED control.

Fig. 3 Flowchart of the interrupt

Fig. 5 Flowchart of time adjustment


III.

OPERATION OF THE SYSTEM

Fig. 4 Flowchart of LED display

Clock input circuit which generates 50 Hz is connected with the RB0 port of PIC. The RB0 port can make have the function to do interruption in the change of the input signal. This time, it detects the rising edge of the input signal and the interruption occurs. It counts this interruption fifty times and recognizes one second. 4 MHz resonator is used for the operation clock oscillation by PIC. The precision of this oscillation frequency doesn't influence the precision of the clock. The precision of the clock is decided by the precision of the frequency which is inputted to RB0. Because it doesn't need the high-speed operation of PIC at the circuit this time, 4 MHz is used. In this circuit, the appropriate program and voltages are used to operate the whole circuit. For digit display, six seven-segment LEDs to show the hours, minutes and seconds, two LEDs to separate the minute and hour and another two LEDs to separate before noon (AM) and after noon (PM) are used.

363

World Academy of Science, Engineering and Technology 42 2008

The ten seven-segment LEDs are common anode. The specification of the display position is controlled by the binary signal which is output from RA0, RA1 and RA2 port of PIC. This signal is decoded in three-eight decoder (CD4028) and eight kinds of signals are made. This time, six kinds are used. Only the transistor which corresponds to the low level decoder output becomes ON condition. The LED which is connected with the transistor becomes lighting-up possible condition.

Segments of the lighting-up of each digit are controlled using seven ports of RC6 from RC0 of PIC. The output of these ports is common to all the LEDs. The LED lights up when the RC port is low level. The brightness of the LED depends on the kind of the LED. When the brightness is different extremely, the resistors which are connected with the RC ports should be separated.

Fig. 6 Circuit diagram for digital clock

IV. CONCLUSION AND FURTHER EXTENSIONS In this paper, the microcontroller-based digital clock is mainly controlled by the clock pulse frequency. The clock pulse frequency can be generated by using the IC1 555. The clock pulse frequency can be obtained from other methods such as the power line frequency and the internal oscillator IC with RC circuit and so on. The power line frequency will not get more accuracy than the quartz crystal. The 555-timer astable mode can be used for this purpose. In the display, there are needed to give the outputs of seconds, minutes and hours and AM/PM. In this display system, the output of PIC is connected with the input of decoder (CD4028) to drive the seven-segment LEDs. The decoder (CD4028) has four inputs and ten outputs. But, in this circuit three inputs and six outputs are used. So, one input pin is grounded and four outputs pins are not used. In the music section which generates the time, the output frequency is nearly 600 Hz. In the electronic circuits, the audio

range is between 20 Hz and 20 kHz. So, 600 Hz is the suitable output frequency. This paper can be extended to cover electronic fields and would like to be a little support for other researchers in the field of electronics. Some further extensions performances which can also be carried out are described as follows. The microcontroller-based digital clock can be provided with the date, month and year circuits. The output of day indicator can be shown by connecting with the output pins of CD4028, pin seven and eight. But the required instructions are added to the existing program. If the month indicator is wanted to show, the remaining input pin, pin D is connected with the output pin of PIC, RA3 and then to drive the seven-segment LEDs output pins of CD4028, pin zero and nine are used. Furthermore, the year indicator is wanted to add, the decoder must be changed. Because CD4028 has only ten outputs, it is not sufficient to show the year indicator. So four-sixteen decoder (74HC154) should be used instead of CD4028.

364

World Academy of Science, Engineering and Technology 42 2008

The circuit can provide with another alarm circuit. The existing alarm circuit is simple 555-timer circuit and it will ring the alarm at every hour. If the alarm is wanted to ring at the specified time, the program is rewritten. Moreover, the pleasant song can be heard by using the melody ICs. V. EXPERIMENTAL RESULTS The experimental results of this system are shown in Fig. 7 and Fig. 8.

Bolyestand, R. Electronic Devices and Circuit Theory. 5th ed. Printed by Prentice-Hall, Inc. [5] Iovine, J. 2002. PIC Microcontroller Project Book. Printed by Mc Graw-Hill. [6] U Maung Maung Myat. 2001. Electronic Professionals, Volume 2. [7] Tyyer, S. B. 1995. Programmable Digital Clock, Electronic Project Volume 16. [8] Microchip. No Date. Data Sheet of PIC16F873 28/40-Pin 8-bit CMOS FLASH microcontroller. <http://www.microchip.com>. [9] Inoue, S. Digital Clock, PIC Circuit Gallery. October 2005. <http://www.hobby.com>. [10] Nigel Gardner. An Introduction to Programming the microchip PIC in CCS.

[4]

Fig. 7 Top view photograph of digital clock

Pan Thu Tun was born in 1982, April 1. Graduated in August, 2004 with B.E (Electronic) and finished Master degree on March, 2006 with M.E (Electronic). Now, he is a PhD Candidate of Electronic Engineering Department, MTU, Myanmar. He served as a Demonstrator at Mandalay GTC from January, 2001 to January, 2004 when he was attending the Special Engineering Course in MTU. From 4, Novenber, 2004 to 31, March, 2008, he promoted as an Assistant Lecturer of Mandalay Technological University and from 1, April, 2008 to now, he promoted as a lecturer, Department of Technical and Vocational Education, Myanmar. For his Master Thesis, he wrote the results of his research Design and Construction of microcontroller-based Digital Clock. Now, he is making his PhD research at Mandalay Technological University (MTU), Myanmar with the title of Development of Wireless Remote Control for Take-off and Landing System in UAV. Mr. Pan Thu Tun made his first publication of International Paper at this paper Development and Implementation of Microcontroller based Digital Clock.

Fig. 8 Front view photograph of digital clock

ACKNOWLEDGMENT Firstly the author would like to thank his parents: U Kyaw Yin and Daw Mya Sein for their best wishes to join the PhD research. Special thanks are due to his Supervisor/ Head of Electronic Engineering Department, MTU, Myanmar: Dr. Yin Mon Myint. The author would like to express his thank to his friends. The author greatly expresses his thanks to all persons whom will concern to support in preparing this paper. REFERENCES
[1] [2] [3] Predko, M. 2001. Programming and Customizing PIC Microcontrollers, 2nd ed. Printed by Prentice-Hall, Inc. Penfold, R. A. 1997. An Introduction to PIC Microcontrollers. 1st ed. Printed by BERNARD BABANI (publishing) LDT. Microchip. 2001. PIC16F873 Data Sheet. Printed by Microchip Technology, Inc in the United States of America.

365

Das könnte Ihnen auch gefallen