Schematic diagram of microcontroller clock circuit
The following uses an actual clock circuit to illustrate the software programming method of the timer. The clock is the most common timing tool that displays hours, minutes, and seconds as units. It is a typical application representative. The
minimum timing unit of the clock is seconds, but if a single-chip 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 that the timer overflows 8 times (125ms╳8=1000ms) to get the minimum timing unit of seconds. It is easy to achieve 8 counts using software methods.
Timer 1 is used in the circuit, working in working mode 1, and the timer performs 125ms timing. Use the interrupt method to
The number of overflows accumulates, and when it reaches 8 times, 1 second is obtained.
To realize the carry of minutes and hours in the accumulation of a clock, multiple bases are used. The carry of seconds, minutes and hours is in decimal, while the carry of seconds to minutes and the carry of minutes to hours are in sexagesimal. There is a twelve-hour system or a twenty-four-hour system every day, which are duodecimal and twentieth-century respectively. From seconds to minutes and from minutes to hours can be realized by software accumulation and numerical comparison methods.
In the internal RAM of the single-chip microcomputer, a display buffer needs to be set. The displayed hour, minute and second values 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, the second value is not displayed here. The carry of seconds is realized by flashing the minute value. In this way, there are four LEDs to display the hour and minute values respectively. At the same time, the clock needs to be calibrated. In the program, a display code table needs to be set. The value to be displayed sends the real code value for display to the LED through the table lookup instruction. In the circuit, the micro switches of P3.4 and P3.5 of the single-chip microcomputer AT89C2051 are connected to realize the correction of hours and minutes. Each time the hour or minute value is pressed, 1 is added. The value is accumulated by pressing it continuously to realize the calibration of the clock.
A buzzer is also set in the circuit for simple time reporting. For example, it can be set to get up at 7:30 in the morning and get up at 1:30 in the afternoon. Each time it rings for 1 minute, 1 second, and stops for 2 seconds, instead of ringing continuously. This program uses the 12-hour system. For this reason, the corresponding flags should be set in the program to facilitate the recognition of the main program. There are also several related flags in the timing program, which mainly control the direction of the program flow. The program has made detailed comments, which will not be repeated here (see Appendix).
In Figure 5, the hardware circuit still uses the low-cost AT89C2051 microcontroller as the microprocessor 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.
As the field bit drive output of LED, the "carry" of the second uses the fractional value flashing prompt, which is on for 0.5 seconds and off for 0.5 seconds. P3.1-P3.3 is used for bit drive, and the display is displayed in a dynamic scanning mode. 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 is too short and the brightness is too low, which is not easy to watch. It is better to make the naked eye not feel the LED flickering. For the sake of intuitiveness, the drive output does not use integrated circuits, but uses discrete components-transistors, but the working principle is the same.
This circuit structure determines that the LED uses a common anode digital tube, which can use LQ5101BS ordinary light-emitting diodes, and the driving transistor can use the easily available 2SA1015 and 2SC1815 models. Of course, low-power transistors such as S9012, S9013, S9014, 2N5401, 2N5555 can also be used. There are no special requirements for other devices. To facilitate the experiment, the single-chip microcomputer AT89C2051 can use a DIP20P socket. After the program is compiled and debugged, it can be burned into the AT89C2051. It is worth mentioning that the AT89C2051 is a Falsh program memory, and the program can be erased and written repeatedly, which is very convenient for experiments.
Previous article:Other extinguishing super regenerative receiving circuit
Next article:RF Input Stage Circuit
Recommended ReadingLatest update time:2024-11-16 15:35
- Popular Resources
- Popular amplifiers
- Wireless Sensor Network Technology and Applications (Edited by Mou Si, Yin Hong, and Su Xing)
- Modern Electronic Technology Training Course (Edited by Yao Youfeng)
- Modern arc welding power supply and its control
- Small AC Servo Motor Control Circuit Design (by Masaru Ishijima; translated by Xue Liang and Zhu Jianjun, by Masaru Ishijima, Xue Liang, and Zhu Jianjun)
- High signal-to-noise ratio MEMS microphone drives artificial intelligence interaction
- Advantages of using a differential-to-single-ended RF amplifier in a transmit signal chain design
- ON Semiconductor CEO Appears at Munich Electronica Show and Launches Treo Platform
- ON Semiconductor Launches Industry-Leading Analog and Mixed-Signal Platform
- Analog Devices ADAQ7767-1 μModule DAQ Solution for Rapid Development of Precision Data Acquisition Systems Now Available at Mouser
- Domestic high-precision, high-speed ADC chips are on the rise
- Microcontrollers that combine Hi-Fi, intelligence and USB multi-channel features – ushering in a new era of digital audio
- Using capacitive PGA, Naxin Micro launches high-precision multi-channel 24/16-bit Δ-Σ ADC
- Fully Differential Amplifier Provides High Voltage, Low Noise Signals for Precision Data Acquisition Signal Chain
- 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
- How Tiny Data Converters Give You More Value in Smaller Size
- Industrial waste gas monitoring system based on ZigBee wireless sensor network
- Electric energy measurement solution based on C2000 built-in 12-bit ADC
- I am engaged in car audio products and would like to know how to prevent piracy of new products. Is there any good method?
- "Smart eyes" to identify Tektronix PCIe: Electronic engineers are happy to see the verification code 12306
- Use 0-3.3v PWM signal to generate 0--15v negative pulse
- DSP emulator driver installation error caused by the error and processing
- Capacitor step-down power supply principle and precautions
- Answer a question and win a Kindle: Learn about ADI's grid management and energy metering solutions and complete smart grid projects
- Does anyone know if there is a sensor that can detect the distance of the workpiece (the workpiece is aluminum alloy)?