Author Topic: Circuit for low-side MCU-controlled soft power switch?  (Read 4387 times)

0 Members and 2 Guests are viewing this topic.

Offline PeabodyTopic starter

  • Super Contributor
  • ***
  • Posts: 2773
  • Country: us
Circuit for low-side MCU-controlled soft power switch?
« on: November 21, 2019, 05:57:05 pm »
This relates to the type of circuit in which a momentary pushbutton turns on power, and then the microcontroller takes over and keeps power on by asserting a GPIO pin - until it's ready to turn off its own power.

The circuit on the left in the attached picture uses a P-channel mosfet on the high side to switch power.  I've used it several times, and it works fine.  But I wondered if there was a low-side equivalent using an N-channel mosfet.  The circuit on the right is an attempt to do that, but I don't think it works.

If the power is on, and the MCU attempts to turn it off by bringing the GPIO high, or making it an input, I think current will flow from the 9V rail through the emitter and base of the PNP, into the GPIO pin, and through the upper protection diode to 5V.  If that happens, the PNP will stay on, and the MCU will be unable to do anything to turn it off.

Am I thinking right about this?  If so, how might this be made to work without adding another bipolar transistor?  It seems that to make it really equivalent, you would have to move the regulator to the low side, and make it 4V - not something you see every day.
« Last Edit: November 21, 2019, 05:58:57 pm by Peabody »
 

Offline MarkR42

  • Regular Contributor
  • *
  • Posts: 139
  • Country: gb
Re: Circuit for low-side MCU-controlled soft power switch?
« Reply #1 on: November 22, 2019, 10:19:51 am »
I am reasonably sure that you can do the low-side switching without using a 2nd transistor, i.e. just use the mosfet.

Provided it's the correct type of n-channel mosfet, i.e. the gpio is high enough to fully turn it on, then it should work. I've not tried that exact setup myself, but I have done low-side switching of other loads with a n-channel mosfet from a micro.
 

Offline PeabodyTopic starter

  • Super Contributor
  • ***
  • Posts: 2773
  • Country: us
Re: Circuit for low-side MCU-controlled soft power switch?
« Reply #2 on: November 22, 2019, 04:40:37 pm »
I am reasonably sure that you can do the low-side switching without using a 2nd transistor, i.e. just use the mosfet.

Provided it's the correct type of n-channel mosfet, i.e. the gpio is high enough to fully turn it on, then it should work. I've not tried that exact setup myself, but I have done low-side switching of other loads with a n-channel mosfet from a micro.

If you mean just driving the mosfet gate directly from the GPIO pin, I don't think that will work if what you're switching is the MCU's own ground.  If the positive rail is connected, but the processor's GND is not connected to the negative rail, then a GPIO pin will read as 5V, or 9V or whatever, with respect to the negative rail.  And that will turn on the mosfet.  So I think it would try to cycle on and off.
 

Offline MarkR42

  • Regular Contributor
  • *
  • Posts: 139
  • Country: gb
Re: Circuit for low-side MCU-controlled soft power switch?
« Reply #3 on: November 22, 2019, 08:19:15 pm »
Maybe a weak pull-down resistor would enable it to stay off? Like a 33k or something?
 

Offline PeabodyTopic starter

  • Super Contributor
  • ***
  • Posts: 2773
  • Country: us
Re: Circuit for low-side MCU-controlled soft power switch?
« Reply #4 on: December 04, 2019, 05:50:52 pm »
I tested the attached circuit, and it seems to work fine.  With the right mosfet, it also works on a 3.3V controller.

 

Offline EEisBS

  • Newbie
  • Posts: 2
  • Country: us
Re: Circuit for low-side MCU-controlled soft power switch?
« Reply #5 on: July 18, 2025, 09:28:40 pm »
Hi Peabody. I know this was years ago, but can you provide details into which PNP BJT, and which NMOS you used?

I tried building the circuit using a BC557 PNP BJT and a 2N7000 N-MOS. The button works to power the Arduino, but does not latch in power :-//  |O as is my goal.

I'd appreciate any insight you can provide! ;D
 

Online ledtester

  • Super Contributor
  • ***
  • Posts: 4207
  • Country: us
Re: Circuit for low-side MCU-controlled soft power switch?
« Reply #6 on: July 19, 2025, 12:07:53 am »
Hi Peabody. I know this was years ago, but can you provide details into which PNP BJT, and which NMOS you used?

I tried building the circuit using a BC557 PNP BJT and a 2N7000 N-MOS. The button works to power the Arduino, but does not latch in power :-//  |O as is my goal.

I'd appreciate any insight you can provide! ;D

First a sanity check... after powering up does your Arduino code make the GPIO pin an output and sets it to LOW? That's what is needed to keep the MOSFET on.
 
The following users thanked this post: EEisBS

Offline Smokey

  • Super Contributor
  • ***
  • Posts: 3885
  • Country: us
  • Not An Expert
Re: Circuit for low-side MCU-controlled soft power switch?
« Reply #7 on: July 19, 2025, 03:12:42 am »
Search "load switch" on digikey.  Sort by "high side".  Diode OR the microcontroller pin and physical switch voltages to the enable of the load switch.
 

Offline PeabodyTopic starter

  • Super Contributor
  • ***
  • Posts: 2773
  • Country: us
Re: Circuit for low-side MCU-controlled soft power switch?
« Reply #8 on: July 19, 2025, 03:17:00 am »
The PNP would have been a 2N3906.  I don't know about the mosfet.  It would need to be logic level, with a threshold voltage of maybe 2V or lower.  I think the ones you used should work if you make the GPIO output low.

« Last Edit: July 19, 2025, 03:20:24 am by Peabody »
 
The following users thanked this post: EEisBS

Offline EEisBS

  • Newbie
  • Posts: 2
  • Country: us
Re: Circuit for low-side MCU-controlled soft power switch?
« Reply #9 on: July 21, 2025, 03:33:37 pm »
Thanks for your replies. I did in fact have a silly error in my Arduino script. The circuit works perfectly to latch power into the MCU.

Has anybody used (a version of) this circuit that allows the same button press to be used to de-latch power from the MCU? :popcorn:
 

Online tooki

  • Super Contributor
  • ***
  • Posts: 15982
  • Country: ch
Re: Circuit for low-side MCU-controlled soft power switch?
« Reply #10 on: July 21, 2025, 04:45:08 pm »
One approach is to add some diodes and resistors so you can use another GPIO to monitor the button state, and then when you detect a press, you can run whatever cleanup/shutdown code you need, and then at the very end, turn off the GPIO that’s holding it on. I’ve done this before, but set up the code so that simple presses change modes, and then holding down the button shuts down.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

-->