timed power switch with a pic - RC Groups
Thread Tools
Dec 13, 2005, 01:44 AM
Registered User

timed power switch with a pic

Hi all,

I am working on a PIC project and would like to use a button to power off the pic after it is pressed for like 2 seconds. Just like many of the devices you can get when you press the power button for a few sec to turn it on and then again to turn it off. This button also cycles through some other modes. There is also another button used for other functions. I am using the port change int (rb4..7)to read the button presses. Rb 0..3 is used for an LCD display. Can anyone give me a few hints Right now it kinda works but wakes up with any keypress after is shuts down. I am almost there arggggg.

Any help would be appreciated...
Sign up now
to remove ads between posts
Dec 13, 2005, 02:43 AM
The BEST way to do this is by using a dual comon cathode diode, with one side going to the PIC (pulled up) as the button state to be read by the PIC, and the other side going to a PNP transistor gate with common split running back to the PIC for a "power on hold" line that will hold the gate low. This makes the PIC really shut off (as in 0 power consumption). You can use LDO regs with super low current draw in standby, but you will always be drawing something. The method I describe has more draw on the battery through air leakage than the current required to run it.

RB7 is set to an input to read SW1's state. Make sure you turn on the weak pull-ups. RB6 is set to an output and driven high to hold the power on state. When you press SW1, power is supplied to the PIC through the PNP transitor->voltage regulator. This design works with ICSP. I designed this circuit 4 years ago, and I have used it as you see it in dozens of commercially available PIC based products. It works!
Last edited by JimDrew; Dec 13, 2005 at 02:51 AM. Reason: Added picture
Dec 13, 2005, 11:48 AM
Registered User
Mr.RC-CAM's Avatar
If I understand your problem, you have the wakeup feature working, but you do not like the issue that other keypresses also wake up the PIC. Instead, you want only one particular button to do that and only if it is held down for a short period. Is that the situation?

If so, then it is all a matter of checking for the source of the keypress wakeup interrupt and then checking for the correct press timing. If it is not the key that you want, or the keypress time is not correct, you just put the PIC back to sleep without doing anything else.
Dec 14, 2005, 02:17 AM
Registered User
Thanks guys,

yes Mr RC-CAM, thats exactly what I am trying to do. Driving me crazy. Cant figure it out for some reason I am getting close though. Thanks for the advice.!!! I "thought" I am doing what you say but keep getting confused with how to wakeup...sleep...setting flags and not getting back into the right parts of the code. argggg I am not giving up.

Thread Tools

Similar Threads
Category Thread Thread Starter Forum Replies Last Post
Power Switch with Voltage indicator Romych DIY Electronics 10 Mar 17, 2005 02:28 AM
Yippee! 15 amp wattage esc with bec and power switch cheap new flyer Aircraft - General - Radio Equipment (FS/W) 6 Oct 30, 2004 08:32 PM
Hyperfly anyone playing with one? and seems I have a power problem with it tooooo!!!! jpduke Electric Heli Talk 5 Oct 16, 2001 02:02 AM
Sudden power loss with new model astroboy Power Systems 5 Sep 26, 2001 11:53 AM
On/Off Switch with BEC? martin johnson Electric Plane Talk 1 May 25, 2001 09:27 PM