Maker Pro
Maker Pro

Soft latching power switch

carrotflower

May 5, 2015
10
Joined
May 5, 2015
Messages
10
Hi, I am looking to create a soft latching power switch to disconnect the battery from the rest of the circuit. In the circuit I have a microcontroller and multiple momentary press buttons. These buttons would be connected to ground and different individual pins on the microcontroller which use the internal pull-up resistors. I would like any of these buttons when pressed to turn on the power switch and the microcontroller to be able to turn off the switch. I apologise for the awful diagram but I've tried to show this.
Please could someone point me in the right direction to try and achieve this?

Thanks a lot
Joe
Untitled.png
 

cl10Greg

Mar 20, 2014
25
Joined
Mar 20, 2014
Messages
25
Depending on the load and the power you can do this with a couple of different components.
  • PMOS transistor - Have a pull up resistor to the battery and a protection resistor to your microcontroller. Pull the line load to turn on the battery
  • NMOS transistor - have a pull down resistor to ground and a protection resistor to your microcontroller. Pull the line high to turn on the battery
  • Relay - Have a bjt that pulls the relays coil to ground and use the microcontroller to turn it on and off
Google any of these and you will get a ton of hits.
 

carrotflower

May 5, 2015
10
Joined
May 5, 2015
Messages
10
Sorry, I wasn't very clear in my original post. I want the switch to supply power to the microcontroller itself and not an external load. I want to be able to switch off the supply via the microcontroller but when the switch is off there is of course no way of using the microcontroller to turn the switch back on so I was looking to use the push buttons. These buttons are already connected to the microcontroller for other purposes, but would it be possible to somehow wire this up to activate the switch by pressing any of these buttons?

Thanks for your help
 

huttojb

May 3, 2015
52
Joined
May 3, 2015
Messages
52
I'm doing the same sort of thing, look at my post
NPN and relay cct
Where I use the pic to control the input for the regulator, by setting the pin logic, kills the 12v and therefore kills the regulator. I have enough charge in the capacitors to put the micro in a known state. I don't know if this is what your looking for, but may give you a help in hand.

Hope this helps.

Jason.
 

carrotflower

May 5, 2015
10
Joined
May 5, 2015
Messages
10
I'm doing the same sort of thing, look at my post
NPN and relay cct
Where I use the pic to control the input for the regulator, by setting the pin logic, kills the 12v and therefore kills the regulator. I have enough charge in the capacitors to put the micro in a known state. I don't know if this is what your looking for, but may give you a help in hand.

Hope this helps.

Jason.
Thanks for this, I've taken a look but I'm more interested in figuring out how to connect multiple buttons (see below).

You didn't say what microcontroller you are using. I have used a P-MOSFET and an N-MOSFET to make a Push-ON/Push-OFF or Push-ON/Program-OFF switch for PICAXE's power. Here is a link to links discussing on how to do this.
http://www.picaxeforum.co.uk/showth...led-power-down&p=158381&viewfull=1#post158381

Ken
Sorry about that, I haven't yet decided on the microcontroller for the final design but at the moment I am using a teensy 3.1 (ARM K20DX256) for testing.

I've come up with the following design that I think would work? However, instead of one button being dedicated to turning on the circuit I would like to be able to use any of the existing buttons that are already connected to the microcontroller without connecting them together. Any ideas on the best way to do this?

Thanks
sdfsdf.PNG sdfsdfsdf.png
 

KMoffett

Jan 21, 2009
723
Joined
Jan 21, 2009
Messages
723
I'm thinking you will want the wire (with the arrow) to go to the three switch inputs through diodes. Anodes toward Q2. This isolates the switch inputs from each other. I assume the micro has "weak pullups", as the schematic doesn't show external pullup resistors. Do they say how they program D3. If it is always an "OUTPUT", when it's HI it will be shorted to ground through Q2's b-e junction. I would replace the wire from D3 to the bottom of R1 with a 10K resistor.

Ken
 

carrotflower

May 5, 2015
10
Joined
May 5, 2015
Messages
10
Thanks a lot for this Ken, I really appreciate it. Yes, the micro is using internal pullups for the buttons. I've attached a 10k between d3 and r1 incase an INPUT mode can't be used on the μc. I assume that this will still be a low enough resistance to divert the current away from the base of Q2 when D3 is low?

Thanks again
Joe
sdfsdfsdfsdf.PNG
 

KMoffett

Jan 21, 2009
723
Joined
Jan 21, 2009
Messages
723
The issue is, I don't know the state of the I/O's when the micro is off. If there is even
a high resistance path through them to ground, this approach might not work. With the power off and without the diodes, measure the resistance from D4-6 to ground. If there is any readings, this approach is out.

Ken
 

KMoffett

Jan 21, 2009
723
Joined
Jan 21, 2009
Messages
723
Been rethinking (3AM) my suggestion. It might be OK. There might be a very small continuous uA leakage current when off, but that may not be a problem for you. The fact that there is a 100K resistor from source to gate would probably keep the MOSFET off even with a high resistance current path to ground. It would be well worth bread-boarding. I don't have that micro board, or I would try it.

Ken
 

carrotflower

May 5, 2015
10
Joined
May 5, 2015
Messages
10
Thanks for this, a tiny uA leakage won't be an issue. I'm away at the moment so won't be able to breadboard for a while but thanks a lot for your help so far.

Joe
 

carrotflower

May 5, 2015
10
Joined
May 5, 2015
Messages
10
I'm having a bit of difficulty breadboarding the original circuit (attached). The circuit runs as normal when pressing the button to turn on the mosfet and a button between ground and the base of the transistor (instead of a microcontroller). However when the mosfet is off, waving a hand near the circuit will switch it back on. It seems to be most sensitive near the gate and drain of the mosfet. I've tried multiple transistors and mosfets all with the same result. Any suggestions on what could be happening?

Thanks again,
Joe

sdfsdf.PNG
 

KMoffett

Jan 21, 2009
723
Joined
Jan 21, 2009
Messages
723
Are you sure you have R2 is connected between the MOSFET's source and gate? That should prevent the MOSFET from reacting to the static charge on you hand.
The circuit runs as normal when pressing the button to turn on the mosfet and a button between ground and the base of the transistor (instead of a microcontroller)
With that, you are also leaving the the base of Q2 floating as R1 is connected Q1's open drain that in not conducting except for what ever leakage there may be. I would put a 100K resistor from the base to ground and see if that helps.

Ken
 

carrotflower

May 5, 2015
10
Joined
May 5, 2015
Messages
10
Yes, r2 is definitely connected. I've added a third 100k from base to ground and this has definitely made it a lot less sensitive but it is still turning on occasionally when actually touching the connections. Is this normal behaviour or can more be done to prevent this?

Thanks
Joe
 

KMoffett

Jan 21, 2009
723
Joined
Jan 21, 2009
Messages
723
I never wired my circuit with Q2's base current coming directly from Q1's drain, so I can't say.

Ken
 

Kenneth Tan

May 22, 2015
58
Joined
May 22, 2015
Messages
58
I've found this youtube link that shows a soft latch power switch with additional microcontroller support.

Maybe it's the one your looking for.
 
Top