Want to use a single cheap momentary action push button switch to toggle your circuit power on and off? Try this circuit on for size.

Hi The Humble Toggle switch. You've seen them. You've used them on your projects to switch your projects off and on, and it seems pretty obvious when you design a product. Well, I need to switch the power off and on.

You use a toggle switch, but when you go on into production, it's not always the best idea. I Thought we'd take a look at it, think you might find it rather interestes in. Now take my power supply project for example. I've got to switch the power to this off and on and it can be drawing a couple of amps so your switch has to be rated for that.

And of course, it's got to be a latching type switch like this. Now these switches are great. They're simple, they work, they're easy. You've used them before, but are they the most economical solution? Not really.

because one off these things are two three I don't know, even five bucks for you know, even a reasonable quality switch that can handle your switching current for your particular project. or even if they're low current ones. getting ones that actually latch like that instead of the momentary push button ones that you might be using on your product or you've seen on other commercial products. They're much cheaper than these latching types.

So when you go into volume production, even from the one low Factory In China you're going to be struggling to pick these things up for under a buck or something like that. Now, a dollar that can buy you a hell of a lot of circuitry can buy you a microcontroller. whole bunch of passives, and all sorts of Active Components and stuff like that. So really, is the mechanical latch toggle switch the best way to go if you're trying to get the cost down on your product? Not really.

So today we're going to try and design a soft latchin' power circuit. Sounds simple enough, but let's see if we can do it. And one of the first things you start out with with any design like this: what are the requirements? Let's take a look at them. We've got.

Uh, zero power went off. We don't want the circuit to draw any power when it switch switches off just like a regular toggle switch. Uh, we want the one switch to do the onoff function. no separate on and off button.

One switch. You want to lower the cost. Simple, just like on regular commercial products. Three Stand loone.

We don't want the microcontroller in our system to actually have to switch the thing off or do any control or things like that sometimes. Um, that's actually desirable. but in this case I don't want that I Want it completely standalone. Number Four wanted to use Jelly Bean Parts Only We Don't want to use specific or dedicated chips hard to get parts so we're talking basic transistors, resistors, caps, dodes, that sort of stuff only and we want it to have a minimal number of Parts cuz we want to be elegant, don't we always? Now if we just ignore our requirements for a second, look at the basic application of this for just a separate onoff switch, how can you do that? Well, we've got our in input here and our output power here and we have a pass transistor.
in this case. it's a Um P channel uh, bipolar, but you can use a mosfet as well which we'll do in our final one. and you've got a latching transistor down the bottom. Now if you have a look at the first case, when you initially power this circuit up, this transistor is not going to be on because there's no base current flowing through here.

It's like that chicken and egg kind of situation. If there's no base current, this for there to be base current flowing through here like this. To turn this transistor on, this transistor down here needs to be switched on. First And of course it's not.

So you have the on switch here. When you turn on the on switch, current flows down through there like that and switches on that transistor and then the voltage. Well, the current flows through here and then it can then switch on this transistor down here here like this which then latches it so you only have to press that on switch very briefly and that will latch because it's in parallel with this switch. It'll keep that switch turned on, Keep this transistor turned on and Bingo! You've latched your power on.

Simple And how do you turn it off? Well, you just, uh, turn off this transistor down here by uh, shorting its base to ground? That'll switch it off. This gets no base current. Nothing goes through. End the story.

So that's how you can use. Um, that's a basic circuit for switching on and off, but we don't want two switches and we want we want to use one switch so it's a bit more complicated. So what we're going to do for starters, is to replace our bipolar transistor with a P Channel Mosfet works exactly the same, except it's got lower on Resistance They're just nicer, more readily available. So we're going to use a mosfet, but you could still use a bipolar transistor if you really wanted to.

And because it's a mosfet, um, we you know you don't want the gate here flapping in the breeze around like that. bad idea. So we're just going to tie it to the input here. so it just keeps the uh gate of the transistor stable when it's switched off.

and we've got our same uh, Npn bipolar transistor down here and it works exactly the same. It latches the same way. We can put our on switch across here and our off switch across here and it would work, but we want the one switch to toggle off and on. We're going to add some extra stuff over here.

We'll start out with basic understanding of what we want this one toggle switch to do and I've just, uh, diagrammatically drawn it as two separate switches here. Just for starters, if we've got our on switch the the base of this transistor, we need to switch this transistor on somehow so you'd have a pullup resistor back to the input here so the input voltage is always there when you hit this switch. you want this transistor to turn on, the latch thing will happen and everything's sweet. And then you want this same node because effectively these two nodes here you want them to switch between one and the other, or toggle between one and the other.
So when the uh. so when the circuit the soft latch circuit is off, you want this point here in your circuit to be. If our switch is on this base here, we want it to be high to the input and then once this thing switches on, we want this thing to go low like this so that then we can short out the base to ground, switch it off. How are we going to do it? So what I've done here is I've left our imaginary green circuit there in place and I've drawn in the new real black circuit here to replace these two switches with this one switch and it's doing exactly the same thing I said before.

When this uh pass transistor is off, the circuit's off and you want to switch it on, You want this one switch to act as the on switch. Here's this resistor up here. pulled High to the input like that. So if the circuit's off and you want to switch it on by pressing the button, then current will flow through this resistor, through the switch, through the base of this transistor, latching it on and Bobs your uncle and then what happens is this lat this transistor down here will switch on and then pull this point here to ground.

So now you can see that that's we wanted before. we wanted this point to toggle from high to low when it switched on and that's exactly what it's going to do. Toggle from high to low and then I'm assuming it's your circuit's been working for a while, it's been switched on and this you want to use the same button to switch it off, then this is pulled to ground. This point here is effectively grounded like that.

so when you press it, it shorts out the base and switches the whole thing off. Bingo! You've got some basic onoff functionality with a single switch. I Love it. But I know what you're saying Dave this is analog circuitry operates really really fast and a button press is really really slow cuz it's human.

Well, unless you're a superhero, Uh, if you press, you're going to hold down effectively. hold down this button ignoring switch bounce and things like that, you're going to hold it down for know 100 milliseconds quarter of a second. Something like that. even if you press it really quick.

So this thing is actually going to oscillate off and on. Off and on. Off and on. You don't want that, we're going to have to slow it down.

How can we do that? Easy. We'll add a capacitor in here to ground. That should do the trick. So let's take a Clos look at that.

I Have taken out the imaginary green stuff and this is our real final circuit that I think's going to do the trick or it should do in theory. now. Uh, works exactly the same as before. when you push this switch, if the circuit's off, this transistor's off.
You push, push this switch, it switches this base current on, latches this, and you supply power to your circuit. and now this capacitor here starts out at zero and it starts to charge up in voltage based on the RC time constant. plus the base current flow through there. Because this is a Um, this is an Npn bipolar transistor.

There's going to be some base current flowing in there as well, but anyway, that will charge that capacitor up. So uh, it won't immediately switch back off cuz this point will still be high. it'll still be high for I don't know. Depending on the RC time constant, you might Point 0.5 seconds or something like that that.

you want this point to be high and then once it reaches a threshold voltage of the transistor, it will switch the transistor on and pull that to ground. And if you're still holding down that switch after this transistor switches on, well, it's going to oscillate exactly like before. but assuming you can push it quicker than half a second or a second, whatever your time constant is, then, uh, this transistor will be fully on. and then this.

Um, the functionality of this switch changes from an on button to an off button. I Love it! So I've gone and put some real values in here: 100K pull up 100K pull up for the base here. it's relatively high. but stick with me and we got 100K here and we got a 1, Meg and a 22 mic here should roughly do the trick.

I Think we need to build this up, but I think this circuit because we're using uh, Bjts here could be a bit critical in terms of uh getting the ratio between. um, because this value needs to be high unless you got a massive cap. here you've only got very small amount of Base current. this resistor has to be high and there's going to be a balance between these values, so could be a little bit tricky unless you went to Mosfets.

But I'm going to try and build this up with Bjts and a Mosfet Um Pass transistor up here. see how it goes breadboard time and here's my circuit built up on the breadboard for my mosfet here: I've got an Irf 910 Um, that won't be the final one I use in my circuit but that's what I had to hand. So I'm going to use one of those. basically I want this to operate from a very low Uh voltage? a single lithium ion cell.

so 4.2 Vols maximum down to 3 volts or something like that. So you're really need to pick a mosfet with a very low Vgs um uh, that has a particular on the maximum on Resistance you want for a certain low Vgs voltage so you can't just use anyone off the shelf if you're um, picking like a if you need a low voltage. uh Supply like we're using uh for my power supply for example. and I'm just using transistors are 2 and3 3904 bog standard stuff I've using a 47 mic cap I didn't have a 22 to hand so let's give it a go.

Let's switch this thing on and Bingo there it is! It automatically switches on and I press the button and it switches off. Press the button switches on too easy and that works a treat. and if I hold it down, it should oscillate just like we said at the frequency set by that RC time constant. So let me actually replace that 20 two that 47 sorry with say a 10 mic and let's see what happens There We go there.
We go. It's oscillating much quicker and now it's going to be still works, but it's uh, going to be probably a little bit touchier. There you go. So yeah, that's the higher value.

It's going to do the trick there now. Uh, you'll note that I've actually got no load on this thing. So this is, um, assuming a circuit with absolutely zero load. and by the way, I was operating that at 4 Vols there.

So let's wind the wick down and see how low it will go with this particular mosfet. So there we go. We're at 3 Vols so we'll power that on and try it at 3 Vols It switches on and it switches off. It requires me to hold down the switch for a bit longer.

That's the thing it'll Miss if I press that off button really quick. it'll actually miss that I need to hold it down for a bit more. Uh, for a bit longer than I do to switch it on I can do a really quick on, but I can't do a quick off. There you go.

You could actually call that a feature. and let's have a look at the output voltage on the scope here. That's 500 MTS uh per division. So we're getting our 3 volts out there or just under and if we switch it off it, look, the output voltage doesn't actually go to ground.

it's at 500 MTS Now I'm measuring the output the meter there, and you'll notice that it's dropping. So that is the capacitor. uh, charged up to the base emitter, uh, voltage of the transistor that it's on. and then it's discharging through the extra resistors there, so that will actually eventually get down to ground.

That's because there is no load. And of course, that makes perfect sense because when you switch this off, this capacitor is charged up to the base emitter voltage up here. So the only PL when this? Transit When you press the button and you actually, uh, switch this transistor off here, the voltage up here goes to uh, you know it switches off, so it's got to discharge through these resistors here. and uh, that's what's causing it to stay on.

But you'll find that if we stick a load on here, say 10K or something like that, it should just vanish and go to zero instantly. But that's the disadvantage of this circuit with no load or a very light load, and we'll try that again with our 10K load. Let's switch it on and switch it off. Bang Right down to zero.

No problems. Let's set our trigger point in the middle there and capture that switching off to see if it switches off cleanly. Yep, not a problem whatsoever, and we might as well capture that switching on as well. So let's go bang there it is.
No problems at all. And one small note. Just remember, these mosfets have a built-in parasitic reverse diode like that in case that matters in your circuit. And if you remember, one of our requirements for the circuit was that it actually takes zero power when it's off, Does it? Yep, it does.

There we go. it's eventually going to go down to practically zero microamps. There you go. it draws na all half a be's dick.

So there you have it. I Think that's probably the simplest, Uh, discreet. Standalone soft latch power switch you could possibly do I could be wrong, but I'm going to claim that. Damn it, why not uses all Jelly Bean Parts two uh, Npn transistors.

it doesn't use Npn and PNP like some of the other. Solutions I've seen the best solution I've seen before. This is a three transistor one, plus the mosfet as well. and well, it seems to work reasonably well.

There are other Solutions I'm sure, but I rather like this one. It's kind of neat. We could probably do it. uh, different using mosfets.

Um, if we wanted to. but I'm using uh, bipolar transistors here and this is a standalone one. There are other ways you can do these sort of things where you can switch them off using a micro controller. like if you got an automated uh, if you want your software to be able to switch off the unit to go into power save mode after a certain amount of time.

Well, that's a different thing again, but this is just a standalone circuit using one very lowc cost momentary push button switch and I Love it. Is it the simplest solution possible? Well, I don't know I think it's pretty darn close. If you know something better, jump on the Forum and uh and share your thoughts. and uh, if you like the video, give it a thumbs up.

and in this video, I Won't bother experimenting with values and stuff like that just to show you which parts are critical and non-critical and how they interact. I'll leave that one up to you. Get the bread bought out. Play around! And for those who hate me, tapping on the Whiteboard just for you.

Catch you next time.

Avatar photo

By YTB

21 thoughts on “Eevblog #262 – world’s simplest soft latching power switch circuit”
  1. Avataaar/Circle Created with python_avatars Nathan Imig says:

    Wait is "soft" in Soft latch power switch not indicative of software controlled power off?

  2. Avataaar/Circle Created with python_avatars Petar Smiljanic says:

    Great Idea to exchange one mechanical switch with just two same of the kind and some electronics! For whom are you working or?

  3. Avataaar/Circle Created with python_avatars Hash#k says:

    How can i connect an led in the first circuit you drew

  4. Avataaar/Circle Created with python_avatars Prince Banini says:

    and for those who hate me tapping on the white board…..tap tap tap tap …..just for you๐Ÿ˜‚๐Ÿ˜‚

  5. Avataaar/Circle Created with python_avatars michael morrison says:

    Yoy are pointing to the emitter and saying base current..a bit misleading..

  6. Avataaar/Circle Created with python_avatars Ricardo Aguilar says:

    today I learned what the phrase "bo'b's your uncle" means. thank you

  7. Avataaar/Circle Created with python_avatars Leslie Valmadre says:

    Coming very late to this Video by Dave and having trouble making it work as expected as the LED stays on at 7v and goes immediatley off at lower voltages. In looking at Dave's breadboard set up am I totally off base when I think I see the T1 transistor Emitter leg connected directly to the Mosfet Gate when in the schematic it should be the Collector leg connected to the gate? Main problem in my setup is I cant get my hands on a IRF9110 and am using instead a IRF9540 which has a Vgs that is just too high for the low voltages I am using.

  8. Avataaar/Circle Created with python_avatars Guitar Player says:

    A micro controller might be cheaper, possibly. And be ultra low current in sleep mode. But this was 11 years ago, prices have changed now.

  9. Avataaar/Circle Created with python_avatars Jeffrey Petree says:

    Thank you mark

  10. Avataaar/Circle Created with python_avatars Sadaf Jarah says:

    How is the key to the PB with the PB. What does the circuit change: a clear mode means 1, a moderate mode like the flashlight that blinks and the third place is zero. Can you guide me?

  11. Avataaar/Circle Created with python_avatars Andrew Kay says:

    What a great presentation – I've learned something & enjoyed doing so. Thanks

  12. Avataaar/Circle Created with python_avatars Farid Safazadeh says:

    Did not have that P channel Mosfet you used. I had IRF5210 so used that. Worked like a charm first try! Thanks for sharing. You are just amazing. Although I will modify this and using this as an oscillator. I like the wave form coming out of it. A very neat square wave.

  13. Avataaar/Circle Created with python_avatars Oscar Caetano says:

    this video is so good. i already made the circuit years ago. and today i was in the need for something like that and remember it. i don't have any toggle switch at hand but plenty of transistors, resistors etc.

  14. Avataaar/Circle Created with python_avatars Ambassador Kees says:

    Nice. The only problem being: Switches on with initial power supply.
    That can be a safety issue in some cases.

  15. Avataaar/Circle Created with python_avatars Tolga Dabbagh says:

    i m sure this is not cheaper and prone to failure more than a simple switch .

  16. Avataaar/Circle Created with python_avatars Paul Cohen says:

    You could get an patent on the circuit!

  17. Avataaar/Circle Created with python_avatars andymouse123 says:

    Still a great video for the young ones…..cheers !

  18. Avataaar/Circle Created with python_avatars Doug Gale says:

    I unsubscribed because of that spiteful thing at the end, years ago. In case you thought it was funny. Knowing you couldn't care less about annoying viewers convinced me to avoid your stuff.

  19. Avataaar/Circle Created with python_avatars Edgars LS says:

    You could just put the switch between the collector and base of the transistor that pulls the gate of the fet to ground.

  20. Avataaar/Circle Created with python_avatars Keri Szafir says:

    Plain simple and elegant; can be combined with over-discharge protection.

  21. Avataaar/Circle Created with python_avatars Kurt Rowland says:

    I'm sorry. Half a bee's what?

Leave a Reply

Your email address will not be published. Required fields are marked *