wengenroth.com
Wengenroth.co - Auto-Off Circuit


AUTO-SHUTOFF CIRCUIT



schematic of auto shutoff circuit

I came up with this circuit after searching for something similar and coming up empty. Basically, I have a lot of battery operated devices with power switches, but no auto-shutoff. Yes, there are many circuits out there that provide a means of automatically turning off a device, but they have one downfall - they require a momentary switch. Almost everything I have that I needed an auto-off for has a SPST switch and I didn't want to rip open the case to modify it for a momentary switch. Normally, this would be a simple task for a microcontroller to monitor the switch and turn the circuit on or off accordingly. This would work, but i wanted a circuit that would completely cut the power, meaning not even the microcontroller is powered when off.

I tested many ideas before finally settling on this one. At the heart of the circuit is a timer, in this case I'm using an AVR Tiny to trigger a port pin when powered on and turning it off after the time has elapsed. The port pin is fed into the base of a PNP transistor. The collector of the PNP is then fed into the base of a NPN. The emitter of the NPN is tied to the switch and thus the negative terminal of the battery. The collector goes to the ground of the timer circuit (AVR Tiny). This collector also feeds the new switched power to the original circuit - say a light. Finally, the emitter of the PNP is tied to the positive terminal of the battery (along with the timer and original circuit) through a small 1K resistor. The resistor limits the current on the two transistors, yet allows the NPN to function in the non-linear (switching) region. To start the circuit when the switch is turned on, a small 1nF capacitor is connected between the base of the PNP transistor and the emitter of the NPN. A very small 15pF capacitor is connected between the base and emitter of the PNP to allow the circuit to restart quickly when power-cycled.

auto off circuit built breadboard first

I built this using parts on hand over the course of a weekend and as such, it may not be the best approach but it works well. The voltage drop introduced by the emitter-collector junction of the NPN is roughly 200mV, which shouldn't affect the original circuit, unless it is an extremely low impedance load. Future improvements may include using MOSFETs instead of bi-polar transistors.

auto off circuit built on a piece of perfboard

I started with a breadboard and after verifying the circuit works, I built it on a piece of perf-board I had. This is when I ran into troubles with it not restarting after cycling the power (switching it off and on). Many hours later (the next day actually) I realized I needed the small capacitor between the emitter and base of the PNP, which was missing on the breadboard. The breadboard itself has a pretty high capacitance between rows (several picofarads) which was introduced unknowingly. I built several other circuits 'deadbug' style and they all work just as well (with this added capacitor).


auto off circuit built dead-bug style bottom view auto off circuit built dead-bug style side view
auto off circuit built dead-bug style top view

The microcontroller I used was the AVR tiny85 because I have some many of them on hand. In reality, any microcontroller can be used so long as it has a few bytes of code space (maybe the tiny5). The code is very simple: enable port pinX as output low, when timer is up, make port pin input (HiZ). I'm using interrupts, sleep modes, and the watchdog clock source to keep power usage minimal. Even with it written in C, the code size is only 200 bytes, which can be substantially reduced further with assembly.

Feel free to use this as you please, just be sure to give reference to me. The source files are below for the AVR. If you like it or find it useful, then let me know!

Downloads



Name

Email (optional) will not be made public

Website (optional) will not be made public

Comment


Sheldon Mar 27, 2013 14:59:11

Is there anyway you could send the source could for Arduino Uno? Thanks

Kyle Wengenroth Mar 30, 2013 13:09:49

Hello Sheldon, unfortunately I have never worked with an Arduino so I don't have any code available for that. The code is very simple. On power-up, it makes the pin an output and sets it low. It then runs a timer until the counter reaches zero (in my case its about 15 minutes) then it makes the output pin an input (hi-Z). Im not sure if this would work with an Arduino since it may try to pull more power than is initially available on startup. You also have to factor in the bootloader which takes time before it gives control to the main program. Thank you for your interest though.

(c) 2013 Kyle Wengenroth