Application of light touch switch circuit in AVR microcontroller

Publisher:camuspycLatest 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:P87LPC767 microcontroller and its application in micro-power intelligent positioner
Next article:The principle and application of dsPIC30F6010 microcontroller

Recommended ReadingLatest update time:2024-11-16 23:51

Debugging of 24c02 based on PIC microcontroller is completed
Suitable for PIC series, assembly, memory tight friends SDA EQU 5 ;'OC' SCL      EQU    4 ACKF     EQU    0 EE_VCC  EQU   2 EE_WP   EQU   1       ;'H' DISABLE 'L'ENABLE DO    EQU 7 TX_BUF    EQU 0X30 BUF_IN    EQU 0X31 EEPROM    EQU 0X32 BIT_COUNT  EQU 0X33 byte_count equ 0x34  ACK     EQU 0X35 rom_buf1  equ 0x36 rom_
[Microcontroller]
PIC24FV16KM204 Series General Purpose 16-bit Flash MCU Data Sheet
The PIC24FV16KM204 family of devices introduces many new analog features to the ultra-low power Microchip devices. With a rich peripheral feature set and enhanced computational performance, this 16-bit microcontroller family provides new migration options for high-performance applications that may require more than an
[Microcontroller]
PIC24FV16KM204 Series General Purpose 16-bit Flash MCU Data Sheet
Programming of AVR single-chip computer learning buttons and digital tubes
Introduction: Programming of buttons and digital tubes Input mode of AVR IO port and selection of pull-up resistor Structure statement and query method of buttons Programming of digital tube Basic principle of digital tube Scanning method to display multi-digit digital tube 1. Input status IO register setting 1.
[Microcontroller]
Programming of AVR single-chip computer learning buttons and digital tubes
Design of automatic gear shifting system for locomotive based on 8031 ​​single chip microcomputer
1 Overview In subway construction, engineering diesel locomotives (referred to as engineering locomotives) play a very important role. Especially in the early stage of subway construction, because a large amount of construction materials need to be transported, and the initial transportation conditions are re
[Microcontroller]
Design of automatic gear shifting system for locomotive based on 8031 ​​single chip microcomputer
ADC acquisition digital tube display simulation program based on AVR microcontroller Atmega16
Circuit Diagram The digital tube used is 7SEG-MPX4-CC. code #include mega16.h #include delay.h #define uchar unsigned char #define uint unsigned int flash char led_7 = {0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x6f}; flash char position = {0xe0, 0xd0, 0xb0, 0xf0}; char ad ; //Digital tube displ
[Microcontroller]
ADC acquisition digital tube display simulation program based on AVR microcontroller Atmega16
Using ActiveX Controls in VC++ to Implement Serial Communication with MCU
In single-chip microcomputer application systems, it is often necessary to communicate with microcomputers through RS-232 serial ports. Among various operating systems, Microsoft's Windows is more common, and most of them are 32-bit platforms such as Windows 95/98. In the past, serial communication on the Windows platf
[Microcontroller]
51 MCU + LCD 12864 with font library + DS1302 digital clock C source program
After two days of searching and debugging, I made continuous modifications based on other people's programs and finally successfully debugged the program. The time and date cannot be modified yet, it just starts from the scheduled time. Applicable to development board: 51 single-chip microcomputer (AT89S52) + LCD wi
[Microcontroller]
Infineon Technologies and Magneti Marelli Collaborate to Drive Regional Control Unit Innovation with AURIX™ TC4x MCU Family
On November 8, Infineon Technologies AG and Marelli, a supplier of mobility technology for the automotive industry, collaborated to develop advanced E/E architecture solutions. The collaboration combines the automotive expertise of the two companies to develop innovative regional control units (ZCUs) using Infineon'
[Automotive Electronics]
Infineon Technologies and Magneti Marelli Collaborate to Drive Regional Control Unit Innovation with AURIX™ TC4x MCU Family
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号