Design of single chip microcomputer timing counter circuit

Publisher:SerendipityJoyLatest update time:2011-08-25 Source: EEWORLD Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

If you have a timer that reminds you when the time you set is up, you no longer have to worry about forgetting to cook on the gas stove, causing the food to burn or the water to dry up, or taking a nap too long. This article introduces a countdown timer made with the AT89C205l microcontroller. The timer can be set from 1 to 99 minutes. When the time is up, it will use a beep alarm to remind you, and the remaining time will be displayed with a digital tube during the timing process.

Circuit working principle:

Countdown Timer The circuit is shown in the figure. The circuit consists of a single-chip microcomputer circuit, a digital display circuit and an alarm circuit.

AT89C2051, X1, R1, C1 and other components constitute the single-chip microcomputer circuit. Rl and C1 constitute the reset circuit of the single-chip microcomputer. At the moment the power is turned on, due to the charging process of C1 by the power voltage, the reset terminal 1 pin of the single-chip microcomputer AT89C2051 obtains a high-level reset pulse, making the single-chip microcomputer enter the initial state.

The digital tubes DS1, DS2, transistors VT2, VT3, resistors R3~R11, etc. form a digital display circuit. Two digital tubes display minutes and tenths respectively. Since each digital tube has seven stroke segment AG display units (the decimal point DP is not used here), the conventional driving method requires 7×2=14 I/O lines, which is obviously not enough for AT89C2051. Therefore, the dynamic scanning display method is used here to solve this problem, which only requires 7+2=9 I/O lines. Dynamic scanning display is to connect the same-named ends of the seven stroke segments A~G of the two digital tubes together, and the common end COM of each digital tube is independently controlled by the I/0 line. When AT89C2051 sends the font code to the font output port, all digital tubes receive the same font code, but which bit is displayed depends on the COM end, and the COM end is controlled by P3.5 and P3.7 ports. P3.5 and P3.7 ports use a time-sharing method to control the COM ends of the two digital tubes in turn through VT2 and VT3, so that the two digital tubes light up in turn. Since the P1 port of AT89C2051 can inject a large current, a common anode digital tube is used here.

In the process of scanning by turns, the lighting time of each digital tube is very short. Due to the phenomenon of human visual persistence, although the digital tubes are not actually lit at the same time, the impression given is that it is a set of stable display data without flickering.

The light-emitting diode VD1 indicates the working status. It flashes during the timing period and does not display during the rest of the time. VT1, R2, sp1, etc. form an alarm circuit, which sounds an alarm when the timing ends.

Buttons s1 and s2 are timing time setting buttons. S1 sets the minute position, and S2 sets the tenth position. The minute position and tenth position are set separately. Press the corresponding button, and the number displayed on the corresponding digital tube will change accordingly. Button s3 is the timing start button. After setting the timing time, press s3 to start the timer and enter the countdown. When the timing time is reached, an alarm sound is issued, and the digital tube displays the time as 0HD. The alarm and display are alternately performed for 0.25 seconds each, and the duration is 60 seconds. If you want to end the alarm in advance, just press s3. After the alarm ends, the circuit returns to the initial state. At this time, the timing time displayed is the time set last time. This is very convenient for occasions where the same timing time is used repeatedly, such as being used as an English oral test timer.
The main program flow chart is shown in the figure. The program is written in assembly language. The program consists of modules such as the main program, timing interrupt subroutine, digital display subroutine, and delay subroutine. The main program consists of keyboard processing, alarm and other parts.

Due to the dynamic scanning display method, although the circuit is simplified and the IO line is saved, it takes up more CPU time, so it is necessary to use the method of calling the timer interrupt to reduce the CPU burden. The timer timing is 60ms, and calling 1000 times is 1 minute. The delay subroutine is mainly used for display subroutine and alarm program to call, and the delay time is 0.5ms. The delay time determines the refresh frequency of the digital display and the audio frequency of the alarm, both of which are 1000Hz.

The output of the glyph code uses P1.1~P1.7 of the port, P1.0 is empty, and the data output by port P1 is obtained by looking up the table. The corresponding relationship between the data bit and the glyph is shown in the attached table. Because the digital tube is a common positive type, the pen segment is bright when the corresponding output bit is 0. The memory units 20h and 21h are used as the storage units of the quantile and tenth digits respectively, and their values ​​are used as the address values ​​of the table lookup. In the table, P1.0 is empty, and its value is 1.

The dynamic scanning display is completed by the digital display subroutine. When the quantile is sent to the P1 port, P3.5 outputs a low level, vT3 is turned on, and the digital tube DS2 displays the quantile; when the tenth digit is sent to the P1 port, P3.7 outputs a low level, vT2 is turned on, and the digital tube displays the tenth digit. In this way, the two-digit time can be displayed by taking turns. Due to the use of the dynamic scanning display method, the digital display subroutine must also be called in time-sharing in the keyboard processing, alarm and other parts of the main program. Only in this way can the digital time be displayed correctly for operation.
The printed circuit board uses a universal circuit board, ICl uses an AT89C2051 microcontroller, a 12MHz quartz crystal, D1 and D2 use common anode LED digital tubes, and a passive electromagnetic buzzer with an impedance of 16Ω. The parameters of the remaining components are shown in the first page.

Before installation, compile the assembly source program into the target file, i.e., the HEX file, and then use the programmer to write the HEX file into the AT89C205 1 chip.

When setting the timing time, press s1 or s2 once to increase the corresponding digit by 1. When it reaches 9, press it again to return to 0. If you do not release it after pressing it, the digits will continue to flip, jumping one number every 0.2 seconds. Release it when it reaches the number you need.

Note: The initial value of the timing time after power-on is 00. You can modify the program to adjust this initial value as needed. For example, if you want to adjust the initial value to 45 minutes, you only need to modify the 9th and 10th lines of the program to mov 20h, #5h and mov 21h, #4h.

Reference address:Design of single chip microcomputer timing counter circuit

Previous article:Design of Sine Wave Output Inverter
Next article:Application of ICL7135 and PIC microcontroller in temperature transmitter

Latest Industrial Control Articles
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号