Six-digit display multi-channel timing electronic clock made with AT89C2051 single chip microcomputer

Publisher:Ziran520Latest update time:2011-01-28 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

The electronic clock introduced here has a very simple circuit. It only uses a single 20-pin microcontroller to complete all the functions of the electronic clock, while other design schemes that I have seen are implemented by using more than two ICs.
A 20-pin microcontroller STC2032 (the pin arrangement is exactly the same as AT89C2051) is the main body of the electronic clock. Its display stroke data is output from the P1 port in time-sharing, and the P3 port outputs the corresponding six-bit selection signal. Since the LED digital tube consumes a lot of power when it is lit, it cannot be completed with the AT89C2051 single chip, but it can be completed with the STC89C2032. In addition, when making this site, super bright light-emitting diodes are used instead of expensive large digital tubes, which is low cost and has a unique effect.

This electronic clock is designed with three light-touch buttons, which we name as mode setting button K1, plus adjustment button K2, minus adjustment button K3. Since the STC89C2032 has an integrated reset resistor, the reset pin only needs to be connected to a capacitor. This electronic clock uses an NPN transistor and a buzzer as the alarm circuit. This figure is powered by a battery, and there are installation locations for bridge rectification, filtering and three-terminal regulator 7805 on the circuit board, which can use AC voltage to supply the entire system. This electronic clock can work with any 6~12V/100mA AC/DC power adapter and has strong adaptability.

Electronic clock function

1. Running time: The default is running time status, which displays "hour: minute: second" according to the 24-hour system. There are four seconds points dynamically displayed, and the time will change according to the actual time with seconds as the minimum unit.

2. Time adjustment: Press K1 (or K2, K3) for more than two seconds, and one of the hour, minute, and second positions will flash quickly. Press K1 to cycle, and press K2 and K3 to add or subtract the flashing numbers, so as to quickly set the time. If there is no key operation for more than 20 seconds, it will automatically return to normal timekeeping state.

3. Adjust the alarm time: Press K1 (or K2, K3) again for more than two seconds, and one of the hour, minute, and second positions will flash slowly. Press K1 to cycle, and press K2 and K3 to add or subtract the flashing numbers, so as to quickly set the alarm time. When there is no key operation for more than 20 seconds, it will automatically change to the normal timekeeping state.
Note: In the alarm state, the hour position will change from 01 to 64, indicating 64-way timing time; the minute position can only change from 00 to 24, indicating 24 hours, of which the default display is 24, indicating no alarm; the second position changes from 00 to 59, indicating 60 minutes. Therefore, this electronic clock can set multiple alarm times with minutes as the smallest unit. (Since 64 channels are too many, they are basically useless and inconvenient to use, so this site sells 16-way timing.)

4. Error correction status: As we all know, even the best and most authentic quartz crystal oscillator in the world will have frequency deviations, and capacitors are needed to fine-tune the frequency. Different capacitors and loads will affect the frequency deviation. This situation may cause the daily error to reach tens of seconds. Of course, equipped with high-quality genuine components can reduce the travel time error to a few seconds. If you design a fine-tuning capacitor, you can reduce the daily travel time error to less than 1 second.
However, for amateur production, there is no more standard measurement equipment to prove that your debugging is just right. You cannot measure the cycle or frequency (ordinary measurements will change the circuit working parameters and bring greater measurement errors). And we usually compare it with the time of the TV station. After 24 hours, is my electronic clock fast? ? Or slow? ?
Now don't be afraid, this electronic clock is designed with an error correction program: if your electronic clock will be 1.6 seconds faster (or 0.8 seconds slower) in a day, then through the error correction setting of this electronic clock, you can unknowingly slow down by 1.6 seconds (or speed up by 0.8 seconds) in a day. Therefore, the electronic clock can theoretically achieve a daily error of less than 0.2 seconds. Of course, the specific process and effect still need to be operated and proved by everyone.
Error correction method: In the alarm adjustment state, press K1 (or K2, K3) for more than two seconds, the hour position and minute position will become "one one one one" or "three three three three", indicating slowing down or speeding up, press K1 to select; the second position will become 00, and K2 and K3 will change between 00-80. The larger the number, the greater the correction. 00 means no correction to speed up or slow down, such as 2+0=2-0. When there is no key operation for more than 20 seconds, it will automatically change to normal running state.
Other functions:
1. If it is in the running state, when the alarm rings (it will ring for 20 seconds), press any key of K1, K2, K3 to stop the sound.
2. In the running state, press K3 to make the electronic clock emit a short "beep" sound every second, which is a bit similar to the sound of a mechanical pointer electronic clock (or mechanical watch), of course, the sound is much louder. This function is very useful. For example, we cannot look at the clock in some special circumstances, but we can close our eyes and listen to the sound and count the number of seconds in our mind before operating something. Press again to turn off the second sound.
3. Hourly time signal function: Press K2 to turn on and off the hourly time signal function. After turning it on, you will hear a long "beep" sound for two seconds every hour.
4. Alarm switch function: Press K1 to turn on and off the timer alarm function. After turning off the alarm, the previously set data will not be lost.


Since the circuit design is extremely simple, the rich functions can only be completed by software, and software design becomes the key here. The following introduces some key points used in software design.

This electronic clock program only uses one timer number T0, and all other interrupts are turned off. The timer works in two 8-bit automatic loading initial value states. This is an important method to ensure accurate and stable timekeeping. The webmaster has seen that many books and teaching materials ask everyone to use timer interrupts to execute dynamic display programs and key scanning programs. This is a very bad method. In addition to wasting hardware resources, it will increase the complexity of the program and affect the operation of other programs.
The webmaster believes that the shorter the interrupt program, the better. It is best to end it immediately after a few instructions. For dynamic scanning display, key functions, etc., they can be written in the main program to let the program run repeatedly. If there are many interrupts, the biggest disadvantage is that it affects the running time of the main program. The scanning display will flicker, or the key response will slow down (generally imperceptible). However, this has another advantage. You can improve the program at any time and see the results immediately.
The LED dynamic scanning display is to light up each LED in a time-sharing manner, using the visual persistence characteristics of people to make people feel that it is continuously lit. When the lighting frequency is high, it means that the microcontroller has enough time to run the main program.

Reference address:Six-digit display multi-channel timing electronic clock made with AT89C2051 single chip microcomputer

Previous article:Hardware Design of LED Display Screen Based on AT89S52 Single Chip Microcomputer and ATF1508AS Programmable Logic Device
Next article:Application of AT89C51 and nRF401 chips in RFID systems

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

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号