How to power off the ?C by itself

Hi everybody.
I'm making a battery powered arduino project. It should turn on by pressing a button and should power off by itself.

My idea:
put a Mosfet (p-channel, with 10k pullup) parallel to the button and connect its gate to the ?C. If the ?C powers up, it should set the pin connected to the gate immediately low. And turning the ?C off by setting the pin high.
Datasheet of the mosfet: http://docs-europe.electrocomponents.com/webdocs/0d23/0900766b80d23111.pdf

My 2nd idea:
Use the enable pin of my voltage regulator to turn the power on (also with a button) and holding it with a pin of the ?C
Datasheet of the regulator: http://docs-europe.electrocomponents.com/webdocs/0cbc/0900766b80cbc561.pdf

My problem:
I tried the first one with no results. If i set the pin low, it doesn't turn off the mosfet. (The raw mosfet circuit works as expected if i connect the gate manually to VCC or GND)
I haven't tried the second one.

Maybe somebody could help me and tell which one of the two methods mentioned above should work (or none of these), or tell me an other solution.
Tanks, Andy

I've had very good success using POWER DOWN sleep mode. Second year for a pair of AA alkaline batteries. I use a pin change interrupt to wake the processor on a button press. But it's powered directly from batteries.

If your time has any value, this is a good choice...

Thanks coding badly

I've had very good success using POWER DOWN sleep mode.

good idea. Is that a common method: I will switch my device on or off about three times a year or so :wink:

If your time has any value, this is a good choice...
Pololu Pushbutton Power Switch LV (old version)

The pololu switch looks rather interesting, i could try to replicate it

Any idea why my circuit mentioned above doesn't work?

Thanks

guest1102:
POWER DOWN sleep mode ... good idea. Is that a common method:

I don't how "common" that is. I just know that it works well.

I will switch my device on or off about three times a year or so :wink:

So long as nothing is drawing current (like an inefficient voltage regulator) then POWER DOWN should work very well.

Any idea why my circuit mentioned above doesn't work?

Someone else will have to help with that question.

guest1102:
Hi everybody.
I'm making a battery powered arduino project. It should turn on by pressing a button and should power off by itself.

My idea:
put a Mosfet (p-channel, with 10k pullup) parallel to the button and connect its gate to the ?C. If the ?C powers up, it should set the pin connected to the gate immediately low. And turning the ?C off by setting the pin high.
Datasheet of the mosfet: http://docs-europe.electrocomponents.com/webdocs/0d23/0900766b80d23111.pdf

My 2nd idea:
Use the enable pin of my voltage regulator to turn the power on (also with a button) and holding it with a pin of the ?C
Datasheet of the regulator: http://docs-europe.electrocomponents.com/webdocs/0cbc/0900766b80cbc561.pdf

My problem:
I tried the first one with no results. If i set the pin low, it doesn't turn off the mosfet. (The raw mosfet circuit works as expected if i connect the gate manually to VCC or GND)
I haven't tried the second one.

Maybe somebody could help me and tell which one of the two methods mentioned above should work (or none of these), or tell me an other solution.
Tanks, Andy

The first circuit cannot work - once the microcontroller sets the output high it loses power, thus pulling all its pins down to 0.5V above its Vcc, which will turn on the MOSFET again...

Second idea has exactly the same issue. You need to use a control signal that is LOW to turn off the supply. A CMOS inverter could be added to either of the circuits to fix the issue but only if the supply is 6V or less (for 74HC family). If the supply is significantly higher 4000 series CMOS might work but the gate drive might not be high enough (needs to be more than 0.5 x supply voltage).

When your processor looses power, it resets. All ouput drivers initialize low, turning your power back on. While unpowered the outputs appear as a low impedance to the processor's power supply also telling the fet to turn back on. Your switch control needs to be an active high to maintan power and a low to turn it off, your push button then is used to bypass the power switch transistor long enough for the processor to activate the pin assigned for power control. PNP bipolar power switch, npn driver on common emmitter grounded mode, ballast resistor from driver collector to pnp base, PB between ground and driver Collector. PB bypasses driver, turns on the mains, processor boots and activates driver holding power on.

I drew you up something like I described.

Here is another method that utilizes a single coil 5vdc latching relay. One turns on the system by pushing the manual switch, then the first commands in the running program turn the output pin high, setting the relay that 'seals on' the on contacts and so continues to power the system. When the program wishes to power down it just turns the output pin low. The advantage of this specific circuit is that it draws almost no current once the series cap charges high. I got the relays on e-bay, they are usually around $1 each and I've used this circuit in several of my projects, works reliably.

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

Lefty

I did a similar design a while back using FETs, I never built it but was happy at the time that it would work. With FETs I had to use a zener to ensure Vgs (the input voltage) never got over 12v or whatever because I needed 30v input, that wouldn't be a problem with the TIP and/or lower voltages I think.


Rob

Hi, thanks for your answers.

The first circuit cannot work - once the microcontroller sets the output high it loses power, thus pulling all its pins down to 0.5V above its Vcc, which will turn on the MOSFET again...

Oh yes. You're right, I didn't think about this fact before.

You need to use a control signal that is LOW to turn off the supply.

After reading this I thought I could use an N-Channel MOSFET instead of the P-Channel, so I modified my circuit. But unfortunately without results. If I press the button, the ?C starts and sets the pin on the gate of the mosfet high. So far so good, but after releasing the button the power goes off.
I have absoletely no idea why, I mean the gate has been put high and should stay there, shouldn't it?

guest1102:
I have absoletely no idea why, I mean the gate has been put high and should stay there, shouldn't it?

Is this what you have?
(Pin 7 is VDD of the ATmega328, and I chose pin 11 (Digital Pin 5) as a random digital pin)

index.svg|0x0

abreis:

guest1102:
I have absoletely no idea why, I mean the gate has been put high and should stay there, shouldn't it?

Is this what you have?
(Pin 7 is VDD of the ATmega328, and I chose pin 11 (Digital Pin 5) as a random digital pin)

I took DigitalPin 10 and I used my arduino board, not the bare ATmega. However, pin 7 is VDD.

UPDATE:
Oh sorry, i didn't see the attachment, I'll draw mine now.

My brain says it should work, MOSFETs require so little current it should stay on easily.

Try adding a capacitor from the gate of the FET to ground, just to kill the odds that something is draining current there for a split second, causing your mosfet to shut down.

Whether you you use the circuit I provided or not. The pin must be setup in the startup code of the running application, also the power on button must be maintained longenough for the system reset to clear and the micro processor to start execution. adding a 10 uF cap, series with 10k from the switched power buss to the power control pin and then isolating the micro with a 1N4148 diode, anode side toward the micro and cathode to the power control pin(un modified designation), the supply will maintain its self on for several seconds without the pushbutton depressed. The TIP125 can be subbed with a P channel mosfet, just adjust the value of R1 do that the incoming voltage after division on R1/R2 does not exceed 18V across R1.

My brain says it should work, MOSFETs require so little current it should stay on easily.

Try adding a capacitor from the gate of the FET to ground, just to kill the odds that something is draining current there for a split second, causing your mosfet to shut down.

My circuit is in the attachments underneath.

Yes, I tried to add a 100uF and a 100nF cap without results

Try using the switch to turn the gate on, instead of 'shorting out' the MOSFET (like I had in my crude drawing).

A design like ajofscott suggested would be more resilient, though.

I'll try this circuit tomorrow, i'm going to bed now.
Thanks guys :slight_smile:

guest1102:

My brain says it should work, MOSFETs require so little current it should stay on easily.

Try adding a capacitor from the gate of the FET to ground, just to kill the odds that something is draining current there for a split second, causing your mosfet to shut down.

My circuit is in the attachments underneath.

Yes, I tried to add a 100uF and a 100nF cap without results

That circuit can't work, an N-channel MOSFET's gate has to be more positive than its source to turn on, yet you are expecting both to be at +5.0V when its on... It would be normal to use an n-channel to switch the 0V line, but here that would give exactly the original problem with + and - reversed. CMOS inverter or similar required.

Here's a circuit I did a while back, I never built it though

There's probably stuff you don't need there but the general idea is to use an N-ch FET to switch the P-ch FET. For example D67 is only needed because I had 30v input, with a ~12v input you wouldn't need it.

Truth is there are high-side FET switches and controllable regulators that can do all this now so I doubt it's worth the effort to make a circuit up.


Rob

Greynomad and I both do the same thing with different transistor families. Build our circuit(s) and then go from there. Both can be adapted to be on/off pb controllers with addition of an additional pb. Which would not be a bad idea anyway as it would allow forced powerdown by a human operator.