P-channel mosfet switch

Status
Not open for further replies.

Epyon

Well-known member
More an electronics question. I'm using a ATTiny45 to supervise a project running around a T3.2. When the ATTiny receives a reset signal from the Teensy (asserting a digital input) it cuts power to the project by turning a p-channel mosfet switch (FDN360p) off. The ATTiny gets its power from the power supply directly so it's not affected. It's possible to turn the mosfet on manually by setting a jumper connecting the gate to ground, if the jumper is in the other position the digital output of the ATTiny pulls it down to ground (digitalwrite low) to put it on. The voltage drop over the ATTiny input should still be well below the gate turn-on voltage (around 2V for the FND360P)). See attached circuit diagram.

mosfet.png

If I use the ATTiny to pull the gate down to ground by connecting the gate to the digital output pin, the mosfet won't turn on. The digital pin of the ATTiny is instead pulled up to VCC, but no current runs through R2. Moreover it seems the whole ATTiny stops functioning. If I program another pin to switch together with the pin connected to the gate, it also stops. If I remove the jumper, or set in the other direction (connecting the gate to ground directly) the pins start switching again. The VCC to the ATTiny stays stable at 5V.

If I build the circuit with R2 but without the mosfet on a breadboard, it functions fine. So I must be missing something here with the mosfet?
 
Last edited:
Try adding a 0.1 uF capacitor between VCC & GND close to the ATTINY. Also add a 220 ohm resistor between pin 2 and the mosfet gate.

The mosfet gate is a big non-linear capacitor. If you pull it low through the strong digital output, in the short term high frequency response, you're basically pulling VCC to ground. Adding series resistance will instead look like a resistive load suddenly being added, rather than whatever very low resistance the pin 2 driver has. The capacitor will help stabilize the power in the presence of such a rapidly changing load.
 
As a reference for anyone stumbling upon this thread while looking for the best way to use a mosfet as switch: after implementing the fix Paul suggested above, I still got problems with inrush currents. Anything above 500mA would make the mosfet switch between on and off states rapidly. The solution was adding a capacitor between the mosfet gate and drain. For me a 100nF capacitor worked fine.

mosfetswitch.jpg

This capacitor lowers the turn-on speed of the mosfet switch, thereby limiting the inrush current. More information can be found in this application note.
 
Status
Not open for further replies.
Back
Top