Electronics > Beginners

Multiple uCs/GPIO devices to single mosfet gate; Goal to shut down RPi cleanly

(1/3) > >>

mortrek:
My goal is to have a uC power up a Raspberry pi with a MOSFET, and have the RPi take over the MOSFET control by also wiring it into the same gate so that it can decide when to power itself down.

Basically, uC sets MOSFET gate to high, turning on RPi. RPi sets its GPIO leading to the gate to high on boot. Even if uC's output goes low, the MOSFET stays high, keeping itself on. RPi does some stuff which takes an indeterminate amount of time. RPi is told to shut down, and shutdown script turns GPIO to gate OFF after doing all housekeeping/unmounting, thus shutting itself down cleanly.

Does this work? And do I need to include diodes to protect the IOs from each other? Or caps to maintain a clean signal? Anything else wrong with this?

Ian.M:
Nope.

You need the MOSFET to be a high side switch (i.e. in the positive side of the supply, not the ground) so either you need a P-MOSFET, which needs its gate pulled low to turn it on, or if you use a N-MOSFET, you need a gate drive supply that's significantly above the 5V rail the MOSFET is controlling.

However once you use a P-MOSFET, with a gate pullup resistor to keep it off, any number of transistors or switches can be used to pull the gate low to turn it on, and it wont turn off till they all stop pulling it low.  Be careful of ICs with open drain outputs - if they have a protection diode to Vcc they will pull down the gate if their Vcc supply goes away!

I/O pins and blocking diodes directly driving the MOSFET gate aren't a great idea as most MCUs have internal protection diodes so an un-powered I/O pin will drag down gate, turning the MOSFET back on, resulting in oscillation or a possibly half-powered state that may burn out the MOSFET.

N.B. later model PI B's have a smart power switching chip (or a PMIC) controlling power to the USB ports.  USB Vbus switches on fairly early in the bootup process and is switched off very close to the end of the normal shutdown sequence.   If you've got a PI that does this, you don't need to waste a GPIO for power control, just use Vbus with maybe a second or two delay, to give the startup sequence time to turn on Vbus, and to complete shutdown.

mortrek:
Seeing as how I'm a newbie, could you explain why I need to use a high-side switch? I'm currently using an NPN on the ground side of a circuit driven by a 3.5-5.0V voltage at the gate, with the voltage of the device switched at more like 9V, and it works very well. Is it because I want to use more than one driver for the gate?

ggchab:
Instead of controlling the MOSFET with the RPi, why not using that line to communicate with the µC that would then be the only device controlling the MOSFET ? Just a suggestion. I don't know if this can work with what you want to do.

Ian.M:
Why high side switch?

A low side switch is fine for 'dumb' loads or if the load doesn't have wired connections to any other devices, but is problematic for smart loads with external connections.

Lets take your example of a NPN transistor switching the ground of a load powered from 9V, e.g. an Arduino.  When the transistor is off, the Arduino Gnd (0V) rail will be up near 9V, as will any signals connected to Arduino I/O pins *AND* the ground and shell of the Arduino USB connector.  If those signal lines go to logic chips using the same 0V rail as the emitter of the switching transistor (and the 9V PSU 0v) they probably wont be very happy as the Arduino will attempt to drag  their inputs or outputs high, above the logic Vcc supply if its less than 9V, and power up via the ATmega328P I/O pin lower protection diodes.  Odds are it may exceed the logic and ATmega328P I/O pin current ratings, with a significant risk of damage both to the logic and the Arduino.  Also, if the 9V supply is ground referenced, plugging a USB lead into the Arduino will power it up if the other end is connected to anything grounded, (even a PC that's switched off!), as the 9V PSU 0V return current can bypass the switching transistor via the USB lead shield and the mains wiring ground between the USB host and the 9V PSU.

OTOH if you use a high side switch, all 0V/grounds in the system stay firmly tied together at the same level, It doesn't randomly power up when you plug in external connections, and the only constraints on interconnections to the switched device are that you mustn't try to drive a logic '1' into  any I/O while its off.

Navigation

[0] Message Index

[#] Next page

There was an error while thanking
Thanking...
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod