Go Down

Topic: USB P-FET incorrectly wired? (Read 3550 times) previous topic - next topic


I was looking at the schematics of how the power is automatically switched when using an external battery while connected to the USB.  From what I can tell the system is supposed to pinch off the +5V from the USB when the VIN is powered.  But doing some probing I find that it is not what happens. The schematic shows that the p-channel fet to do this switching is wired up backwards.  The USBVCC should be connected to the source and the +5V should be connected to the drain.

This post http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1278665496
also mentions this problem but the bug was never confirmed. It's hard to believe that it is a bug because so many arduino boards have this system. But using a single p-fet and some experimenting clearly show the current system is incorrect.

Can someone else please verify this so it can be corrected for the next version of the arduino board?


Nope, it's correct.

If VIN is plugged in, then the gate of the MOSFET gets 5V and keeps the P-channel MOSFET off. This is because the source (+5V) to gate voltage is 0 (since the gate is also at +5V).

If VIN is not plugged in then the gate is 0V and since USBVCC-0.7V appears at the +5V node through the body diode of the P-channel MOSFET, there is 5V-0.7V=4.3V between gate and source and the MOSFET turns on, bypassing the diode and now the full 5.0V appears at +5V.

The Gadget Shield: accelerometer, RGB LED, IR transmit/receive, light sensor, potentiometers, pushbuttons


Ahh, I'd forgot about the diode from drain to source.  My test circuit didn't have that.  It just had a raw P-FET.

But wouldn't the reverse work too? Connecting the USBVCC to source and +5V to drain.  The comparator will still turn the transistor on and off based on a voltage at VIN. If the USB is connected and there is no voltage on VIN then the gate will be low which will cause the transistor to turn on.  If there is a voltage at VIN then the gate will be high which would turn off the transistor if USBVCC is +5V.

If reversing the wires on source and drain will still work, what are the advantages of one way or the other? Why did they choose the current setup?

I'm still learning this stuff so please correct me if I'm wrong.


Reversing the P-channel FET would allow current to backfeed into the power line of the USB port through the drain-to-source diode.

The "one way or the other" question very much depends on actual voltages. This scheme, for example, could not be used to switch 12V like this.

The Quick Shield: breakout all 28 pins to quick-connect terminals


This scheme, for example, could not be used to switch 12V like this

To which "this" are you referring to? And, if you don't mind, I'm curious to understand why it cannot be used to switch 12V like you say.

Well, dang. I've actually already prototyped a board with the source and drain switched (my test circuit showed it to be correct, which I now see the flaw). So given my test board, I'm trying to predict what is going to happen if VIN is powered and the USB is plugged in.  I assume it is not desirable if there is a potential difference which allows current to run backwards into my laptop through the +5V line.  I just don't know if that will damage my usb ports or if it will be ok. The +5V output from the converter will most certainly be ~5V maybe slightly less (4.95). My converter is a buck converter so inrush on the output shouldn't be an issue because of the inductor (AFAIK). So I assume that as long as the USB +5V > than the converter +5V output then the potential difference will keep the current from flowing back into my laptop. Inevitably the current will flow back up so I'd like to know what to expect. Do you know if this will damage the usb port?


The whole auto voltage switching function used on the Arduino is one of the reasons I chose to buy a Seeduino board instead of a Arduino board. The Seeduino uses a simple two position switch to select usb or external power and can also function as a power on/off switch if one is only using one voltage source. Also if switched to the external power position there is no voltage connected to the USB serial convertor chip thus saving additional power consumption. The Seeeduino design is just a simpler more elegent solution in my opinion.


Go Up