128
\$\begingroup\$

I'm going to start developing a USB 1.1 device using a PIC microcontroller. I'm going to keep one of the USB ports of my PC connected to a bread board during this process. I don't want to destroy my PC's USB port by a short circuit or connecting \$\pm\$Data lines to each other or a power line accidentally.

How can I protect the USB ports? Does a standard USB port has built-in short circuit protection? Should I connect diodes, resistors, fuses on/through/across some pins?

enter image description here

\$\endgroup\$
6
  • 4
    \$\begingroup\$ Using a resettable fuse on the VCC would be a good start, assuming you've rated it correctly. I can't speak for how they'd work on a data line though. \$\endgroup\$
    – Polynomial
    Commented Dec 22, 2013 at 18:17
  • 1
    \$\begingroup\$ The data lines would need at least a TVS, or even better, optoisolation. \$\endgroup\$ Commented Dec 22, 2013 at 19:12
  • 1
    \$\begingroup\$ I think modern mainboards are somewhat tolerant. When tinkering around with an AVR I accidentally connected GND to VCC and besides the device being disconnected by the system (i.e. windows played the "device disconnected" sound) nothing happened at all. It might be worth noting that it was no direct usb connection. VCC came through the ISP cable (which got it from USB) and GND came through an USB=>serial cable. \$\endgroup\$ Commented Dec 23, 2013 at 0:14
  • 1
    \$\begingroup\$ Most modern computers have protection against this. They deactivate all USB ports when any of them is using more than the max USB throughput. On my mac, it shows a notification when this happens. \$\endgroup\$
    – Andrew
    Commented Dec 25, 2013 at 12:33
  • 2
    \$\begingroup\$ Do not, under any circumstances, trust the motherboard to protect you. I manage to blow up my motherboard, keyboard, mouse, and a few other USB peripherals when I put 24v on the 5V rail.... \$\endgroup\$
    – CurtisHx
    Commented Jun 10, 2015 at 11:54

7 Answers 7

89
\$\begingroup\$

This is to expand on Leon's suggestion to use a hub.

The USB hubs are not all created equal. Unofficially, there are several "grades":

  1. Cheap hubs. These are cost optimized to the point where they don't adhere to the USB spec any more. Often, the +5V lines of the downstream ports are wired directly to the computer. No protection switches. Maybe a polyfuse, if lucky.
    edit: Here's a thread where the O.P. is complaninig that an improperly designed USB hub is back-feeding his PC.
  2. Decent hubs. The downstream +5V is connected through a switch with over-current protection. ESD protection is usually present.
  3. Industrial hubs. There's usually respectable overvoltage protection in the form of TVS and resettable fuses.
  4. Isolated hubs. There's actual galvanic isolation between upstream port and downstream ports. Isolation rating tends to be 2kV to 5kV. Isolated hubs are used when a really high voltage can come from a downstream port (e.g. mains AC, defibrillator, back EMF from a large motor). Isolated hubs are also used for breaking ground loops in vanilla conditions.

What to use depends on the type of threat you're expecting.

  • If you're concerned with shorts between power and data lines, you could use a decent hub. In the worst case, the hub controller will get sacrificed, but it will save the port on the laptop.
  • If you're concerned that a voltage higher than +5V can get to the PC, you can fortify the hub with overvoltage protection consisting of TVS & polyfuse. However, I'm still talking about relatively low voltages on the order of +24V.
  • If you're concerned with really high voltages, consider isolated hub, gas discharge tubes. Consider using a computer which you can afford to lose.
\$\endgroup\$
3
  • \$\begingroup\$ What if we're concerned about other equipment which is connected to the same hub? Would an industrial hub suffice? \$\endgroup\$
    – user42875
    Commented Mar 25, 2015 at 18:19
  • 1
    \$\begingroup\$ @user42875 The answer is: possibly, it depends on a specific hub, and on your expected threat level. You would have to look at the specifications of your particular industrial hub. \$\endgroup\$ Commented Mar 25, 2015 at 20:37
  • \$\begingroup\$ @NickAlexeev ok, but how do you concretly make the difference on amazon between a "cheap" and "decent" hub? And why not using usb isolator (the cheapest cost arround 10$) \$\endgroup\$
    – JinSnow
    Commented Dec 3, 2018 at 8:05
34
\$\begingroup\$

Use a hub. They are quite inexpensive, and your USB ports will be perfectly safe no matter what your device does.

\$\endgroup\$
3
  • 13
    \$\begingroup\$ Well, not anything... those hubs are only rated for a couple of kV worth of isolation ;) \$\endgroup\$
    – Polynomial
    Commented Dec 22, 2013 at 18:25
  • 5
    \$\begingroup\$ If the hub is a passive one the power pins would be directly connected to the PC power lines, or they still offer power isolation? \$\endgroup\$
    – alexan_e
    Commented Dec 22, 2013 at 18:28
  • 3
    \$\begingroup\$ @Guido Bad story. That teacher of yours didn't know what he was doing. Lightning can jump across a civilian USB hub like no business. Proper lightning protection is done by shunting the bulk of the charge to ground (earth) through gas discharge tubes (GDT), and clamping the remaining charge with TVS Zeners. \$\endgroup\$ Commented Dec 22, 2013 at 21:01
19
\$\begingroup\$

As someone who does this for a living, any cheap hub in-line should give you 100% protection if your motherboard provides reasonable short-circuit protection. We use them all the time, even when doing ESD testing on our parts (15KV zaps are pretty entertaining), and have never blown one up or taken out a host port.

The Data lines from a cheap hub simply can't physically be connected to the PC - there must be a hub chip in between to separate the communications for the 4 or 7 ports that the hub provides. USB is not a bus like Ethernet - connecting multiple ports with wire simply doesn't work as too much of the signalling is based on DC levels. This hub chip will provide nearly foolproof protection between your device and the host port on the Data lines.

Power is a different issue. I had one motherboard that current limited the USB port with a fuse on the USB 5V line - not a resettable polyfuse but a melting wire fuse. An unintended short required major motherboard surgery. Power is the area that's most likely to cause problems. Buy a good powered hub (say, $25 worth), use the supplied adapter, and you're good to go.

If you're really paranoid, USB permits up to 4 hubs between the host and the device. Buy 4 different cheap powered hubs, hook them in line, and go for it.

Good Luck

\$\endgroup\$
2
  • 7
    \$\begingroup\$ Stacking multiple hubs has another advantage. In the early days of USB it wasn't unusual to see devices that wouldn't work well or at all if more than one hub away from the host. Regularly testing with four should shake out lots of little latency assumptions. Don't forget to also test for correct operation with fewer hubs too, once you're confident of operational safety. \$\endgroup\$
    – RBerteig
    Commented Dec 23, 2013 at 19:24
  • 6
    \$\begingroup\$ As someone who also connects prototype USB hardware to PCs, also be aware that flaky USB software can crash the host OS. We have issues with Windows disabling USB ports (requiring reboot). Also OSX will sometimes kernel panic due to bad USB data. \$\endgroup\$ Commented Dec 23, 2013 at 20:49
14
\$\begingroup\$

Analog devices makes a two chip solution for your problem, it provides full power and data isolation for the USB bus up to 12mbps, which should be fine for your needs:

http://www.ubasics.com/usb_isolator

Power - ADuM5000
Data - ADuM4160

enter image description here

There are a number of evaluation kits and breakout boards which make these easier to use for those not handy with a soldering iron.

\$\endgroup\$
2
  • 5
    \$\begingroup\$ And how does he protect the USB when he builds this and tests it the first time ;-) \$\endgroup\$
    – Myforwik
    Commented Dec 23, 2013 at 5:55
  • 9
    \$\begingroup\$ @Myforwik He'll use a hub! \$\endgroup\$
    – Ian Boyd
    Commented Dec 23, 2013 at 14:53
12
\$\begingroup\$

Use a wireless hub. I'd like to see someone create a USB device that can fry a motherboard through the wireless USB hub...

\$\endgroup\$
7
  • 2
    \$\begingroup\$ Would you like to try my 10 kV Tesla coil at an distance of a few centimeters? \$\endgroup\$ Commented Dec 23, 2013 at 16:55
  • 11
    \$\begingroup\$ Of course he would like to see that, who wouldn't? :) \$\endgroup\$ Commented Dec 23, 2013 at 18:01
  • 1
    \$\begingroup\$ @PaulBecotte The underwriters from UL. ;) \$\endgroup\$ Commented Dec 23, 2013 at 19:38
  • 1
    \$\begingroup\$ @BenjiWiebe Just let me hot-glue a usb cord to it first... \$\endgroup\$ Commented Dec 23, 2013 at 19:41
  • 1
    \$\begingroup\$ Spark gap coil with a neon sign transformer; it was a fun weekend project. \$\endgroup\$ Commented Dec 23, 2013 at 19:45
6
\$\begingroup\$

Using a (self-powered) hub is a good idea. Also, you could use a USB add-on card in your PC instead of your system's built-in USB ports, which would offer further protection.

\$\endgroup\$
0
\$\begingroup\$

If the device you are making runs of the power of the usb port a simple hub will do. If the device makes use of an external powersupply use isolation. I speak of this by experiance. One of my usb ports of my macbook pro is fried because of a groundloop with an externally powered arduino board. One of the other anwsers has a good solution for low cost usb isolation.

\$\endgroup\$

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