I’ve been experimenting with MOSFETs for the first time and I must still be missing something fundamental. Here’s what I’m trying to do:
I have two circuit boards that are tied together via ground (they communicate with each other.) I want Board A to be able to turn on or off the power to board B using a GPIO trigger for the MOSFET (3.3V/GND) pin C on Board A.
The problem is that when I have Board B hooked up through the MOSFET, it powers up regardless of what the Control pin level is set to. I have attached the graphic of how I have the two boards connected via the MOSFET breakout below.
If I Do-Not have board B hooked up to the device side of the NPN MOSFET, and I monitor the voltage on the output side of the MOSFET with a multi-meter, when I change the C pin level from GND, to 3.3V to GND, I see the voltage change from just a few millivolts to the RAW input voltage and back to near 0 like I would expect. But when the board is connected to the device side of the MOSFET, it powers up regardless of the C ping level.
I’ve tried both SFE COM-10256 and PRT-11214 to do this - I’ve also tried both NPN and PNP type MOSFETS and they basically behave the same way - Board B is always powered up when it’s connected regardless of the C pin level.
I’m obviously missing something really basic with how MOSFETS are supposed to operate, but it seems so simple - not sure what I could be doing wrong. My expectation is that I can turn on and off the power to Board B just by toggling the Pin C level.
Mosfets do not come in NPN or PNP. Only in N or P type. Those types you mentioned are BJT (bipolar junction transistors) types. But this is just semantics.
How about the pin states configuration of that GPIO port? I assume you drive it by some microcontroller. It kinda is important if it is set as an input or output, if it is set to output low or high or if it has pull-up resistors enabled.
In your drawing you left the GPIO ground pin unconnected. Is that internaly connected to the 12Volt GND? Make sure it is, otherwise you might want to connect it through externally.
It is very very simple: The N MOSFET is switching the ground connection but you already have a hard wired connection so it does nothing.
If you try and control a P channel MOSFET ont he high side without a driver, both the 3.3V and 0V output levels on the control pin will turn on the P FET. (Source = 12V and gate = 3.3V.)
UhClem:
It is very very simple: The N MOSFET is switching the ground connection but you already have a hard wired connection so it does nothing.
If you try and control a P channel MOSFET ont he high side without a driver, both the 3.3V and 0V output levels on the control pin will turn on the P FET. (Source = 12V and gate = 3.3V.)
Thank you everyone so far.
Just to answer a few questions and clarify… The 3.3V/GND are actual pins on Board A I am using to drive C high or low, but I am expecting to use a GPIO pin from a micro (and yes, definitely know I need to set the pin direction.) The GPIO GND pin is the same bus as the other board to board GND.
I think I get the N MOSFET switching ground, which is why I started with P, but after it not working, tried N.
So, I think the question I have now is how to control the P channel on the high side with a driver. You have described what I’m seeing which is that regardless of whether C is high or low by connecting it to 3.3V or GND on Board A, the MOSFET is on. So, what is the “driver” I need in this case? I thought I could drive it high or low just by connecting C to 3.3 or GND - this is likely the thing I’m missing.
Ok, here is some information I discovered about this setup.
As suggested, I disconnected the direct GND connection between the two boards and left an N MOSFET in the breakout. I had previously disconnected the serial GND between the two boards as well which is why that one wasn’t shown in the original diagram though I had mentioned the two boards communicate with each other (i.e.: UART to UART.)
After disconnecting the explicit ground, I retried the power-up and both boards still powered up regardless of level of C pin - despite there not being a hardwired ground any longer (the N MOSFET would be switching ground.)
Next I disconnected the Tx/Rx lines that connect the two UARTs between Board A and B. Low and behold, it began acting the way I was expecting. If I connected C to 3.3V on Board A, Board B powered up. If I connected C to ground on Board A, Board B powered down like I expected.
It acts like the serial line is somehow completing a ground connection so all explicit grounds are gone, but when the tx/rx is connected, Board B will power up when it shouldn’t. Is it possible that when the serial line is driven high or low by virtue of it sending a character, that when it’s low, it’s becoming the board ground in which case it acts like it did when I had the explicit ground on?
Will go back to the P for the high-side which is where I think I should be with this anyway.
I’ve attached a new diagram which I think shows the configuration:
You are obviously completely unaware of the ESD protection diodes you get for free (even if you don’t want them) on almost every CMOS device. These will clamp the pin to no more than a diode drop above or below the power rails. But if these diodes conduct more than a few milliamps, the chip will enter latchup (thanks to parasitic SCR’s you also get for free) and possibly destroy the device.
With your low side NMOS switch off, the board electronics are still connected to 12V and this is going to result in out of spec voltages applied to the controlling board. Given the other connections, you really should be using a high side switch just to protect your electronics.
Note that this problem goes the other way as well. Assuming a high side power switch that is off, if your UART output is high (and it probably is), the ESD diode on the powered down UART will be conducting. Not generally a good idea so make sure to drive those pins to ground when the power is off.
It acts like the serial line is somehow completing a ground connection so all explicit grounds are gone, but when the tx/rx is connected
Correct, that's what's happening. Going to a "high side" FET, given you'll be switching 12v with a 3.3v signal, is problematical. If speed isn't a concern, then an old fashioned relay may be the easiest way to go. Otherwise you need another element to control the gate of the P channel FET switch. And even I recall there may be an issue w/getting the FET to completely turn off. You may need to bring the gate above Vsource for a short time, that's why there are charge pump FET driver ICs. I'll see if I can find the article I read on this. But meanwhile read this.
Thank you for everyone’s comments and pointers. The thing I’m getting out of this is a MOSFET is the wrong solution for this problem; a relay the most straightforward.
If you had this problem where two boards needed to communicate (UART to UART or GPIO to GPIO, sharing a common ground), but one needed to control the power status for the other, what do you think the best solution would be if it hasn’t already been mentioned?
Normally, mosfets would be the ideal solution, but not with the voltages you’re using. Typically, for a high side switch like you thought you were using, the gate voltage needs to be a few percent above the controlled voltage - ie to turn 12V on and off, you need probably 15V on the gate of a properly selected device. Low side switching of power has lots of problems unless it’s a simple device like a relay ( one side of the coil to +12V, the other side through the fet to ground). You could use a solid state relay (SSR), they typically have a logic level control input to turn power on and off. Or a mechanical relay.
Dave Mueller:
Normally, mosfets would be the ideal solution, but not with the voltages you’re using. Typically, for a high side switch like you thought you were using, the gate voltage needs to be a few percent above the controlled voltage - ie to turn 12V on and off, you need probably 15V on the gate of a properly selected device.
Only if you are using a N channel FET as a high side switch. With a P channel device that has its source connected to 12V, if the gate is also at 12V, it is off. You have to lower the gate about Vgs(threshold) below the source to turn it on so it is easy to add a simple NPN driver. (A [random example. More complicated drivers are required if turnoff time of the FET is a concern.)
With the N channel FET you have to connect the drain to the 12V power source. If you also connect the gate to 12V then the source will never rise above 12V - Vgs(threshold). This is usually more voltage drop (and power dissipation) than is tolerable. So there are devices specially designed to drive high side N FETs.](http://cq.cx/pics/int-switch-p-fet.png)
UhClem:
With the N channel FET you have to connect the drain to the 12V power source. If you also connect the gate to 12V then the source will never rise above 12V - Vgs(threshold). This is usually more voltage drop (and power dissipation) than is tolerable. So there are devices specially designed to drive high side N FETs.