Latching power schematic - am I doing it right?

I’m trying to make an Arduino circuit that comes on when you press a momentary button, but then stays on until the Arduino decides it’s time to switch off. Fairly common situation, I’d imagine, but I’ve never done it before.

Is my [attached] schematic workable? Looks sensible to me, but I’ve discovered that that means remarkably little :slight_smile:

Basically, I’m imagining that the circuit won’t do anything when power is first applied, as there’s no current through the base/emitter of the TIP102. Press the power button on the right, and the TIP102 will turn on, allowing power through the voltage regulator and therefore powering up the arduino. The first line of code in the arduino will set the ‘power control’ pin high, so it’ll keep the TIP102 powered even after the user has taken the finger off the button.

Then when I want the arduino to power down, all I have to do is set the ‘power control’ pin low.

The two diodes are just acting as an ‘OR’ gate, and to stop current from finding a route straight from the power button to the arduino.

… Or am I making a basic mistake? Thought it was worth asking here before buying the bits.

Oops - just to add, I'm slightly concerned that the decoupling caps across the input and output of the voltage regulator may cause problems. Should they perhaps be connected to ground before the TIP102 (the 'switched ground', if you will)?

I'm not worried about the circuit inadvertently powering on when I first connect the 9v battery, as long as it'll behave from then on.

h

I'm slightly concerned that the decoupling caps

No they are fine.

That looks like it might work. The only problem [u]might[/u] be when the arduino want's to turn off and it will not be able to hold the output high long enough to be off. But I think it would work. If you have problems then you might like to look at looking at the on button with the arduino and only turn on the holding output when the on button is being pressed. But try this first.

Conventionally this is done with two transistors connected as a multivibrator or flip flop. It is kicked on and then kicked off so it doesn't require any logic level to hold.

Thanks for the response!

That looks like it might work. The only problem might be when the arduino want's to turn off and it will not be able to hold the output high long enough to be off.

The Arduino's holding the power on by keeping a pin high, so do you mean it may not be able to hold the output low for long enough?

No the on bit should work. It is the off bit that might be problematical.
Arduino sends pin high, power starts dropping, then you enter a sort of twilight zone where you might get resting going on and restarting the program and re asserting the pin low. Electronics do funny things when operating a voltages on the verge of operation.
But as I said it will probably work.

Sorry to harp on, but I'm a bit confused now - the TIP102 conducts when there's power applied to it's base, doesn't it? So I'm triggering the power on by giving it some volts, and the Arduino takes over and keeps supplying enough volts to keep the TIP conducting.

When it's time to switch off, the Arduino output goes LOW, causing the TIP to stop conducting.

Or have I got things arse-about-face?

Yes you have it right.

My worry is the potential thrashing about of the arduino pin as the power dies, it might just trigger it on again.

When I've wanted project with manual on/automatic power control I've used a small single coil latching relay circuit. Draws zero current once latched on. Software turns output pin high in setup function, set output pin low when program wishes to power off.

http://img25.imageshack.us/img25/563/08miq7.jpg

Lefty

@Grumpy_Mike - thanks for checking for me! I'll buy the bits and have a play.

@retrolefty - Yup, a relay was my first thought, but I've only got one 5v/latching one knocking about and I want to save it for bigger badder things. Thought it would be a useful exercise to try and keep the whole thing solid-state now I'm getting a little more experienced with all the analogue 'glue' needed to have my AVRs talk to the outside world.

[edit:] Just looked at your schematic; never come across single coil latching relays before, I've only got double-coil ones. Interesting. A bit confused about C1, though; why is it there? Doesn't it stop the current flowing before the relay's even had a chance to think about moving?

Just looked at your schematic; never come across single coil latching relays before, I’ve only got double-coil ones. Interesting. A bit confused about C1, though; why is it there? Doesn’t it stop the current flowing before the relay’s even had a chance to think about moving?

No, upon intital digital output high, enough charging current flows through cap to latch relay on, once cap charges to full +5vdc, current flow stops, but the charged cap then contains enough charge to reverse current flow when output pin goes low, resetting the relay. It’s a cleaver little circuit that is more then meets the eye at first. The resistor shown is optional as if you try and turn the circuit back on too soon before the cap has fully discharged it won’t relatch, the resistor ensures the cap fully discharges when off.

If one doesn’t mind the continous 13ma current flow draw of the relay coil, then the cap and resistor can be done away with and relay just wires from ground to the output pin.

By the way Pololu seels nice sold-state power switches:

Lefty

I've just posted a schematic to solve this very problem in thread "Switch Arduino ON, it does tasks, then Switches self OFF" which is also in this section of the forum.

Hi Howiem

I was a litle concerned with your design with having the transistor in the base of the 7805. This will create an offset that will increase the output of the 7805 to about 5.7Vdc and could also cause some instability if the voltage across the TIP102 varied. Since there is no voltage on the GND pin of the 7805 and very little current, I doubt it would work without adding a resistor from +9V to the collector, and I am not sure that would turn off the 7805.

REMOVED solution, thank you Magician for pointing out the err in my version.

Regards Bill

IMHO, it’s wrong way to switch output by disconnecting a ground of 78XX. It would send higher output voltage to load, up to unregulated Vin ( 9V ), creating serious threat to load.

@Bill_Kerr: nice try, but it’s not gonna to work eather. (At least no smoke hazard :slight_smile:
In order to keep it “on” Atmega has to output on control pin whatever voltage it getting as VCC plus 2 x p-n junction (1.4 V) what, obviously, it couldn’t do.
I’d suggest to have a look on RuggedCircuit “high side drive”
http://ruggedcircuits.com/html/circuit__19.html
only instead of solenoid and diode, collector should be connected to 7805 input terminal. In “off” state wouldn’t be any current, which is important with battery power source.

Yup - as many suspected, my circuit doesn't work properly - it latches "on" beautifully, but when the Arduino's finished it's task and sets the power-latch-pin LOW, the power never goes all the way off.

It's obvious in hind-sight what's going on - because I'm effectively disconnecting the ground from the Arduino, the whole Arduino/load part of the circuit ends up floating at VDD, including the power-latch-pin, meaning current flows through the B-E part of the TIP102, keeping it all switched on.

Glad I tried doing this way, though, if only because I've learnt a few important lessons, and my arduino has survived :)

When I get some time I'll have a look at Magician's high-side drive approach, or the two-transistor bi-stable or flip flop approaches (thanks, Grumpy-Mike and dc42). If all else fails I can always drop in my last precious latching relay to do things the old-fashioned way.

@Bill_Kerr - good point, hadn't thought about the offset effect of having silicon on the base of the 7805... oops

Flippin 'eck, the digital side of electronics is sooooooo much easier [logical, ho ho] than analogue. Getting there, though :)

Flippin 'eck, the digital side of electronics is sooooooo much easier [logical, ho ho] than analogue. Getting there, though

Boy, isn't that the truth. I've been building circuits for many decades and the digital based projects almost always work from the git go, with possibly only needing to add a Vcc bypass cap here and there. On my analog circuits, I can count on them almost never working from the offset, for many different reasons. Op-amps have helped my analog circuits be a little more predicatble on start-up, but still not as reliably as the pure digital designs.

Lefty

Hi Howieem

I was looking for something else when I came across this SPec sheet.

There is a remote shut down circuit in the notes

http://www.makershed.com/v/vspfiles/assets/images/l7805.pdf

Regards Bill