Author Topic: Mosfet power switch with auto-off  (Read 14826 times)

0 Members and 2 Guests are viewing this topic.

Offline 8086Topic starter

  • Super Contributor
  • ***
  • Posts: 1085
  • Country: gb
    • Circuitology - Electronics Assembly
Mosfet power switch with auto-off
« on: June 11, 2012, 12:10:16 am »
I'm trying to come up with a design for a simple pushbutton operated power switch (over on the right side of the schematic), that I can latch somehow and turn off at will. I have a PIC in the circuit so I figure if I drive RA2 high once the circuit is powered through the momentary pressing of the button, it should stay on, and then it can turn itself off through pulling RA2 low.



Are there any obvious problems with this plan? It seems logical but I know all too well there can be many "gotchas" with things that seem too simple.
 

Offline hlavac

  • Frequent Contributor
  • **
  • Posts: 536
  • Country: cz
Re: Mosfet power switch with auto-off
« Reply #1 on: June 11, 2012, 12:32:56 am »
Let's see... a short circuit thru RA2 when someone is holding the button when PIC wants to power itself off? I'd stick a 330R resistor between RA2 and the gate/switch...
« Last Edit: June 11, 2012, 12:34:45 am by hlavac »
Good enough is the enemy of the best.
 

Offline digsys

  • Supporter
  • ****
  • Posts: 2209
  • Country: au
    • DIGSYS
Re: Mosfet power switch with auto-off
« Reply #2 on: June 11, 2012, 12:49:46 am »
Given the info supplied, you either run the switch into it's own Input to the PIC, if you have any spare IO,
OR you leave RA2 in INPUT MODE (or high impedance if that's available), then WHEN you need to control
the output, 2 lines of code - change RA2 to OP mode via DDR, Turn On or Off. The 330R resistor is a MUST
as well. It can be up to 1-2K, as you're not running the FET at high frequency.
Hello <tap> <tap> .. is this thing on?
 

Offline hlavac

  • Frequent Contributor
  • **
  • Posts: 536
  • Country: cz
Re: Mosfet power switch with auto-off
« Reply #3 on: June 11, 2012, 12:50:46 am »
Also, the 3V gate voltage is uncomfortably close to the gate threshold voltage of the MOSFET, in fact 2N7002 datasheet says the threshold voltage may be up to 3V max.
You may get way bigger on resistance than you expect for some. You may get lucky if your supply current is extremely low. Or not. This design would be more suitable for 5V power rail.
Not a huge problem in a one off project where you can pick another one that works, but I wouldn't feed an assembly line with 10000 of these, the manufacturing tolerances might bite you.

I guess it's CR2032 lithium battery powered? If so, I'd have a problem with that 10k pulldown on MOSFET gate, which would have been eating your battery capacity. It may not look like much, but these CR2032s are pretty wimpy. Also I'd put a few uF cap across the CR2032, the internal resistance is pretty awful.
« Last Edit: June 11, 2012, 01:01:21 am by hlavac »
Good enough is the enemy of the best.
 

Offline 8086Topic starter

  • Super Contributor
  • ***
  • Posts: 1085
  • Country: gb
    • Circuitology - Electronics Assembly
Re: Mosfet power switch with auto-off
« Reply #4 on: June 11, 2012, 01:01:46 am »
You guys are right about that resistor - oops.

Interesting you should mention the threshold voltage, the datasheet I have for the 2N7002 says it's 2V typ. and 2.5V max.  :-\

digsys, I'm not sure what you're getting at with giving the switch it's own input, etc, I was planning on simply setting RA2 high as the first operation after reset. The button is only going to be pressed to turn on, never to turn off.
 

Offline Rufus

  • Super Contributor
  • ***
  • Posts: 2095
Re: Mosfet power switch with auto-off
« Reply #5 on: June 11, 2012, 01:05:43 am »
Are there any obvious problems with this plan? It seems logical but I know all too well there can be many "gotchas" with things that seem too simple.

There is a path from VDD to VSS through the PIC and on to the MOSFET gate via the RA2 pin clamp diode. It will sit with the MOSFET partially on or perhaps oscillate.

Dave did a video on a single push button on/off circuit and there was a long thread about it and other designs.
 

Offline hlavac

  • Frequent Contributor
  • **
  • Posts: 536
  • Country: cz
Re: Mosfet power switch with auto-off
« Reply #6 on: June 11, 2012, 01:19:13 am »
There is a path from VDD to VSS through the PIC and on to the MOSFET gate via the RA2 pin clamp diode. It will sit with the MOSFET partially on or perhaps oscillate.

What? No, you are thinking higher gate voltages than the PIC supply, this is not the case.
It's just when the RA2 outputs LOW and you press the button you would short circuit the +3V through the RA2 low side driver to GND. It would probably not even smoke the thing, these can do a few dozen of mA... but your power supply will dip and the PIC may crash due to brownout, especially on a 3V lithium battery power.

Good enough is the enemy of the best.
 

Offline hlavac

  • Frequent Contributor
  • **
  • Posts: 536
  • Country: cz
Re: Mosfet power switch with auto-off
« Reply #7 on: June 11, 2012, 01:25:23 am »
Interesting you should mention the threshold voltage, the datasheet I have for the 2N7002 says it's 2V typ. and 2.5V max.  :-\

You're right, I was looking into the wrong box (2N7000). Damn multi-device datasheets :) 2.5V should be OK.
Good enough is the enemy of the best.
 

Offline digsys

  • Supporter
  • ****
  • Posts: 2209
  • Country: au
    • DIGSYS
Re: Mosfet power switch with auto-off
« Reply #8 on: June 11, 2012, 01:28:05 am »
Quote
Interesting you should mention the threshold voltage, the datasheet I have for the 2N7002 says it's 2V typ. and 2.5V max
A quick check aslo confirms min threshold at 2.75 max, whcih seems fine to me too.

Quote
I was planning on simply setting RA2 high as the first operation after reset. The button is only going to be pressed to turn on, never to turn off
Then I don't understand the circuit .. If PA2 goes high immediately, then the OP is 3V, same as the switch?? The FET is between 0V and GND ???
If SO, what potential is GND from 0V, it CAN'T be more than 20V, unless you add a zener.
Hello <tap> <tap> .. is this thing on?
 

Offline Rufus

  • Super Contributor
  • ***
  • Posts: 2095
Re: Mosfet power switch with auto-off
« Reply #9 on: June 11, 2012, 01:32:53 am »
There is a path from VDD to VSS through the PIC and on to the MOSFET gate via the RA2 pin clamp diode. It will sit with the MOSFET partially on or perhaps oscillate.

What? No, you are thinking higher gate voltages than the PIC supply, this is not the case.
It's just when the RA2 outputs LOW

The RA2 pin can't output LOW. LOW turns off the MOSFET which lets the PIC VSS pin rise towards 3v and the RA2 pin will rise with it.
 

Offline hlavac

  • Frequent Contributor
  • **
  • Posts: 536
  • Country: cz
Re: Mosfet power switch with auto-off
« Reply #10 on: June 11, 2012, 01:42:43 am »
I don't think there will be a problem with that. When the PIC starts choking due to low voltage, its drivers will die off and the 10k pulldown on the gate will finish the job. It's not necessary to output LOW to turn off, merely stop outputting HIGH will do. It will just be slower.
Good enough is the enemy of the best.
 

Offline 8086Topic starter

  • Super Contributor
  • ***
  • Posts: 1085
  • Country: gb
    • Circuitology - Electronics Assembly
Re: Mosfet power switch with auto-off
« Reply #11 on: June 11, 2012, 01:47:55 am »
I guess it's CR2032 lithium battery powered? If so, I'd have a problem with that 10k pulldown on MOSFET gate, which would have been eating your battery capacity. It may not look like much, but these CR2032s are pretty wimpy. Also I'd put a few uF cap across the CR2032, the internal resistance is pretty awful.

Yeah, or similar battery. Would this loss be through the pic then, considering the switch is NO, so you really just have pic -> 10k -> gnd?

Quote
I was planning on simply setting RA2 high as the first operation after reset. The button is only going to be pressed to turn on, never to turn off
Then I don't understand the circuit .. If PA2 goes high immediately, then the OP is 3V, same as the switch?? The FET is between 0V and GND ???
If SO, what potential is GND from 0V, it CAN'T be more than 20V, unless you add a zener.

It's just a low-side switch. Instead of switching VDD, I'm switching VSS. The idea is that 0V is passed through to GND when the mosfet is on.
 

Offline Rerouter

  • Super Contributor
  • ***
  • Posts: 4700
  • Country: au
  • Question Everything... Except This Statement
Re: Mosfet power switch with auto-off
« Reply #12 on: June 11, 2012, 01:48:42 am »
my first concern would be any significant capacitance between 3V and 0V will cause a slow startup that transits through the brownout region, you would want to make sure that wouldnt cause your device to do something funny,
 

Offline hlavac

  • Frequent Contributor
  • **
  • Posts: 536
  • Country: cz
Re: Mosfet power switch with auto-off
« Reply #13 on: June 11, 2012, 01:55:59 am »
PICs have brown out reset protection, that should not be a problem. Just enable BOD reset.


Good enough is the enemy of the best.
 

Offline hlavac

  • Frequent Contributor
  • **
  • Posts: 536
  • Country: cz
Re: Mosfet power switch with auto-off
« Reply #14 on: June 11, 2012, 02:16:27 am »
If PA2 goes high immediately, then the OP is 3V, same as the switch?? The FET is between 0V and GND ???
If SO, what potential is GND from 0V, it CAN'T be more than 20V, unless you add a zener.

When the MOSFET turns on, it will look like a few ohm resistor between 0V and GND. There will be a small voltage drop on it dependent on the current through it.

It is like a switch on the negative side of supply. It does not matter if you break the circuit at positive or negative side of the battery, it will still break.
Good enough is the enemy of the best.
 

Offline electroguy

  • Regular Contributor
  • *
  • Posts: 78
  • Country: au
Re: Mosfet power switch with auto-off
« Reply #15 on: June 12, 2012, 11:40:08 am »
I guess it's CR2032 lithium battery powered? If so, I'd have a problem with that 10k pulldown on MOSFET gate, which would have been eating your battery capacity. It may not look like much, but these CR2032s are pretty wimpy. Also I'd put a few uF cap across the CR2032, the internal resistance is pretty awful.

Yeah, or similar battery. Would this loss be through the pic then, considering the switch is NO, so you really just have pic -> 10k -> gnd?

I agree, you would be lucky if this thing lasts 1 to 2 months turned "off" MAYBE 3 if you are lucky.
Why not just bite the bullet and get a high side switch? or make one using a few p and n type fets. that way your product should last 8 to 10 years turned "off"
I know cost is always a factor, but you are only talking about an extra 15 to 20 cents for a HSS over the 2n7002. A HSS is about 25 to 30c and a 2N7002 is about 5 to 10c
Can you afford the extra 20 cents to make your product last 30 to 50 times longer?! If not, just make your own using a few FET's, might only cost you 5 to 10c more.
There are 10 types of people that understand binary, those that do and those that don't!
 

Offline 8086Topic starter

  • Super Contributor
  • ***
  • Posts: 1085
  • Country: gb
    • Circuitology - Electronics Assembly
Re: Mosfet power switch with auto-off
« Reply #16 on: June 12, 2012, 05:37:38 pm »
Okay, so here's an attempt at a high side switch



Included the diode so the PIC can take the button as an input. Vf is only 0.26V @ 10mA and the NMOS threshold is max. 2.3V so I think that should be okay.

Think it should work better than the previous design? I am finding it difficult to imagine unexpected battery drain paths, maybe there is a problem with R5 and R6 when it is switched off?
 

Offline electroguy

  • Regular Contributor
  • *
  • Posts: 78
  • Country: au
Re: Mosfet power switch with auto-off
« Reply #17 on: June 12, 2012, 11:15:33 pm »
much better.
the diode is a good idea, that way you can use the switch to also turn off if you want, in addition to software time out auto power off.

Also, does RC2 have internal pull down (i haven't checked the data sheet). If not, don't forget to add it externally, because the switch can only switch high.

The only thing is the choice of fet's. i haven't checked your data sheet, but you want to make sure you get a decent on VGS voltage. I had a quick glance, it says VGS 3V, which is probably no good for your circuit, as your battery drops off and gets 2.9, 2.8, 2.7 etc... what will happen? check the data sheet carefully.
There are 10 types of people that understand binary, those that do and those that don't!
 

Offline 8086Topic starter

  • Super Contributor
  • ***
  • Posts: 1085
  • Country: gb
    • Circuitology - Electronics Assembly
Re: Mosfet power switch with auto-off
« Reply #18 on: June 12, 2012, 11:34:00 pm »
Forgive me if I've missed something, but the datasheet seems to be saying that Vgs is max. 2.3v, for both N and P type (not accounting for polarity)?

http://www.diodes.com/datasheets/DMG6602SVT.pdf

So with the diode voltage drop (assuming it's between the 0.2v @ 1mA and 0.26v @ 10mA to be safe) I think it should definitely be good down to a battery voltage of ~2.6v?

EDIT: I just realised, I think I must have the P-channel fet upside down?
« Last Edit: June 12, 2012, 11:50:23 pm by 8086 »
 

Offline Short Circuit

  • Frequent Contributor
  • **
  • Posts: 439
  • Country: nl
    • White Bream electronics R&D
Re: Mosfet power switch with auto-off
« Reply #19 on: June 12, 2012, 11:41:21 pm »
I don't think there will be a problem with that. When the PIC starts choking due to low voltage, its drivers will die off and the 10k pulldown on the gate will finish the job. It's not necessary to output LOW to turn off, merely stop outputting HIGH will do. It will just be slower.
Probably wrong; the pin goes to negative voltage, which the input diodes don't allow beyond 0.6V. So the FET gate becomes about VCC-0.6V.
 

Offline electroguy

  • Regular Contributor
  • *
  • Posts: 78
  • Country: au
Re: Mosfet power switch with auto-off
« Reply #20 on: June 13, 2012, 12:35:24 am »
Forgive me if I've missed something, but the datasheet seems to be saying that Vgs is max. 2.3v, for both N and P type (not accounting for polarity)?

http://www.diodes.com/datasheets/DMG6602SVT.pdf

So with the diode voltage drop (assuming it's between the 0.2v @ 1mA and 0.26v @ 10mA to be safe) I think it should definitely be good down to a battery voltage of ~2.6v?

It's the P type you are worried about, as that is the one passing the higher current. The N type is only passing the current of the 1M resistor, so it will probably work at under 2V (maybe as low as 1V or less, so maybe add a pull down to the gate of the N fet, so it doesn't turn back on while the PIC is shutting down...). But the P type, you want that to have the minimum resistance when on, so you don't waste power on it. Briefly looking at it, it should be OK, so you should have no problems with a battery voltage as low as 2V, depending on your overall circuit current consumption...

EDIT: I just realised, I think I must have the P-channel fet upside down?
yes, good pickup, i didnt notice! haha
There are 10 types of people that understand binary, those that do and those that don't!
 

Offline 8086Topic starter

  • Super Contributor
  • ***
  • Posts: 1085
  • Country: gb
    • Circuitology - Electronics Assembly
Re: Mosfet power switch with auto-off
« Reply #21 on: June 13, 2012, 12:54:57 am »
Awesome, thanks.

The upside down fet also explains the weird simulation results i've been having - I just corrected and tried again and this time got the results i expected.

So, here's what I have now, I think it's all there, are 1M pullup/down appropriate, they will surely be best for battery life, or should I go for 100k, or even 10k? The 1k resistors on the PIC, would it be worth swapping them with 1M resistors as well, just in case there's some leakage through the PIC, or is leakage through the PIC not a problem with the inclusion of the high side switch, as the available current for everything will be determined by Q3?

 

Offline electroguy

  • Regular Contributor
  • *
  • Posts: 78
  • Country: au
Re: Mosfet power switch with auto-off
« Reply #22 on: June 13, 2012, 01:48:28 am »
So, here's what I have now, I think it's all there, are 1M pullup/down appropriate, they will surely be best for battery life, or should I go for 100k, or even 10k? The 1k resistors on the PIC, would it be worth swapping them with 1M resistors as well.
looking at your original circuit with the op amp, you are already using 100k. So if you want to minimise your BOM, i suggest you make R4, R6, R7, R8 all 100k (or you can leave R4 1M if you want to save that extra little bit of power). the PIC has a typ 0.1uA and MAX 1uA input pin leakage current, so 1M is probably a touch too big if you want to cover the full temperature range. R5 can stay 1k or 10K, (or at least something 10 times smaller than R7, as you have a voltage divider).
Also, make sure your internal pullups on RA2 and RC2 are OFF.

or is leakage through the PIC not a problem with the inclusion of the high side switch, as the available current for everything will be determined by Q3?

That's right! much better solution, im sure you agree! If your P and N FET are low leakage (sorry i don't have time to check your data sheet), you should get 10 years+ "off" time with this using a CR2032 lithium. Your main concern now would be the "on" current usage!
There are 10 types of people that understand binary, those that do and those that don't!
 

Offline 8086Topic starter

  • Super Contributor
  • ***
  • Posts: 1085
  • Country: gb
    • Circuitology - Electronics Assembly
Re: Mosfet power switch with auto-off
« Reply #23 on: June 13, 2012, 07:47:03 pm »
Awesome, thanks  ;D
 

Offline electroguy

  • Regular Contributor
  • *
  • Posts: 78
  • Country: au
Re: Mosfet power switch with auto-off
« Reply #24 on: June 14, 2012, 01:29:39 am »
no problem!
there's lots of different ways to do it. You could probably get your original circuit working, but i think your final version is a bit better. Don't forget to look at HSS's, you might find some cheaper than what you can make yours, or maybe not, but it doesn't hurt to have a look at what's available.
There are 10 types of people that understand binary, those that do and those that don't!
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf