Design of digital stopwatch based on single chip microcomputer

Publisher:数据旅人Latest update time:2012-03-08 Source: 物联网技术 Keywords:MCU Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
Today, computer technology has brought about a major leap in scientific research and production, and the application of microcomputers has penetrated into all aspects of production and life. Single-chip microcomputers are characterized by small size, low price and powerful functions. As their performance continues to improve, their scope of application is becoming wider and wider, and they occupy an important position in the field of computer applications. Stopwatches are used in our lives, work, sports and other aspects that require timing. The digitization of stopwatches has brought great convenience to people's production and life, and has greatly expanded the original functions of stopwatches. It has developed from the initial mechanical stopwatch to the digital stopwatch commonly used today. The timing accuracy of stopwatches is getting higher and higher, the functions are increasing, and the structure is becoming increasingly complex. This paper combines single-chip computers to realize the design of a digital stopwatch based on AT89C52 single-chip microcomputer, and uses Proteus and Keil software to realize simulation.

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.

a.jpg



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.

b.jpg


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.

c.jpg [page]

2.4 Digital tube display circuit
This 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.

d.jpg



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.

e.jpg



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.

Keywords:MCU Reference address:Design of digital stopwatch based on single chip microcomputer

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

Design of digital virtual surround sound controller based on PIC microcontroller
Introduction In the context of the rapid development of smart entertainment technology, consumers have generally hoped to create the sound effects of a home theater. To configure a home theater audio system, a surround sound processor and a high-power AV amplifier are required, and at least 5 or 6 speakers are
[Microcontroller]
Design of digital virtual surround sound controller based on PIC microcontroller
SPI multi-machine loop communication based on AVR microcontroller
SPI communication with one master and three slaves The program is as follows: host://ICC-AVR application builder: 2012-1-13 18:56:57 // Target : M16 // Crystal: 8.0000Mhz // Complete program download: http://www.51hei.com/f/djhltl.rar #include iom16v.h #include macros.h #define Load_High PORTB|=(1 4) #d
[Microcontroller]
SPI multi-machine loop communication based on AVR microcontroller
Temperature measurement solution based on single chip microcomputer
TC74 is a serially accessible digital temperature sensor from Microchip that can collect and convert temperature information from its onboard solid-state sensor with a resolution of 1°C. The temperature is an 8-bit digital word stored in its internal temperature recorder that can be accessed via a 2-wire I2C compatible
[Microcontroller]
Temperature measurement solution based on single chip microcomputer
Basic knowledge of microcontroller pointers
1. What is the pointer of a microcontroller? The microcontroller pointer refers to the memory address of the storage area where a certain variable or data is located. 2. What is the function of the microcontroller pointer? It can effectively represent data structures, dynamically allocate memory, use strings more conv
[Microcontroller]
AVR microcontroller (ATMEGA16) timer program
#include iom16v.h   #include macros.h   #define uchar unsigned char   #define uint unsigned int   #pragma interrupt_handler timer1:9   flying i,temp;   void delay(uint x)   {    uint y,z;    for(y=x;y 0;y--)                    for(z=1111;z 0;z--);   }   void main(void)   {    i=0;    temp=0x01;    TCCR1B=0x04; //T/C1
[Microcontroller]
AVR microcontroller (ATMEGA16) timer program
Design of smart home audio signal analyzer based on DSPIC30F6014A microcontroller
At present, most audio signal processors are not only large in size but also expensive, and are difficult to be popularized in some special aspects. Embedded system analyzers are small and reliable, so the development of audio analysis instruments based on special function microcontrollers is the basis of spee
[Microcontroller]
Design of smart home audio signal analyzer based on DSPIC30F6014A microcontroller
Microcontroller---ESP8266 transplantation lvgl (I)
Preface I really like this LVGL recently. It can make all kinds of fancy interfaces. Just like our major car companies build cars, it is really difficult to improve performance. Sometimes it takes years of accumulation to be 0.1 second faster. But the appearance is different. Just change the drawings and the performan
[Microcontroller]
Microcontroller---ESP8266 transplantation lvgl (I)
STC89C52 MCU timer 1 implements counter
///////////////////////////////////////////////////// ////////////////////////////   Function implementation:  Configure the relevant registers of timer 1 to implement the timer interrupt function, and then implement the counter on the digital   experiment board model: BS-XYD-C52   Experiment name:  Timer 1 Author: 
[Microcontroller]
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号