Today I wanted to upload a design I created for a soft latch power switch. It was used to power a Solarbotics Ardweeny, though you could use it for just about any microcontroller. If your microcontroller requires something other than +5V input, you may need to change the linear voltage regulator used, but the rest of the circuit should work fine. Everything here was powered from a single +9V battery.
For those who do not know what a soft latch power switch is, it allows a single button to perform three tasks - power on the microcontroller, act as an input to the microcontroller, and power off the microcontroller. Additionally, the soft latch power switch allows the microcontroller to power itself off. This is excellent for situations where a user may not power the device off, but you need to conserve battery. If no input is received within a desired amount of time, the microcontroller simply powers itself down.
For this project you will need:
- 9V battery
- 9V battery leads
- P-Channel MOSFET (PN: STP12PF06)
- NPN Transistor (PN: 2N3904TFR)
- 2x Rectifier Diode (PN: 1N4002)
- 5V Linear Voltage Regulator (PN: L7805ABV)
- Momentary Switch
- 3x 100k resistors
- 0.10 uf Capacitor (PN: UKL1H0R1KDDANA)
- 0.33 uf Capacitor (PN: UKL1HR33KDDANA)
- Microcontroller (Arduino)
Construction: Connect everything on your proto-board as shown in the schematic. Note that 'A0' and 'D0' connect to the microcontroller, as well as the +5V and ground (on the right of the schematic). If desired, the +9V output on the top right can be connected to any additional circuits required. Otherwise, only connect it to the voltage regulator.
Operation: When the power is off and the switch is pressed, the P-FET is activated and +9V is supplied to the linear voltage regulator. The regulator then supplies +5V to the microcontroller and it will turn on. It is important that your software immediately sets pin 'A0' to a high output. If done properly, the voltage on this pin will activate the NPN transistor and latch the power circuit on. While powered on, the pin 'D0' can be setup and used as an input. In my prototype, when the switch is momentarily pressed, the system responds by playing a beep. If the switch is held down for at least 2 seconds, the microcontroller plays a longer beep and sets pin 'A0' to a low output. This will release the latch, and the microcontroller will be powered off when the switch is released. If the switch is not pressed for 30 seconds, the microcontroller will automatically shut down.
Below you will find a video of my prototype and some Arduino code. In the video, everything is attached to a protoboard and you can see how it works. As shown in the picture, however, it can all be soldered to a more permanent board in a nice and compact form. I didn't have a lot of space in the device I put this in, so it worked out perfect. The code provided should get you pretty well started. Enjoy!
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Participated in the
1 Person Made This Project!
gmhoovler made it!