I have a microcontroller with USB Host, and I need to be able to programmatically power-down the USB peripheral. The reason is that I need to power cycle the USB peripheral to reset it (a necessary evil unfortunately).

The microcontroller simply has D+D- lines for the USB, and power is expected to be supplied by me, which I take from the 5V rail.

I thought I would use some variation of a TIP NPN to simply switch the 5V going to the USB peripheral, and control that with a GPIO from the micro - however, given that USB is designed to never have the data lines connected when the power lines are not - I no longer think this is such a good idea.

Can anyone suggest a simple circuit which would achieve what I'm trying to do? Or if my transistor approach is actually OK.


[EDIT] This is the Microcontroller http://www.acmesystems.it/arietta The connected peripheral is a CDC_ACM serial device.

  • \$\begingroup\$ Which speed are you using? Full speed, high speed, SuperSpeed? Can your MCU host disconnect its own data pins from the device? \$\endgroup\$ – Adam Haun Dec 8 '14 at 20:02
  • 2
    \$\begingroup\$ Tristate your data pins and then cycle power. \$\endgroup\$ – Passerby Dec 8 '14 at 20:05
  • \$\begingroup\$ Hi @AdamHaun, the micro specs the port as a Full-Speed device. Don't know about the ability to disconnect data lines... I'll also ask on their forum. I have update my question with a link to the device. \$\endgroup\$ – Adam Dec 8 '14 at 20:07
  • \$\begingroup\$ Hi @Passerby - any possibility you could elaborate? I'm more of a software guy than hardware... \$\endgroup\$ – Adam Dec 8 '14 at 20:08
  • 1
    \$\begingroup\$ How about using a set of Reed Relay (1 Form A also known as SPST-NO) such as Coto Technology 9001-05-00. Total 3 relays (VBUS, D+, D-), since you don't need to disconnect GND. (Mouser carries a 3 Form A, but it's more expensive than using 3 separate 1 Form A relays.) By using a mechanical reed switch instead of transistors, this should avoid affecting the impedance-matching and device-insertion-detection resistor network, being as close as possible to actually unplugging the cable. Assuming you keep the relays close and try to avoid impacting the USB controlled-impedance traces too much. \$\endgroup\$ – MarkU Dec 9 '14 at 1:14

The Transistor approch is OK, but I recommend using a P-channel MOSFET to switch the +5 Volt.

USB data lines are pulled low on the host side anyway, so switching just the power line is safe. But don't try to switch GND.


"however, given that USB is designed to never have the data lines connected when the power lines are not - I no longer think this is such a good idea."

Do you mean the USB standard is designed to never have ... or your design need to have the data lines disconnected when the power is removed?

It seems you are working as a USB host, right? The USB standard recommends a pull-down resistor on the downstream facing transceivers. And per the datasheet p. 1562:

Self powered devices can detect 5V VBUS using a PIO. When the device is not connected to a host, device power consumption can be reduced by the DETACH bit in UDPHS_C TRL. Disabling the transceiver is automatically done. HSDM, HSDP, FSDP and FSDP lines are tied to GND pull-downs integrated in the hub downstream ports.

And in p. 1566, it shows registers to control the pull-downs, you can enable/disable the pull-downs. So when you remove the power to your USB slave devices, you can just control the data line states by registers, the external switches may not necessary.

  • \$\begingroup\$ Hi @diverger, thanks for your response. I read in an article that one should disconnect data before power to "prevent the device from attempting to draw power from the data lines". Having said that, this device is self powered, but it does use the 5v line to detect connectivity. \$\endgroup\$ – Adam Dec 9 '14 at 20:07
  • \$\begingroup\$ @Adam: Can you give the article's name or link? In this situation, i think you can just set the 'DETACH' pin, and enable the pull-downs, then all data lines are grounded through a resistor. If you set 'DETACH' but disable pull-downs, it will all be high-impedance. \$\endgroup\$ – diverger Dec 10 '14 at 1:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.