Electrical Engineering Asked by cutlerr on December 29, 2021
The only switches I have every worked with are basic switches with on/off state, but I want to be able to add a power button to my project that is just like the power button on a cell phone. (hold for x seconds to power on, hold for x seconds to power off). It should also obviously act similarly to a momentary switch that doesn’t depress or change levels when it is clicked.
I know this requires specific programming within the controller; I’m just confused about the best switch setup to accomplish this.
Do I accomplish this with a certain type of momentary switch? I am getting confused by the different types on digikey, such as this one: https://www.digikey.com/product-detail/en/e-switch/TL3315NF100Q/EG4620CT-ND/1870400
You have left very little information as to the type of power source you have and the type of load you mean to switch. If in the case you are dealing with a low DC voltage supply with a load of up to a couple of amperes of current the following circuit topology is suitable for toggling a load on and off with momentary TACT switch.
Answered by Michael Karas on December 29, 2021
The programming part is somewhat easy, but you also need to power on the microcontroller first before it will execute code.
If your voltage regulator has an "enable" input, you need to build a diode based OR gate with the power switch and a GPIO as inputs, so you can activate the regulator with the button, and the microcontroller can keep it active when the button is released.
Regulators usually aren't picky about the voltage on the "enable" pin, because if there were a stable voltage source, there wouldn't be a need for a regulator anyway. Your microcontroller, on the other hand, does not tolerate GPIOs being pulled above the supply voltage, so you need a diode to protect it here (Vcc is still off, and the button is connected to an unregulated supply that is likely higher than Vcc).
Turning off from the microcontroller is easy: just pull down the GPIO.
Turning off via button needs more external logic: you want to be able to detect short presses and forward these to a GPIO, and long presses that force poweroff.
Answered by Simon Richter on December 29, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP