Application of light touch switch circuit in AVR microcontroller

Publisher:快乐旅行Latest update time:2006-12-11 Source: 单片机及嵌入式系统应用Keywords:MCU  resistance Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
Introduction:

Single-key switch circuits have been widely used in digital products such as PDAs, mobile phones, and electronic dictionaries, and their implementation methods are diverse. Generally, RS flip-flops, counters, 555 integrated circuits, etc. can be used. In some practical applications of microcontrollers, the above implementation methods will increase the complexity of the entire circuit and cannot achieve simple and practical effects. This article will introduce a simple and stable light-touch single-key switch circuit that can be implemented in microcontroller applications.

1 The circuit principle

is shown in Figure 1. DC-DC is a DC regulated power supply chip with a shutdown control terminal, and MCU is a single-chip microcomputer. When S1 is pressed, Q1 and D1 are turned on, and the voltage regulator chip works to power the microcontroller. The microcontroller immediately sets the corresponding I/O pin to output high. At this time, Q1 and Q2 are turned on, and the entire circuit enters the working state. Then the microcontroller sets this I/O pin as an input. Due to the presence of pull-up resistor R4, Q1 and Q2 are always turned on. The microcontroller keeps scanning the corresponding I/O input status. If S1 is not pressed, this I/O will always be high. When S1 is pressed again, D2 is turned on, and the microcontroller detects that the I/O pin input is low. At this time, the microcontroller sets the I/O to a low output state. Q2 is cut off. If the button is lifted, Q1 will also be cut off. The voltage regulator chip will not provide voltage to the microcontroller, and the entire circuit will be in a shutdown state.

2 Regarding the values ​​of R3 and pull-up resistor R4

, some microcontrollers, such as the AVR series microcontroller ATmega8L, have an internal pull-up resistor Rpu, as shown in Figure 2.

Whether the resistor is pulled up or not can be controlled by the microcontroller program, thus eliminating the need for an external pull-up.

Under normal circumstances, the value of R3 should be much larger than R4, otherwise the input voltage Vpin of the microcontroller I/O may be lower than the lowest value of the standard input voltage VIH. From the ATmega8L data sheet, we found that the value of Rpu is between 20kΩ and 100kΩ, and the minimum value of VIH is about 0.6VCC. Therefore, R3/(R3+R4)>0.6, take R4=50kΩ, and take R3/(R3+R4)=0.8, so the value of R3 should be in the range of about 200kΩ. You can choose the specific value of R4 according to the actual working situation. value.

3. Processing of Vin connection method

It is not difficult to see from Figure 1 that after adopting this control method, Q1 will consume a certain amount of power. One way to reduce power consumption is to connect Vin directly to the battery , which can be flexibly controlled according to the circuit.

4. The role of capacitor C1.

For general AVR microcontrollers, there is a BOD (Brown-down Detection) circuit inside. This circuit has a low voltage detection function: when the input voltage changes from high to low, the microcontroller will automatically reset.

As shown in Figure 1, when you want to shut down, press S1, and the output of the microcontroller is low. After the button is lifted, Q1 and Q2 are cut off and the microcontroller is powered off. However, after the BOD circuit of the microcontroller detects that the voltage of the microcontroller suddenly drops, it will reset the microcontroller and set the I/O to the pull-up state. Q1 and Q2 are turned on, and the conduction circuit is turned on again.

After adding C1, C1 needs to be charged after the microcontroller is powered off. However, while C1 charging does not reach the minimum operating voltage of the microcontroller, Q1 and Q2 have been cut off, thus disrupting the reset operation of the microcontroller.

5. Delay processing of power on and off.

In some specific applications, such as mobile phones and other digital products, a delay operation is required for power on and off. A simple implementation is for the microcontroller to start counting when the button is pressed until the button is lifted. Only when this count value is large enough can the computer be turned on, otherwise it will not be considered a power-on operation. In the same way, similar processing can be done when shutting down.

The program flow of the microcontroller is shown in Figure 3.

Reference
1 http://www.goldenchips.com/
2 Atmel Atmega8 datasheet, 2003-09 ( end )
Keywords:MCU  resistance Reference address:Application of light touch switch circuit in AVR microcontroller

Previous article:RTOS-AVRX application of AVR microcontroller
Next article:Application of light touch switch circuit in AVR microcontroller

Recommended ReadingLatest update time:2024-11-16 17:34

8-bit resolution ADC inside Songhan MCU
;Purpose: To learn the internal 8-bit resolution ADC and data processing ;Full code download: http://www.51hei.com/f/shrad.rar  CHIP SN8F27E65 //{{SONIX_CODE_OPTION  .Code_Option WDT_CLK Flosc/4  .Code_Option Reset_Pin P04  .Code_Option LVD LVD_Max ; 3.3V Reset  .Code_Option Watch_Dog Disable ;Turn off watchdog  .Co
[Microcontroller]
C51 single chip microcomputer driving liquid crystal chip
192*64 LCD driver program written by Keil C51. Thanks to many netizens for providing reference source programs. This program is adapted based on the programs provided by netizens. There are many places that have received the patience of experts. Thank you very much for your guidance. This is a complete C51 source
[Microcontroller]
MCU crash cause check, Crash dump stack backtrace technology can easily solve
       If you are using MCU for development, as the functions and codes increase in the later stages of the project, crashes seem to be inevitable. Whenever you encounter this problem, you usually need to use an emulator to locate code defects, but if you encounter a problem that is very difficult to reproduce, or the
[Microcontroller]
MCU crash cause check, Crash dump stack backtrace technology can easily solve
Design of digital control switching power supply based on single chip microcomputer
  introduction   In real life and experiments, various power supplies are often used with various voltage requirements. How to design a voltage source with stable voltage, high output voltage accuracy and large adjustment range has become a hot spot in the application of electronic technology. On the market, there ar
[Microcontroller]
Design of digital control switching power supply based on single chip microcomputer
Vector Measurement and Power Calculation of Least Squares Filter in Single Chip Microcomputer
At present, digital electrical measurement and protection devices based on single-chip microcomputers have become the mainstream form. Direct sampling of AC signals has also become a common method. Fast Fourier algorithm is the main algorithm, while the least squares algorithm has a large amount of calculation. Espe
[Microcontroller]
Vector Measurement and Power Calculation of Least Squares Filter in Single Chip Microcomputer
stm8s003MCU_PWM_pin function configuration
I am currently developing an LED light product using the stm8s003 MCU. I am using the PWM output function of TIM2, using TIM2_CHANNEL3, and the PA3 pin is multiplexed as TIM2_CH3. 1. How to reuse the PA3 pin as TIM2_CH3 The pin multiplexing function of stm8MCU is not like the NXP MCU or 51MCU I have used before. The
[Microcontroller]
51 microcontroller timer initialization setting process
The timer/counter of the 51 microcontroller is a programmable component. Its working mode, initial counting value and start and stop operations should be initialized before the timer/counter works, that is, writing the corresponding control word to the corresponding register. There are two timers, T0 and T1, inside
[Microcontroller]
51 microcontroller timer initialization setting process
Microcontroller literacy: the relationship between MCS51 and 8051/8031, etc.
We always talk about 8051, 8031, and now there is 89C51 and 89s51. What is the relationship between them? MCS51 refers to the general name of a series of single- chip microcomputers produced by the American INTEL company (yes, the famous INTEL) . This series of single-chip microcomputers includes many varieties, su
[Power Management]
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号