Protecting Microcontroller Input Pins from Soft Power Switch

Not rated 8,844

Circuit Image

A soft power switch for a microcontroller is designed such that a momentary switch can activate the circuit, including the microcontroller. When the switch is pressed a second time, the microcontroller is capable of shutting itself down after executing necessary cleanup tasks. The circuit utilizes a lithium-ion battery (3.7-4.2V) and the TC1015 voltage regulator (3.0V output). Upon pressing the switch, the regulator is activated, causing the microcontroller to set the uC Power high, maintaining its operation. A subsequent press of the switch triggers an interrupt on the uC Switch, allowing the microcontroller to set the uC Power low, thereby turning itself off. Concerns arise regarding the need to protect the microcontroller from battery voltage, as the microcontroller has an absolute maximum voltage on the I/O pins of Vdd + 0.4V. Additionally, there is uncertainty about whether the circuit will prevent the regulator from activating while in the "off" state. A pulldown resistor on the enable line was considered, but concerns about current draw during the powered-on state were noted. The revised circuit employs a flip-flop, with the data line normally pulled low. Pressing the switch triggers the clock, activating the system. Subsequent presses of the switch raise the CLOCK line high, allowing the microcontroller to recognize the press without affecting the regulator's output. When the microcontroller is prepared to power off, it sets the DATA line high and then raises the CLOCK line, resulting in the regulator shutting down. This configuration ensures that the initial button press turns the regulator on and keeps it active until the microcontroller is ready to power down. Contact bounce is not a concern, as the data line remains held low by the pulldown. The current draw is minimal, limited to the flip-flop and the TC1015 while off, with negligible current through resistors while on. The microcontroller must be safeguarded from the battery voltage on the clock line, which can be achieved with a resistor on the CLOCK.

The soft power switch circuit for the microcontroller is designed to facilitate an efficient power management system, ensuring that the microcontroller operates only when necessary and conserves battery life. The use of a lithium-ion battery provides a stable voltage range conducive to powering both the regulator and the microcontroller. The TC1015 voltage regulator is chosen for its low dropout voltage, making it suitable for battery-powered applications.

The implementation of a flip-flop adds robustness to the circuit. The flip-flop acts as a memory element that retains the state of the power switch, ensuring that the microcontroller can reliably detect switch presses without being affected by mechanical bounce. The initial button press activates the regulator, and the microcontroller can maintain its operation by setting the uC Power high. This design minimizes the risk of unintended resets or power cycling due to noise or bounce.

To address the potential issue of battery voltage exceeding the microcontroller's maximum I/O pin voltage, a resistor is used on the CLOCK line to limit current and protect the microcontroller. This resistor ensures that when the CLOCK line is driven high, the voltage does not exceed safe operating levels for the microcontroller.

The circuit's design also considers power consumption. The use of pulldown resistors and the flip-flop configuration minimizes current draw during the off state, which is critical for extending battery life. Overall, this soft power switch circuit is a well-thought-out approach to managing power in microcontroller applications, balancing functionality with efficiency and reliability.Soft power switch for a microcontroller where a momentary switch can turn the circuit on (including microcontroller), and then when the switch is pushed a second time, the microcontroller can shut itself off after performing some clean up. I have the above circuit so far, but I`m not sure if it`ll be reliable. I`m using a lithium- ion battery (3. 7-4. 2V) and the TC1015 regulator (3. 0V output). The idea is that when the switch is pressed, the regulator turns on, then the microcontroller sets uC Power high, keeping itself on. When the switch is pressed a second time, an interrupt on uC Switch will allow the microcontroller to set uC Power low, turning itself off.

What I`m not sure about, is if I need to protect the microcontroller from battery voltage. The microcontroller I`m using has an absolute maximum voltage on the I/O pins of Vdd+0. 4V, so I`m not sure how to handle that best. Second, will this circuit actually keep the regulator from turning on when it`s in the "off" state I had thought about using a pulldown resistor on the enable line, but am worried about the current draw while the chip is powered on. The new circuit uses a flip flop, with the data line normally pulled low. Pressing the switch hits the clock, turning the system on. Subsequent presses of the switch drive the CLOCK line high (allowing the microcontroller to sense the press), but don`t affect the output of the regulator.

Once the microcontroller is ready to power off, it sets the DATA line high and then sets the CLOCK line high, which will cause the regulator to shut down. One of the really nice things about this setup, is that the first button press turns the regulator on, and keeps it on until the microcontroller is ready to shut down.

Bounce isn`t an issue, because no matter how many times the clock line goes high, the data line is still held low by the pull down. In addition, the current draw should be very minimal (just the flip flop and the TC1015 while off), and there is minimal current draw through resistors while on.

The microcontroller does need to be protected from the battery voltage on the clock line, but as @Andy aka suggested, that can be done with a resistor on CLOCK. 🔗 External reference




Warning: include(partials/cookie-banner.php): Failed to open stream: Permission denied in /var/www/html/nextgr/view-circuit.php on line 713

Warning: include(): Failed opening 'partials/cookie-banner.php' for inclusion (include_path='.:/usr/share/php') in /var/www/html/nextgr/view-circuit.php on line 713