Design of adjustable countdown reminder based on PIC16F627 microcontroller

Publisher:QuailLatest update time:2011-05-15 Keywords:PIC16F627 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

This adjustable countdown reminder has the advantages of simple circuit, eye-catching display, accurate timing, easy production, adjustable countdown from 0 to 99 minutes, and convenient use. It is both interesting to produce and practical to use.

1. Hardware Circuit

As shown in Figure 1, the power transformer T1 converts the AC220V mains power into an AC9V AC voltage, which is then rectified by D1~D4, filtered by C4, and stabilized by U2MC7805 (or LM7805) to obtain a 5V DC voltage to power the entire machine.

The main control chip is the PIC16F627 microcontroller, and the source current or sink current of each port can reach 25mA. It can directly drive the LED digital tube without adding an external transistor.

Assume that the RB port of PIC16F627 is output, where RB0~RB6 is used for the segment drive of the digital tube. Since the LG5621BH common anode digital tube is selected, the digital tube can only be lit when RBO~RB6 outputs a low level. The RB7 port is used to control the buzzer, and the transistor Q3 (S8050) is used for driving and amplifying. The buzzer can only sound an alarm when RB7 outputs a high level. Assume that RA0~RA2 is output, where RA0 and RAI are used for the bit drive of the digital tube, and the output is enabled by a low level; RA2 is used for the decimal point drive of the digital tube, and is enabled by a low level. It is used as a timer working indicator. When the timer is working, the decimal point of the digital tube flashes at a frequency of 2s. Assume that RA5, RA4, and RA3 are input ports, and RR4, RR5, and R6 are pull-up resistors of RA5, RA4, and RA3 ports. Key switches S1~S3 are connected to RA5, RA4, and RA3 ports. S1 is the start/alarm release key; S2 is the tens digit preset adjustment key. Press this key once and the tens digit of the timer will decrease by 1. When it decreases to 0, press this key again and the value will return to 9. This cycle will continue; S3 is the timer units digit preset adjustment key. The adjustment method is the same as S2. So far, all ports of the PIC16F627 microcontroller have been used.

Timer function: When the timer is initially powered on, the two-digit digital tube displays 99 and is in standby mode. At this time, if you press the ones-digit timer preset key S3, the ones-digit digital tube display value decreases by 1, and if you press S2, the tens-digit digital tube display value decreases by 1.

S1 is the start/alarm release button. Press S1, the timer enters the working state, and the countdown begins (the timing time is minutes). The timing duration starts from the current display value of the digital tube. During the countdown, the decimal point dp of the digital tube flashes at a frequency of 2s, and the unit digit display value decreases by 1 every minute; the tens digit display value decreases by 1 every 10 minutes. When the digital tube display value decreases to 00, the buzzer starts to alarm after another 60 seconds. During the alarm period, the digital tube always displays 00 until the S1 button is pressed again, the buzzer will stop the alarm, and the digital tube will display the last preset timing time.

During the countdown period, buttons S1 to S3 are shielded and cannot be enabled.

Adjustable countdown reminder www.elecfans.com


2. Programming

1. Program Flow The main program flow is shown in Figure 2 (omitted). The 1-minute timing subroutine flow is shown in Figure 3 (omitted). The digital tube display subroutine flow is shown in Figure 4 (omitted).

2. Key points of program design

(1) This timer uses the PIC16F627 timer module TM10 to create a 50ms timer interrupt, and then uses the register decrement and zero judgment statement "DECFSZ F" to determine whether 20 interrupts have been reached to determine whether the display has reached 1 minute. If it has not reached 1 minute, the current digital value will continue to be displayed. When 1 minute is reached, the current digital value will be reduced by 1 and then displayed for 1 minute... In this way, the value displayed on the ones digit of the digital tube will be reduced by 1 every 1 minute, and the value displayed on the tens digit of the digital tube will be reduced by 1 every 10 minutes, until the display value of the two-digit digital tube is reduced to 00.

(2) How to distinguish between timers In program design, a register flag is used to distinguish between the preset display program and the timer working display program. If the flag is 0, the preset display program is executed; if it is 1, the timer working program is executed.

(3) Key anti-shake problem. Mechanical keys are often connected and disconnected multiple times when they are pressed and released. This program uses software to solve the key anti-shake problem. The specific method is to add a delay program during the process of pressing and releasing the key. Generally, the delay time is about 10ms.

(4) Weekly display table lookup program, using table lookup method to display the digital value of the digital tube can make the software and hardware design more concise and easy to understand. However, in this timer design, the decimal point of the digital tube is used as a "working indicator light", and because the digital tube is lit by "dynamic scanning", this table lookup code is not the same as the other table lookup code, that is, the table lookup code has changed. The code table of the table lookup program used for the common anode digital in this project is on the right.

If the code table values ​​are written upside down, that is, RETLW 0X40 is written at the front and RETLW 0X10 is written at the end, then this timer becomes a "positive" timer.

3. Notes on Programming

When burning the program, be sure to pay attention to the "configuration bit" setting of the programmer, otherwise it may cause problems such as the program not running normally.

Keywords:PIC16F627 Reference address:Design of adjustable countdown reminder based on PIC16F627 microcontroller

Previous article:Hands-free Passive Keyless Entry System Using PIC16F639
Next article:Design and production of digital power supply based on dsPIC30F

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号