Author Topic: smart power button -- short press powers up, long-press removes power  (Read 640 times)

0 Members and 1 Guest are viewing this topic.

Offline exeTopic starter

  • Supporter
  • ****
  • Posts: 2646
  • Country: nl
  • self-educated hobbyist
Hi!

On laptops and many portable devices short press of a power button either powers devices on, or puts it into sleep mode.
A long press removes power or resets the device.

How is this implemented? I'm looking for a cheap integrated solution, something ideally something I can buy from lcsc).

I made a simple circuit that has a ~3s delay, but I'd like not to re-invent the wheel if there is a ready solution. I found https://www.st.com/en/reset-and-supervisor-ics/src0.html , but I'd like something cheaper, preferably like 10 cents/piece (or less).
 

Online wraper

  • Supporter
  • ****
  • Posts: 17920
  • Country: lv
Re: smart power button -- short press powers up, long-press removes power
« Reply #1 on: November 29, 2024, 04:01:12 pm »
Quote
On laptops and many portable devices short press of a power button either powers devices on, or puts it into sleep mode.
A long press removes power or resets the device.

How is this implemented?
In firmware.
 
The following users thanked this post: Smokey

Offline exeTopic starter

  • Supporter
  • ****
  • Posts: 2646
  • Country: nl
  • self-educated hobbyist
Re: smart power button -- short press powers up, long-press removes power
« Reply #2 on: November 29, 2024, 04:10:13 pm »
Yeah, but I'd like a hardware solution in case of firmware glitch. How would I power down a device with soft button in case of software issues? :D
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11858
  • Country: us
    • Personal site
Re: smart power button -- short press powers up, long-press removes power
« Reply #3 on: November 29, 2024, 05:57:45 pm »
It is assumed that you can write a simple MCU firmware that is not buggy to that extent. I doubt there is a readily available IC to do that. Your best bet is to take some 6-pin ATTiny and make a trivial firmware that does this.
Alex
 

Offline soldar

  • Super Contributor
  • ***
  • Posts: 3595
  • Country: es
Re: smart power button -- short press powers up, long-press removes power
« Reply #4 on: November 29, 2024, 06:10:15 pm »
Yeah, but I'd like a hardware solution in case of firmware glitch. How would I power down a device with soft button in case of software issues? :D

http://www.mosaic-industries.com/embedded-systems/microcontroller-projects/electronic-circuits/push-button-switch-turn-on/latching-toggle-power-switch

Press ON - Hold OFF latching circuits

For controlling smart products containing microcontrollers you often want to ensure that the power is not inadvertently removed. Consequently, you want a power switch that can be turned ON by a brief button press, but requires a longer, deliberate button hold to turn it OFF. That prevents accidentally killing power if the tactile switch is unintentionally touched.

The following shows a NAND gate latch implementing the desired action:
All my posts are made with 100% recycled electrons and bare traces of grey matter.
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11858
  • Country: us
    • Personal site
Re: smart power button -- short press powers up, long-press removes power
« Reply #5 on: November 29, 2024, 06:26:08 pm »
So, you still have an IC and a bunch of passives. A simple MCU would be sufficient by itself and it can implement much more robust logic and timings instead of relying on RC time constants. It would need programming, but in large quantities preprogrammed MCUs are an option.
Alex
 

Offline exeTopic starter

  • Supporter
  • ****
  • Posts: 2646
  • Country: nl
  • self-educated hobbyist
Re: smart power button -- short press powers up, long-press removes power
« Reply #6 on: November 29, 2024, 09:38:49 pm »
I agree, an MCU is a good option. I just don't want to bother with programming it, too much of a learning curve.

I found one potentially interesting options: XC6190 and RT9829. But a bit pricey, the first one is like $0.5, the second one is $0.25, but no adjustment of timeout.

I think such ICs are called timers and reset timers. There should be a cheaper option. There are 3 cents timers...
 

Offline Bud

  • Super Contributor
  • ***
  • Posts: 7262
  • Country: ca
Re: smart power button -- short press powers up, long-press removes power
« Reply #7 on: November 29, 2024, 09:57:23 pm »
This thread is just one step away from "Just use an FPGA"  :-DD
Facebook-free life and Rigol-free shack.
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11858
  • Country: us
    • Personal site
Re: smart power button -- short press powers up, long-press removes power
« Reply #8 on: November 29, 2024, 10:19:14 pm »
This is not far from what GreenPAK devices are for. They are closer to FPGAs than MCUs.. They may be even simpler and cheaper than a generic MCU.
Alex
 

Offline WillTurner

  • Regular Contributor
  • *
  • Posts: 57
  • Country: au
Re: smart power button -- short press powers up, long-press removes power
« Reply #9 on: November 29, 2024, 10:28:00 pm »
Completely analogue ... use two cross-coupled BJT's in a flip flop configuration, with another BJT and RC delay on each switching input. Yes, it costs 4 transistors, but is tolerant to switching the input rail (as long as it's below about 40V) and not just logic levels. If you really want to be modern, use Mosfets.
  Yes, you can accurately do the timing in a CPU, but you need the logic rails up first, something of a chicken and egg problem.
  BTW, I personally rediscovered this idea reading vintage homebrew computer schematics like EDUC-8. The sexy switch is a momentary on -- off -- momentary on toggle which will now set you back twenty bucks.  :)
 

Offline exeTopic starter

  • Supporter
  • ****
  • Posts: 2646
  • Country: nl
  • self-educated hobbyist
Re: smart power button -- short press powers up, long-press removes power
« Reply #10 on: November 29, 2024, 11:56:48 pm »
For now I settled on the schematic I posted. I just don't want to bother with those special ICs because they are not very common.

I decided not to do schmitt-triggering for now, let's see how it will work. I hope that's okay for AP2112K LDO and TPS2553 power switch.
 

Offline PGPG

  • Frequent Contributor
  • **
  • Posts: 396
  • Country: pl
Re: smart power button -- short press powers up, long-press removes power
« Reply #11 on: November 30, 2024, 12:48:05 am »
If we are speaking about supply in the range of 5V I'm sure such circuit can be easy build with 74HC14 + some passives. From two negators you can do latch and make it be set in specific position with your button (but through some resistor to let later be possible to set it reverse by the other source). Then signal from button through RC delay and after some time will switch third HC14 negator that would set latch to the opposite state (may be via diode driving input that it driven from button by resistor. If HC14 is too big than you can use HC2G14. If I made not mistake 3 Schmitt negators are enough.
 

Online BeBuLamar

  • Super Contributor
  • ***
  • Posts: 1416
  • Country: us
Re: smart power button -- short press powers up, long-press removes power
« Reply #12 on: November 30, 2024, 01:52:45 am »
Yeah, but I'd like a hardware solution in case of firmware glitch. How would I power down a device with soft button in case of software issues? :D

Pull the plug?? Make you device reliable so pulling the plug is something almost never needed.
 
The following users thanked this post: wraper

Offline exeTopic starter

  • Supporter
  • ****
  • Posts: 2646
  • Country: nl
  • self-educated hobbyist
Re: smart power button -- short press powers up, long-press removes power
« Reply #13 on: December 03, 2024, 02:45:31 pm »
Yeah, but I'd like a hardware solution in case of firmware glitch. How would I power down a device with soft button in case of software issues? :D

Pull the plug?? Make you device reliable so pulling the plug is something almost never needed.

The device will have a lipo battery inside. To pull the plug one would need to unscrew the enclosure first).
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf