Delayed (hold down button) power on. - Page 1
Forum section: electronics / general

author: LEDAero
author_rank: Regular Contributor
timestamp: January 15, 2015, 09:57:21 am
content: I have a project using an ATmega processor that I would like to turn on and off using a held-down button (2 secs, as a yardstick).For things like mobile phones, MP3 players, tablets, PCs, etc. - how is this done? Is there some standard IC that I can integrate? Even my coffee machine does it...Hopefully you bright buggers on here will have the answer - the Arduino people suggested I use one of these, but make it hard to get to...

author: Falcon69
author_rank: Super Contributor
timestamp: January 15, 2015, 09:59:36 am
content: maybe have it operate a transistor which drains a capacitor, when capacitor drops below a certain voltage, it turns the circuit off? Might take a large capacitor though, maybe a 1000uF?

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: January 15, 2015, 10:35:05 am
content: You do it in software - MCU lives in sleep mode wen "off", wakes on the button input, software measures button-down time to decide whether to turn on or not. If necessary, use load switch(es) to control power to any external hardware that can't be put in a low-power mode

author: dannyf
author_rank: Super Contributor
timestamp: January 15, 2015, 11:58:58 am
content: QuoteThrough software, I suppose:Code:if button isn't pressed, reset button_pressed and button_pressed_count;else button_pressed_count ++;if button_pressed_count > DESIRED_BUTTON_PRESS_CNT, button_pressed |= BUTTON_LONG_PRESSED;It is essentially a state machine.

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: January 15, 2015, 11:08:06 pm
content: Quote from: mojo-chan on January 15, 2015, 01:45:22 pmYou can, but you need to be careful about what happens when the MCU's supply drops below normal operating voltage as it turns off - you need to avoid glitches that may make it turn on again.If you're using anything bigger than a coin cell, sleep power will usually be small compared to battery self-discharge, so this would be the "default" way to do it where possible as it requires the minimum of components and maximum flexibility in how something can be woken up.

author: Falcon69
author_rank: Super Contributor
timestamp: January 15, 2015, 11:38:15 pm
content: Won't he need a debounce circuit for the switch though? Or does the software account for that?

author: LabSpokane
author_rank: Super Contributor
timestamp: January 16, 2015, 02:41:33 am
content: If you want do this with an arduino, you can use to boot time as the delay. Yes, it's a shit-rigged way to do it, but it works. Stuff a MOSFET in front of the VCC, then use the momentary switch to turn on the MOSFET. Once the arduino boots, have the code latch on the MOSFET with a digital output and turn on an LED to let the user know that it's latched into the ON mode. The Arduinos reset line will power down the device.

author: Sal Ammoniac
author_rank: Super Contributor
timestamp: January 16, 2015, 03:02:22 am
content: Quote from: Falcon69 on January 15, 2015, 11:38:15 pmSoftware can easily debounce the switch.Here's a good article on switch debouncing that covers both hardware and software debouncing:http://www.ganssle.com/debouncing.htm

author: LEDAero
author_rank: Regular Contributor
timestamp: January 16, 2015, 06:32:44 am
content: I guess I was looking to find out how cell-phones do it - my old Ericcson is powered off - the battery has been taken out and replaced.When I come to turn it on, I have to hold the button down for a certain time before the unit comes on - or is that all just consumer perception - it actually started being powered as soon as the battery got installed and the hold-to-power is just a software trick?Quote from: mojo-chan on January 15, 2015, 01:45:22 pmThat sounds more like it. An LDO is a Low DropOut regulator? And I'm not up to FET yet in my 'Dummies Guide to Electronics', so I suspect this is beyond my abilities right now and I need to keep working through the book - and take the Arduino recommendation of recessing a switchDoing some reading, the Atmega328P that I will be using has six sleep modes - the most frugal of which is SLEEP_MODE_PWR_DOWN, which uses 0.36 mA. That's less than half an amp in a year. Assuming I use batteries which hold their charge for that period - like low self-discharge NiMH - it makes sense to do it in software, like you say.Thanks to all for your replies - very thought provoking.

author: Falcon69
author_rank: Super Contributor
timestamp: January 16, 2015, 06:42:41 am
content: LEDAero,I have a Galaxy mini S4 and it also does that as well. Every cell phone i have owned does that. I believe it is made like that to keep the phone from turning on (or off) in the event it is in your pocket or something and the on/off switch is touched briefly, which otherwise would turn the phone off.

author: LabSpokane
author_rank: Super Contributor
timestamp: January 16, 2015, 07:05:19 am
content: FETs are no-brainer devices as switches. You can do it.If you're working in the arduino environment, there is a library that enables the sleep functions without having to mess with writing to registers directly. I haven't played with it yet, so I don't know how well it has been implemented.And the hold to turn on is not just a perception, it is a feature.

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: January 16, 2015, 09:51:32 am
content: Quote from: Sal Ammoniac on January 16, 2015, 03:02:22 amNo need for much debouncing as you're not counting presses - worst case you go through a few sleep/wake cycles before actually powering up, which doesn't matter, otherwise just add a few mS delay after wake before looking at the button state. If you're using a crystal or resonator thn the start-up time will cover any bounce time

author: Sal Ammoniac
author_rank: Super Contributor
timestamp: January 16, 2015, 12:59:56 pm
content: Quote from: mikeselectricstuff on January 16, 2015, 09:51:32 amIt just seems inelegant to me to let it thrash around a few times when a few lines of C would prevent it.

author: LEDAero
author_rank: Regular Contributor
timestamp: January 19, 2015, 06:21:12 am
content: Quote from: LabSpokane on January 16, 2015, 07:05:19 amI will do more digging, thanks.