A recent Design Idea prompted me to offer the simpler solution that I used in a recent project (Reference 1). We needed a momentary power switch with processor supervision. This supervision would allow the processor to delay a power-down request from a press of the power switch until all routines exited properly. In addition, in periods of inactivity, the processor could shut down the product to conserve battery life. The project also required a boost converter to convert two or three AA batteries to 5 V. The design uses IC1, a Texas Instruments TPS61032 boost converter (Figure 1). It features an enable pin (Pin 9), which, when you pull it low, not only shuts down the converter, but also completely removes the load from the battery. The processor is a PIC16F874. A key element of the design is that you can first configure the processor-I/O pin as an output to keep the converter's enable pin high and then reconfigure it to test the logic level of the power switch.
|Figure 1.||This circuit configuration provides a momentary power switch with processor supervision.|
When the circuit is not running, closing momentary power switch, S1 (push-on) pulls IC1’s Pin 9 high, thereby turning on the converter and providing 5 V to the processor. The processor boots up with its I/O pin configured as an output and pulled high. This action keeps IC1’s Pin 9 high and the converter running after the release of the power switch. Every few milliseconds, the processor's I/O pin reconfigures as an input, and the processor checks the switch for a high (pressed) or low (released) condition. The processor pin then returns to its previous output mode. Capacitor C4 holds IC1’s Pin 9 (enable) high to keep the converter running while the switch undergoes testing. When you release the power switch from power-up and then press it again, the processor begins the push-off sequence. After performing whatever housekeeping it requires, the processor pin configures itself as an input and remains an input. Capacitor C4 then completely discharges, bringing IC1’s Pin 9 (enable) low, thereby shutting down the converter and the rest of the circuitry. Diodes D1 and D2 allow the battery voltage to start the converter and the processor to test the power switch using the higher output voltage from the converter. The TPS61032 also features a low-battery comparator whose trip point is a function of R1 and R2. A different processor could read the comparator's output (IC1, Pin 10) to perform a safe shutdown when the battery voltage gets too low.