126

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

kinokijuf
  • 906
  • 2
  • 9
  • 18
hkBattousai
  • 13,913
  • 31
  • 114
  • 190
  • 4
    Using a [resettable fuse](http://en.wikipedia.org/wiki/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. – Polynomial Dec 22 '13 at 18:17
  • 1
    The data lines would need at least a TVS, or even better, optoisolation. – Ignacio Vazquez-Abrams Dec 22 '13 at 19:12
  • 1
    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. – ThiefMaster Dec 23 '13 at 00:14
  • @ThiefMaster "somewhat" - I still wouldn't trust it. I've fried a brand new board (disabling half the USB ports) in the process of plugging in a standard MicroUSB3 connector - must've accidentally shorted some pins somehow. Point is, it's still quite easy to damage. – Bob Dec 23 '13 at 03:40
  • 1
    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. – Andrew Dec 25 '13 at 12:33
  • 2
    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.... – CurtisHx Jun 10 '15 at 11:54

7 Answers7

88

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.
Nick Alexeev
  • 37,739
  • 17
  • 97
  • 230
  • What if we're concerned about other equipment which is connected to the same hub? Would an industrial hub suffice? – user42875 Mar 25 '15 at 18:19
  • 1
    @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. – Nick Alexeev Mar 25 '15 at 20:37
  • @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$) – JinSnow Dec 03 '18 at 08:05
34

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

Leon Heller
  • 38,774
  • 2
  • 60
  • 96
  • 12
    Well, not *anything*... those hubs are only rated for a couple of kV worth of isolation ;) – Polynomial Dec 22 '13 at 18:25
  • 5
    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? – alexan_e Dec 22 '13 at 18:28
  • 3
    @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. – Nick Alexeev Dec 22 '13 at 21:01
19

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

Frank Schwab
  • 191
  • 2
  • 7
    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. – RBerteig Dec 23 '13 at 19:24
  • 6
    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. – David Poole Dec 23 '13 at 20:49
13

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.

Adam Davis
  • 20,339
  • 7
  • 59
  • 95
12

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

BenjiWiebe
  • 431
  • 2
  • 16
6

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.

John
  • 61
  • 1
0

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.