VBUS power control on USB Host shield

Power switch populated

Power switch populated

About a month ago I started shipping USB host shields built on PCB bearing revision number 2.0.1. On this PCB I added a new feature, suggested by Andrew Kroll – a VBUS power switch. The board comes with power switch unpopulated and if you don’t care about this feature it can simply be ignored. However, if you do care about power control, read on.

The ability to turn VBUS on and off at will can be very beneficial. In battery-powered projects the run time can be significantly increased by powering on USB device only when needed. Some other devices can’t even be initialized reliably without a powercycle. Also, many power switches incorporate current limiting circuitry allowing VBUS overload detection and prevention.

An example of populated power switch is shown in the title picture (click on it to make it larger). A is a power switch IC (in this case, Micrel MIC2004). B is 0.1uF ceramic capacitor in 0603 package. C is a wire from MAX3421E GPX pin to the ENABLE pin of the power switch. Finally, D is VBUS Power jumper which needs to be opened, as pictured. Current revision of USB Host 2.0 library is needed to support power control.

Board Layout

Board Layout

Next picture will be used to explain the details of the power control circuitry.

  • Arrow A points to the jumper which needs to be cut open
  • Arrow B shows the position where 0603 0.1uF ceramic capacitor needs to be placed
  • C and D show the places for the power switches (only one switch is needed). Many switches packaged in SOT23-5 and SOT23-6 use this footprint, use On Semiconductor NCP380 as a reference. Also, some other 5 pin switches, such as Maxim MAX4793 and Micrel MIC20xx, will work while placed on SOT23-6 footprint, as shown on the title picture.
  • Certain switches, such as 6 pin NCP380, allow for adjustable current limit. The position for current setting 0603 resistor is marked ILIM – for the value of this resistor consult the datasheet for the part you’re planning on using
  • Many switches provide FAULT pin to signal various fault conditions, like output overload, reverse votage, or over-temperature. The pin is typically active low open drain type. It is broken out to a pad labelled VBUS OVL. The signal can be used in several different ways. A LED with a series resistor can be connected across VBUS OVL and a power rail. Also, it can be connected to a MCU input. In this case, a position labelled 10K should be populated with 0603 resistor, typical value is 10K. The other (upper) end of the resistor is connected to 5V rail with a trace which is placed under the letter K; if 3.3V level signal is desired, cut the trace and solder the upper end of the resistor to the 3.3V rail.
  • The power control signal is labelled VBUS EN. The library uses GPX pin for vbusPower() and Init() functions. There is also a variant of Init() function which will hold the VBUS off for the number of milliseconds passed to it as a parameter. See usbhost.h file for details. Also, testusbhostFAT.ino demonstrates usage of powercycling Init().

Now, let’s talk about side effects of this feature. USB was originally designed with no power control over VBUS. Embedded USB host spec, added some time after USB 2.0 release, allows for VBUS power control as an option. In USB OTG, VBUS power control is a requirement. Even though, many USB devices were designed with a PC as a USB host in mind (i.e., no power control), where the only way to powercycle the device is to physically disconnect and connect it to the host. This is relatively slow operation which in most cases gives enough time for the capacitors inside a device to discharge. With a power switch, a powercycle can happen very fast; a device may not drain its power rail capacitors to a sufficiently low level and become unresponsive as a result.

The following oscilloscope screenshot shows the worst case. Here, nothing is connected to USB port of the shield and 20uF VBUS capacitor discharges very slowly. The time between vertical cursors is 10 minutes and even this time is not enough to discharge VBUS all the way to ground.

MAX4793, empty VBUS

MAX4793, empty VBUS

Next screenshot shows the VBUS discharge curve with high-capacitance low speed device attached. The time between VBUS enable pulses is 1 second; the VBUS voltage at the end of discharge is almost 2 V. Under these conditions this particular device (a PC remote controller) will fail enumeration 50% of the time.

MAX4793, PC remote

MAX4793, PC remote

Low speed HID devices (keyboards, mice, and joysticks) as well as mass storage devices (especially mechanical ones, like microdrives) typically require long power off times, 1-3 seconds. Most other USB devices discharge VBUS much faster – typically in tens of milliseconds or less. If less time or more certainty is desired, there exists a variant of the power switch which would place a shunt from output to ground at turn off, significantly speeding the discharge. The following screenshot shows empty VBUS discharge using load-discharging switch (Micrel MIC2004). As can be seen, after de-asserting ENABLE the bus is at the 0V potential in 12ms!

MIC2004, empty VBUS

MIC2004, empty VBUS

Next screenshot shows VBUS discharge with a PC remote attached. The discharge is not that great but still much faster than on screenshot number 2 where non-load discharging switch was used.
MIC2004, PC remote

MIC2004, PC remote

Even though MIC2004 looks like a good solution using it is not always possible. First, the minimum quantity I was able to find so far is 10 pieces for $1.60 a piece. At the same time, NCP380 is available in single quantity for $0.30. Second, the range of available currents is limited. Lastly, the FAULT signal is not available so monitoring over-current with this part is not possible.

Here is the sketch that I use to test the power switching. When using it, please connect (any) USB device to the shield, otherwise voltage changes will be difficult to observe (see screenshot 1).

/* USB Host Shield 2.0.1 VBUS power control test routine */
#include <avrpins.h>
#include <max3421e.h>
#include <usbhost.h>
#include <usb_ch9.h>
#include <Usb.h>
#include <usbhub.h>
#include <avr/pgmspace.h>
#include <address.h>
USB Usb;
void setup()
  Serial.begin( 115200 );
  if (Usb.Init() == -1) {
    Serial.println("OSCOKIRQ failed to assert.");
void loop()
  Usb.vbusPower( vbus_off );
  delay( 2000 );
  Usb.vbusPower( vbus_on );
  delay( 100 );

This is it for today; please try this mod and let me know.


3 comments to VBUS power control on USB Host shield

  • Mikey

    There is a new spec for hosts supplying power to slave devices – see wikipedia and the link to

    It appears that if you want your MAX3421 USB Host to supply something like a Galaxy Tab with enough power for it to operate, you need to signal to it that you can do it, otherwise it assumes you can’t. This is done by putting a voltage on the D- rail. Is this something that can be done with this USB Host Shield – either with a hardware modification or through programming the MAX3421 ?

    • MAX3421E doesn’t support this spec. “Putting a voltage on D-” is a standard way a peripheral would signal its speed to a host so I doubt you can use it on a real USB port. Pulling up data lines is widely used on “charger-only” ports though.

  • ben

    Hi , is there any way at all to inject extra 5v power over a usb shield USBhost port ?
    I’m using a usb hub just to get enough power to run a USBmidi control surface.

    Can I just change the 5V supply ? or the 5v has to come from the actual shield ?

    thanks , ben