through a complete system setup.
When it encounters the check for why we started up,
the reason will be RESET_INSTRUCTION, and processing
will continue to turn on the LED and then into the infinite
loop that is the basis for most embedded systems. Within
that loop, we check for a button press of two seconds or
longer which initiates the HWSleep() function all over
again.
The additional hardware on the prototyping board
represents control of power to a load (in this case, a
buzzer) via a pFET (P-channel MOSFET). Support for this is
included in the code file (LF18Switch.c) at the article link.
Applications
Using a microprocessor as a power switch may seem
like over-kill, however (as I mentioned earlier), since my
projects are usually processor-based, I get the functionality
for free. Even the pin for the button is free because I can
use it for other operations after the system is turned on.
While some systems — such as our LED light — need a
switch to turn off, others will turn themselves off
automatically after they have completed their tasks. We’ll
see that in my wireless doorbell and motion sensor
transmitters next.
Before we get to that, there are some other tests I
For driving relatively low power (200 mA or less)
loads, I prefer to use a pFET. They’re cheaper than a relay,
use very little space, and can have a very low voltage
drop. Driving a 20 mA radio transceiver, I experienced a
“diode forward voltage drop” of only 0.15V. Ordinary
transistors will usually have a drop of 0.7V or more. The
2N2222 I tested had a 0.9V drop with the same 20 mA
load I tested with the pFET.
For my application, I need to get the highest possible
voltage from the battery to my radio. The circuit for this is
included in Figures 2 and 3. Note that the pFET is active
low. You need a 1M pullup resistor (R5) to ensure it turns
off because the output from the processor will float when
it’s asleep.
The reason I’m focused on low sleep currents and
pushbutton activation is a wireless doorbell and alarm
project I’m working on. I want to be able to use a
pushbutton switch or a PIR
(passive infrared) sensor to
trigger the radio transceiver
that communicates with the
base station. The radio takes a
while to power up, so if you
just connect the pushbutton
between the battery and radio
November 2014 43
DESIGNATOR PART CATALOG PART #
(All part numbers are for Mouser Electronics.)
U1 PIC12LF1840 579-PIC12LF1840-I/P
Q2 pFE T TP2104 689-TP2104N3-G
PIR Panasonic 769-EKMB1103111
The other parts are miscellaneous workbench supplies.
■ FIGURE 3.