Digital power switch

I'm working on a project that I would like to add a power on/off button. Rather than use a slide switch, I was hoping to implement a "soft" power button, something similar to the power switch found on many modern cellphones.

Eg.

(Power is off) Press-n-hold = power resumes
(Power is on) Press-n-hold = prompt for power off -> confirmation -> shutdown/sleep

I'm pretty sure I can figure out the passive components to pull off the press-n-hold functionality, but I don't know the best approach to powering down the micro while still being able to bring it back. I'm considering just using interrupts, but I thought it'd be worth asking the experts before I get in too deep.

Thanks for your input

Hi, Cellphones etc. are not totally off; they are in sleep mode waiting for an interrupt, I believe. You can do the same thing...

http://playground.arduino.cc/Learning/arduinoSleepCode

terry,

I'm pretty sure you're right. Even in the shutdown state, the micro isn't completely powered off. I'm just trying to decide if I should use the native power saving modes, or implement an external power cut-off. Or more accurately, which one would provide a better user experience. Sliding a switch seems primitive, but a soft power switch might be less reliable. Or am I being too cautious?

Well if your ever looking for a hardware solution here is a circuit I use sometimes. It uses a single coil 5vdc latching relay to control the power to any circuit. Upon manual pressing of the switch the micro starts and sets the relay which 'seal' the power contact on. Then anytime the code wants to shut off the power it just sends a LOW to the output pin causing it to reset and remove power from the circuit. Consumes no steady state current, just pulses of power during switching states.

http://img25.imageshack.us/img25/563/08miq7.jpg

Here's how to do it. No need for big and bulky relays.

// Per.

Zapro:
Here's how to do it. No need for big and bulky relays.

http://www.youtube.com/watch?v=Foc9R0dC2iI

// Per.

Nice circuit, but I suspect my latching relay takes up less board surface and cost less. :wink:

http://www.ebay.com/itm/Lot-10-AL-5WN-K-Takamisawa-5-Volt-Latching-DPDT-Relay-/200540015451?pt=LH_DefaultDomain_0&hash=item2eb11dcb5b

Lefty

retrolefty:

Zapro:
Here's how to do it. No need for big and bulky relays.

http://www.youtube.com/watch?v=Foc9R0dC2iI

// Per.

Nice circuit, but I suspect my latching relay takes up less board surface and cost less. :wink:

http://www.ebay.com/itm/Lot-10-AL-5WN-K-Takamisawa-5-Volt-Latching-DPDT-Relay-/200540015451?pt=LH_DefaultDomain_0&hash=item2eb11dcb5b

Lefty

Maybe. It's cheaper in discrete parts anyway, and it can be made smaller with SMD parts.

But yeah, more than one way to do it.

// Per.

petermetzger:
I'm working on a project that I would like to add a power on/off button. Rather than use a slide switch, I was hoping to implement a "soft" power button, something similar to the power switch found on many modern cellphones.

Eg.

(Power is off) Press-n-hold = power resumes
(Power is on) Press-n-hold = prompt for power off -> confirmation -> shutdown/sleep

That's exactly what I do in one of my designs. Put the mcu into power down sleep mode to turn it off. This stops the clock and the mcu consumes only a microamp or so, provided you don't have the watchdog or brownout detector enabled. The on/off button connects one of the interrupt pins to ground, and the interrupt wakes up the mcu.

Thanks guys!

I Think I might give the latching option a try. Board space is at a premium here, so I'll be attempting to use SMD components. If all else fails, interrupts are tried and true, so I can always fall back to that.

If I get results, I'll post them back here.

Thanks again

petermetzger:
Board space is at a premium here, so I'll be attempting to use SMD components. If all else fails, interrupts are tried and true, so I can always fall back to that.

LTC2950-1/LTC2950-2 Pushbutton On/Off Controller (SMD)
LTC2950

retrolefty:
http://www.ebay.com/itm/Lot-10-AL-5WN-K-Takamisawa-5-Volt-Latching-DPDT-Relay-/200540015451?pt=LH_DefaultDomain_0&hash=item2eb11dcb5b

Lefty

Thank you, 2 lots ordered. after ordered, find out it support Reverse polarity pulse unlatches. It is going to be a lot fun.

The whole point of microcontrollers is that in a single device you can do in software things that would take many components to do in hardware. So making hardware to implement this function - which can easily be done in software - is IMO a pointless waste, unless your primary aim is to educate yourself in hardware design (and not to educate yourself in software design).

Sorry to dig up this old thread. I use power save by putting the cpu in deep sleep. I would like some advice to also cut the power to any auxiliary devices like displays. Is it just a question of using a transistor to cut off the power to those devices? Like a controlled voltage rail? Ideas are welcome.

If the power taken by the device is very low, you can power it direct from an output pin via a 100 ohm series resistor. I have powered 16x8 character LCD displays (not including the backlight) this way. Otherwise, you need to use a transistor or mosfet to switch the power to the device.

Before switching off the power to a device connected to the mcu, it is very important to set all mcu output pins that are connected to the device to the LOW state.

Thank you for a quick response!