1 System design plan
1.1 System design requirements
(1) The maximum value of the stopwatch is 59 minutes and 59.99 seconds.
(2) The stopwatch is displayed by a six-digit seven-segment LED digital tube, where the upper two digits display "minutes", the middle two digits display "seconds", and the lower two digits display "0.01" seconds.
(3) The stopwatch has the functions of timing, pausing, and clearing.
(4) Three function keys are set: key 1 starts timing, key 2 pauses timing, and key 3 clears timing.
1.2 Overall design
The digital stopwatch system mainly displays the timing in real time with an accuracy of 0.01s, and can pause or clear the current timing through the function keys. The system mainly includes a clock circuit, a reset circuit, a key circuit, and a digital tube display circuit.
The system uses six common anode digital tubes, of which the eight-bit data port is connected to the P0 port of the microcontroller through a 74LS245 bidirectional bus transceiver to increase the driving capacity of P0. The six chip select signals are connected to the lower six bits of the P2 port of the microcontroller. The circuit can meet the display of the timing time, with the minimum display unit of 0.01s. If the overflow occurs, the position is carried forward, and the display time range is 0 to 59 minutes and 59.99 seconds. The three function keys are connected to the lower three bits of the P3 port to control the timing, pausing, and clearing of the system. The overall composition block diagram of the system is shown in Figure 1.
2 Hardware Circuit Design
2.1 Selection of Single Chip Microcomputer
Since this system only needs a single chip microcomputer to complete the display of timing and process the interrupt of timing/counting, and there is no special requirement for I/O resources and processing speed, the AT89C52 single chip microcomputer produced by Atmel is selected. AT89C52 adds online debugging function. The program can be downloaded, debugged and solidified through the JTAG interface. It can realize real-time simulation and online programming or in-system programming, and has the function of upgrading and maintenance through the network.
Compared with the MSC-51 series single chip microcomputer, there are two major advantages: (1) The on-chip program memory uses flash memory, which makes it easy to write programs and can be erased and written 1000 times at will, making development more convenient. (2) It provides a smaller chip, making the entire hardware circuit smaller. This design uses the MSC-51 series 89C52 single chip microcomputer, which has program encryption function and is inexpensive and economical.
2.2 Clock Circuit
The time base of the single chip microcomputer is provided by the clock circuit. Connecting a crystal oscillator and two capacitors to the XTAL1 and XTAL2 pins of the microcontroller constitutes the clock circuit of the microcontroller. The clock circuit is shown in Figure 2. In the circuit, capacitors C1 and C2 have a fine-tuning effect on the oscillation frequency. Usually (30±10)pF is used. This design uses 30pF. The pin oscillator in the circuit uses a quartz crystal oscillator, and the crystal oscillator frequency is selected to be 12MHz. The quartz crystal oscillator has very good frequency stability and the ability to resist external interference. The accuracy of the frequency in the circuit is controlled by the reference frequency.
2.3 Reset Circuit
Resetting the microcontroller is to put the CPU and other functional components in the system in a certain initial state and start working from this state. It must be reset when the microcontroller is first connected to the power supply, or after power failure or failure. The reset signal of the 89 series microcontroller is input from the RST pin to the Schmitt trigger of the chip. When the system is in normal working state and the oscillator is stable, if the RST pin has a high level and maintains 2 machine cycles (24 oscillation cycles), the CPU can respond and reset the system. Reset is divided into manual reset and power-on reset. The system reset circuit is shown in Figure 3.
[page]
2.4 Digital tube display circuitThis system uses 6 common anode digital tubes. Designing LED display driver is a very important issue. The display circuit consists of LED display, segment drive circuit and bit drive circuit. Since the parallel port drive current of the single-chip microcomputer is too small to directly drive the LED display, the segment drive circuit connects the P0 port to the eight segments of the digital tube through the 74LS245 bidirectional bus transceiver, which can increase the driving capacity of P0. The bit drive circuit drives the lower six bits of the P2 port as the bit selection signal through six NPN transistors to generate a large enough current to drive the LED to achieve sufficient brightness, so that the display can work normally. If the drive circuit capacity is poor, that is, the drive current is too small, the digital tube display brightness is not enough, and the drive circuit drive current is too large to easily damage the digital tube.
There are two display control modes for LED displays: static and dynamic. This design scheme chooses the dynamic control mode. Since the display of one bit of data is completed by the cooperation of the segment code and the bit code signal, the drive capacity of the segment and the bit should be considered at the same time, and the drive capacity of the segment determines the drive capacity of the bit.
2.5 Key Circuit
This system has three function keys, namely KEY1, KEY2 and KEY3. KEY1 is the start key, connected to P3.0. When pressed, the digital tube starts timing; KEY2 is the stop key, connected to P3.1. When pressed, the digital tube stops timing; KEY3 is the reset key, connected to P3.2. When pressed, all digital tubes are reset. When the digital tube is timing, you cannot press the reset key directly. You can only press the stop key to stop. Press the reset key again to initialize all displays to 0.
3 System Software Design
The system software consists of the main program module, delay module, keyboard scanning program module and digital tube driver module.
In this design, the timing is completed by the timer T0 interrupt, and the other states call the display subroutine in a loop. When the function key is pressed, it enters the corresponding function program. The main program flow chart is shown in Figure 4.
4 Simulation results
The program was written in Keil uVision3 environment. After compilation, the generated .hex file can be loaded into Proteus and run normally. Before the program is run, the initial value of the digital tube display is 0000.0 0. Pressing key KEY1, the system starts timing, and the program enters a timer interrupt every 0.01s. During the program running, if key KEY2 is pressed, the system pauses timing, and the digital tube displays the timing end state; if key KEY3 is pressed, the digital tube is cleared. Figure 5 shows the state of key KEY1 being lifted and key KEY2 being pressed.
5 Conclusion
This paper uses the AT89C52 single-chip microcomputer to design a digital stopwatch with the functions of timing start, pause and reset. The maximum timing value is 59 minutes and 59.99 seconds, and the timing accuracy is 0.01 seconds. Proteus and Keil software were used for simulation, and the expected effect was achieved. The overall circuit has high timing accuracy, simple circuit structure, strong anti-interference ability, and has broad application prospects.
Previous article:Development of a single-chip telephone tester
Next article:Development of CAN bus distributed measurement and control system based on single chip microcomputer
Recommended ReadingLatest update time:2024-11-17 03:02
- 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)
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!
- Rambus Launches Industry's First HBM 4 Controller IP: What Are the Technical Details Behind It?
- 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
- Open Source Tutorial | Design of Smart Ecological Fish Tank
- Please tell me what type of inductor this is
- Feedback coefficient expression calculation
- I am a newcomer to the switching power supply industry and need to learn how to calculate the counter-transformer. Do you have any good experience or t...
- Elimination of low frequency signals
- Where can I find the German patent number?
- EK140 Burning Guide
- Two small questions about the lithium battery charging chip bq2407x
- Operating System Timeline and Family Tree
- Report Summary: Silicon Labs Development Kit Review