This was originally posted on the piclist but unfortunately the archives drop the attachments... reposted by request...
--- snip ---
You don't actually need an On button... the PIC can sense a Keypad Button has been pressed and turn itself On. What is your Keypad arrangement? I assume it's a standard Matrix style whereby the PIC sequentially powers the rows and reads the columns.
If this is the case, the columns get connected to RB4 thru RB7 and you have an interrupt on change preset in software. Meanwhile, you need to power the Rows when the PIC sleeps (since the PIC is no longer polling the buttons. So a transistor and a splattering of Diodes will do that... you'll need an extra PIC pin to accomplish this.
Consider the schematic of the SLEEPY-KEYPAD I've just thrown together (see appended file). You will recognise Fig 1 as the 'Classic' arrangement. Now look at the rehash of the arrangement in Fig.2. With the PIC switched OFF (asleep) additional assigned pin RA0 is either high impedance (Input) or Logic 0. Transistor Q1 is powered ON via R9. In turn power is applied via Diodes D4-D8 onto the Matrix. Any keypad depression will apply a voltage onto RB4-RB7 and trigger a wake on change on those pins. Diodes D1-D4 prevent this aux power arrangement from attempting to power the PIC thru port pins RB0-RB3. When the PIC wakes, the first thing it does is apply a Logic 1 (High) onto the pin I've assigned as RA0. This turns OFF Q1, and now the PIC can scan the Keypad Matrix as normal to detect the offending key-press. Diode D9 is dual purpose, it again prevents external voltages from powering the PIC, and stops you blowing up Q1 by driving RA0 Low. Before going back to sleep, PIC sets either Logic 0 or Input for RA0 to switch ON Q1.
Q1 is any low-power transistor (eg BC237). Diodes are signal types (eg 1N4148). Resistors are 10K except R5, which you may get away with a few hundred K (eg 470K... experiment here).. the higher the better as it just keeps Q1 turned on and adds to your OFF-state power drain.
I'm sure there are heaps of other arrangements, but this is one simple one that obviously springs to mind without burning too many calories over the problem.
Melanie
PS. Rubbish GIF, so save and enlarge accordingly. As an afterthought, the Keypad Resistors can be dispensed with reducing the component count, however transistor base Resistor R9 is still required.
Bookmarks