16
\$\begingroup\$

I want to design a circuit such that the microcontroller can toggle a GPIO pin and shut the whole system (including microcontroller itself) down. And when the user presses a momentary button, the power is brought back up again.

Is this possible?

\$\endgroup\$
11
\$\begingroup\$

alt text

This example uses a Maxim MAX1835 step-up regulator, but could be applied to others as well that have a shutdown pin.

The circuit is normally powered down. When the user presses the pushbutton, the battery is fed into the -SHDN pin, enabling the regulator and turning on the 3.3V to the microcontroller. The microcontroller then puts a logic 1 on the POWER ON lead, holding the power on after the user releases the pushbutton. When the microcontroller wants to shut itself off, it sets the POWER ON lead to 0.

\$\endgroup\$
  • 2
    \$\begingroup\$ Very important, I would think, is debouncing that switch. \$\endgroup\$ – Kortuk Jan 14 '11 at 15:39
  • 2
    \$\begingroup\$ @Kortuk, good point. I was assuming the micro would turn on fast enough that it could override the switch before the first bounce, assuming driving the pin high was the first thing the micro did. If that isn't the case, one could add a capacitor on the -SHDN lead to create a time constant for the turn on (although this would also introduce a slight delay in turn off). The 10 nF one probably needs to be left in for noise suppression (it was included in a datasheet sample schematic). Or one could add additional RC circuit for just the switch. \$\endgroup\$ – tcrosley Jan 14 '11 at 16:36
  • \$\begingroup\$ I have seen some crazy bounce on switches before. \$\endgroup\$ – Kortuk Jan 14 '11 at 17:03
  • \$\begingroup\$ A bigger issue that switch bounce is processor behavior during power-down. In particular, it may be good to make sure that the processor can only turn the supply on when its VDD is above the point where correct operation is guaranteed. I've had to tweak some auto-power-down circuits that would occasionally fail as a consequence of the processor running random code when VDD fell below the valid operating voltage. The random code could set the "power on" output high, which would in turn power the device back up, running code at a random address. \$\endgroup\$ – supercat May 30 '11 at 1:45
1
\$\begingroup\$

One way of doing this is to enter a deep sleep mode on the microcontroller.

Many microcontrollers support being woken up by an external interrupt, such as an edge on an IO pin.

\$\endgroup\$
  • \$\begingroup\$ then i'd also get the quiescent current draw of the regulator supply power to the micro right? \$\endgroup\$ – cksa361 Jan 14 '11 at 10:50
  • \$\begingroup\$ Yes. You would. \$\endgroup\$ – Toby Jaffey Jan 14 '11 at 11:20
  • \$\begingroup\$ @cksa361, some micros this is nano or micro amps. I use the MSP430 and we keep it around 3-5 microamps. \$\endgroup\$ – Kortuk Jan 14 '11 at 17:03
0
\$\begingroup\$

Yes, this is certainly possible, but how you achieve this depends on what kind of load you're going to be switching on and off.

It's probably as simple as just using a relay connected to the output PIN of the microcontroller (via a transistor and protection diode), and a push button switch connected to a pin configured as an input.

Here is a simple example circuit diagram: schematic of relay controlled by a microcontroller

When using a momentary push button switch, be careful of debounce though, you'll need to implement a delay in your microcontroller code to ensure that you check the status of the push button over a period of time (e.g. 1ms) before switching your relay back on. If you don't, then the microcontroller might pick up multiple signals and switch your relay several times in a very short space of time, and you'll find that your button works intermittently.

UPDATE I just saw your edit about powering the microcontroller down as well. Can you give some more information about what your actually trying to do? It's difficult to answer your question without understanding the whole system.

If you want to shut the microcontroller down as well, then you'd need some way of getting power back to the microcontroller. Maybe you could use the relay to power everything including the microcontroller, that way the microcontroller can switch itself off, but not back on. Then your push button could be connected across your relay switch, to effectively short it out giving it enough time to power up and hold the relay open itself.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.