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.
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
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- [NXP Rapid IoT Review] + Learning and thinking about hardware schematics
- CircuitPython starts supporting Open Book
- "Play Board" + Shared Bicycle Control Board - Clock Chip PCF8563
- High-performance fully integrated SAR ADC
- Looking back, I realized that EE is so strong - Antenna
- Latest review activity! Free trial of Espressif's RISCV board ESP32-C3-DevKitM-1
- EEWORLD University - The principle and use of oscilloscope
- F12 debugging, no need to worry about the essence watermark being blocked anymore
- Qorvo will meet you in Beijing
- Has anyone used the MS41909 lens driver chip for network cameras and surveillance cameras?