What measures should I take to protect the USB ports of my PC during development of a USB device?
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":
- 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. - Decent hubs. The downstream +5V is connected through a switch with over-current protection. ESD protection is usually present.
- Industrial hubs. There's usually respectable overvoltage protection in the form of TVS and resettable fuses.
- 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.
Use a hub. They are quite inexpensive, and your USB ports will be perfectly safe no matter what your device does.
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