Pages: [1]   Go Down
Author Topic: Digital power switch  (Read 1166 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 25
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Topsham, Vermont USA
Offline Offline
Edison Member
*
Karma: 33
Posts: 1921
... in The Woods In Vermont
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Regards, Terry King terry@yourduino.com  - Check great prices, devices and Arduino-related boards at http://YourDuino.com
HOW-TO: http://ArduinoInfo.Info

Offline Offline
Newbie
*
Karma: 0
Posts: 25
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17294
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Denmark
Offline Offline
God Member
*****
Karma: 15
Posts: 727
Please don't send questions as PM!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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



// Per.
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17294
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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



// Per.

Nice circuit, but I suspect my latching relay takes up less board surface and cost less.  smiley-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
Logged

Denmark
Offline Offline
God Member
*****
Karma: 15
Posts: 727
Please don't send questions as PM!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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



// Per.

Nice circuit, but I suspect my latching relay takes up less board surface and cost less.  smiley-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.
Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 224
Posts: 6614
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Offline Offline
Newbie
*
Karma: 0
Posts: 25
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Earth
Offline Offline
Edison Member
*
Karma: 52
Posts: 1797
My browser no longer is binding static IP, Floating is the way to go.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Earth
Offline Offline
Edison Member
*
Karma: 52
Posts: 1797
My browser no longer is binding static IP, Floating is the way to go.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


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

United Kingdom
Offline Offline
Tesla Member
***
Karma: 224
Posts: 6614
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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).
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

The Netherlands
Offline Offline
Full Member
***
Karma: 1
Posts: 195
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Rob
Follow my progress on http://simplicate.weebly.com

United Kingdom
Offline Offline
Tesla Member
***
Karma: 224
Posts: 6614
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: December 17, 2013, 03:55:58 pm by dc42 » Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

The Netherlands
Offline Offline
Full Member
***
Karma: 1
Posts: 195
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you for a quick response!
Logged

Rob
Follow my progress on http://simplicate.weebly.com

Pages: [1]   Go Up
Jump to: