Home > Control Circuits >Timing Circuits > Clock timing circuit schematic diagram

Clock timing circuit schematic diagram

Source: InternetPublisher:走马观花 Updated: 2011/03/21

Timer/counter software programming example We use an actual clock circuit to illustrate the timer software programming method. The clock is our most common timing tool that displays hours, minutes, and seconds, and it is a typical application representative. The minimum timing unit of the clock is seconds, but the microcontroller timer is used for timing. If a 6.0MHz crystal oscillator is used, even if it works in working mode 1, the maximum timing time can only reach 131ms, so we can take each timing time as 125ms, so the timer overflows 8 times (125ms╳8=1000ms) to get the minimum timing unit of seconds. It is easy to implement 8 times counting using software method. We use timer 1 to work in working mode 1, and the timer performs 125ms timing. Use the interrupt method to accumulate the number of overflows. When 8 times are counted, 1 second will be obtained. To accumulate the timing of a clock, multiple bases are used to realize the carry of minutes and hours. The carry of seconds, minutes, and hours is decimal, but the carry of seconds to minutes and the carry of minutes to hours are sexagesimal, and every day There is a twelve-hour clock or a twenty-four-hour clock, which are respectively twelve-hour and twenty-four-hour clocks. From seconds to minutes and from minutes to hours can be achieved through software accumulation and numerical comparison methods. In the internal RAM of the microcontroller, a display buffer needs to be set. The displayed hours, minutes, and seconds are taken from the display buffer. Four units are set in the RAM as display buffers, namely 7AH, 7BH, and 7CH. In order to facilitate the description of the circuit and principle, we do not display the second value here, and we implement the carry of the second by flashing the score. In this way we have a total of four LEDs that display the hours and minutes respectively. At the same time, the clock needs to be calibrated. It is also necessary to set up a display code table in the program. The value to be displayed is sent to the LED for displaying the real code value through a table lookup command. We use the two I/O ports PP3.4 and P3.5 of the microcontroller AT89C2051 to connect external micro switches to realize the correction of hours and minutes. Each time the hour or minute is pressed, the value is incremented by 1. If pressed continuously, the value will accumulate to realize the clock adjustment. calibration. We also set up a buzzer in the circuit for simple time telling. For example, we can set up to wake up at 7:30 in the morning, and then wake up at 1:30 noon. Each buzzer will sound for 1 minute, sound for 1 second, and stop. 2 second mode instead of continuous ringing. We use a 12-hour clock for this program. For this reason, corresponding flags must be set in the program to facilitate identification by the main program. There will also be several related flags in the timing program, mainly to control the direction of the program flow. We have made more detailed comments in the program and will not go into details here. For the hardware circuit, we still use the low-cost AT89C2051 microcontroller as the microprocessing unit. This chip is compatible with the C51 instruction system. Programs written on the C51 can be easily transplanted to this chip without any modification. We use the P0 port as the field bit driver output of the LED. The "carry" of the second uses a flashing prompt of the score, which is on for 0.5 seconds and off for 0.5 seconds. , P3.1-P3.3 are used for bit drive, using dynamic scanning mode for display. The display time of each LED can be between 10-25ms. The scanning frequency cannot be too high, otherwise the display time of each LED will be too short and the brightness will be reduced. If it is too low, it is difficult to see. It is better not to feel the LED flicker with the naked eye. For the sake of intuition, our driver output does not use integrated circuits, but discrete components - transistors, but the working principle is the same. This circuit structure determines that the LED uses a common anode digital tube. The ordinary light-emitting diode LQ5101BS can be used. The driving transistor can use the easily available models such as 2SA1015 and 2SC1815. Of course, low-power models such as S9012, S9013, S9014, 2N5401, 2N5555 can also be used. Transistor, there are no special requirements for other devices. In order to facilitate experiments, the microcontroller AT89C2051 can use the DIP20P socket. After the program is programmed and the debugging is correct, it can be programmed into the AT89C2051. It is worth mentioning that the AT89C2051 is a Falsh program memory, and the program can be erased and written repeatedly. It is suitable for experiments. Very convenient.

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号