Adjustable countdown reminder made with PIC16F627

Publisher:jiaohe1Latest update time:2010-10-18 Source: 中电网Keywords:PIC16F627 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

The 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, among which RB0~RB6 is used for the segment drive of the digital tube. Because 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 port, among which 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 to reduce the tens digit of the timer by 1. When it reaches 0, press this key again and the value returns to 9. This cycle is repeated; S3 is the ones digit preset adjustment key of the timer. 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; every 10 minutes, the tens digit display value decreases by 1. 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 made with PIC16F627

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 the display has reached 1 minute. If it has not reached 1 minute, continue to display the current digital value. When 1 minute is reached, the current digital value is reduced by 1 and then displayed for 1 minute. In this way, the display value of the digital tube's ones digit is reduced by 1 every 1 minute, and the display value of the digital tube's tens digit is reduced by 1 every 10 minutes, until the display value of the two-digit digital tube is reduced to 00.

(2) How to distinguish the timer 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 connected and disconnected many 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:Adjustable countdown reminder made with PIC16F627

Previous article:Design of AC contactor energy saver based on PIC12F508
Next article:PIC Programming Based on PICC Compilation Environment

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号