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 )
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
- Popular Resources
- Popular amplifiers
- Wireless Sensor Network Technology and Applications (Edited by Mou Si, Yin Hong, and Su Xing)
- Modern Electronic Technology Training Course (Edited by Yao Youfeng)
- Modern arc welding power supply and its control
- Small AC Servo Motor Control Circuit Design (by Masaru Ishijima; translated by Xue Liang and Zhu Jianjun, by Masaru Ishijima, Xue Liang, and Zhu Jianjun)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Basic knowledge of SCI serial port programming of TMS320F28035
- 【BLE 5.3 wireless MCU CH582】14. BLE serial port transparent transmission test
- Use 1117 solar panels
- Implementation of asynchronous serial port.zip
- 【Badminton Training Monitor Project】-- Additional function test of badminton training monitoring module
- In the 28035EPWM module up-down counting mode, how can I generate ADC trigger pulses at CMPA when both increasing and decreasing?
- DSP startup loading principle
- Based on the problem that the BlueNRG-lp example project given on the ST official website cannot be compiled
- GigaDevice GD32307E-START development board recommendation
- SIMterix-Simplis~6~