# Protecting a laptop from USB connected devices

In the past couple of months I've managed to destroy 2 perfectly good laptops through programming development electronics through USB. I've been wondering what could be done to prevent this. A couple of ideas I've had (not sure how practical):

1. USB connector / hub with clamping 5V zener diodes on power and data lines
2. USB connector / hub with opto-isolators on data lines
3. supplying the usb connection with external power source plus previously mentioned idea

In combination with these ideas perhaps resistors on both 5v D+ and D- lines to limit current to say 200mA (enough for most of the devices I use).

Just wondered what some more experienced engineers than myself thought about these ideas and their practical implications?

• They sell optoisolated USB adapters specifically for this purpose. Jul 22 '17 at 21:47
• How exactly did you manage this? Is your laptop earthed and you plugged into a device with voltage on the ground? Did you feed power back on the 5 V line? Jul 22 '17 at 21:50
• @KingDuken: A schematic isn't enough. USB also requires proper routing in order to not turn the protocol into a pile of goop. Jul 22 '17 at 21:50
• I mainly work with Arduino and PIC based development electronics for controlling washing machines and vending machines (It wasn't the same device that destroyed both laptops). As its mainly just the risk of high voltage would the use of zener diodes be a simple cheap solution or would that mess with the data side of things? Jul 22 '17 at 21:56
• No, it wouldn't – these diodes would have to withstand the full power that your high-voltage source can supply, or they'll burn through, and then the laptop's protection diodes burn next. That'll all happen in milli-, if not microseconds, assuming that switching washing machines requires a rather beefy supply to drive relais reliably. Jul 22 '17 at 22:00

The real problem is not the unprotected USB port, the real problem is that your device puts you and your devices at risk of being connected to higher-voltage, relatively high-current sources.

You can solve transient overvoltage with clamping diodes, but these won't help if you power supply is strong enough – they will just fail, and then you're in the same situation as before, only milliseconds and the smell of burnt semiconductors farther.

Your problem is a bad one, for a lot of reasons, and your laptops are the least of that:

USB is meant to be handled manually (that's redundant wording), so if this fault kills your laptop, I don't have the strongest confidence that it's inherently save for human interaction.

There is, for good reason, design criteria for circuitry that involves switching higher voltages with lower voltages.

Generally: you need galvanic isolation between whatever any human (even a service technician) could touch during operation and the dangerous voltages.

Hence: strictly separate your USB controller and the things it switches. It's common practice to drive inductive or high-voltage loads using optocouplers, whose secondary side is driven by a separate power supply.

The board layout must make the high-voltage regions separate from the 5V/MCU environment. Only optocouplers, transformer cores, and relays can be allowed to cross that boundary. No compromises.

A typical problem is that your device's power supply ground has a completely different potential than the USB ground – though that should not be an issue for a laptop, which itself should be galvanically separate from anything else, there's a lot of cases where you run into trouble with that (e.g. laptop ground ends up on ethernet ground, audio ground, RS-232 ground...). The strict separation (isolation) between controller and controlled makes that an inherent non-issue.

• "e.g. laptop ground ends up on ethernet ground" Ethernet is (supposed to be) transformer coupled. Back in the days of 10-base-2 they had these plastic sleeve BNC jacks that would stick out of the backplane slot, very specifically not touching the chassis ground. Jul 23 '17 at 1:27
• @ChrisStratton Yes, the signalling is properly separated by transformers, and if there's PoE, that happens through the center taps of the primary sides of those, indeed. But: I have an extremely common RTL8139 NIC card in front of me. RJ45 jack has metal case, which makes contact to RJ45 connector and hence cable shield. On the card side, that is directly connected to the chassis ground. So, um... I can check my Gigabit-Ethernet-to-SFP transceiver for cable shielding – chassis connectivity, too, if you want to. My guess is that the same applies to USB ethernet dongles and laptop on-board NICs. Jul 23 '17 at 9:08
• It might be clearer to explicitly say opto-isolating USB boards exist. An example is here adafruit.com/product/2107 - no affiliation, first link from Google. Jul 23 '17 at 9:25
• @abligh though I agree with the fact that these boards exist, I reiterate: having such a board solves the wrong problem. Jul 23 '17 at 9:26
• @MarcusMüller Which is, as I said, an edge case. You personally might interact mostly with STP, but UTP is still by far the more common choice overall, AFAIK. In any case, STP is typically only grounded on one end, so even that isn't an issue.
– Bob
Jul 23 '17 at 11:16

I mainly work with Arduino and PIC based development electronics for controlling washing machines and vending machines (It wasn't the same device that destroyed both laptops). As its mainly just the risk of high voltage would the use of zener diodes be a simple cheap solution or would that mess with the data side of things?

Good. Since you mention the "use of zener diodes" to protect against an ill-defined "high voltage" , we now have one reliable data point: you have no idea about what you're doing.

Therefore, you need a USB isolator to protect the laptop port from yourself. I feel sorry for that laptop, btw.

I mean, laptops are isolated from ground due to their power supplies being not grounded. So, blowing a laptop's USB port is like... difficult... How exactly did you manage to do that exactly? Did you send mains voltage down the USB port or something?

• +1 for "have no idea about", and I wish to give another +1 for "blowing a laptop's USB port is like... difficult..." Jul 23 '17 at 0:49
• Well, if the micro that is being programmed is powered by a live capacitor dropper from mains or some kind of non-isolated supply... I'm not even sure the USB port would blow, the laptop's internal ground would simply be at mains voltage (and extremely dangerous!) Now, if the micro is used to control washing machines (ie, big inductive load) then, well, other things can go wrong too! Jul 23 '17 at 11:17
• "laptops are isolated from ground due to their power supplies being not grounded." Not true (at least in one anecdotal example). While using a laptop from a major vendor, and a reputable replacement adapter (first one died), my USB ground was connected to earth ground. I only discovered this when I tried to probe the circuit under test with a scope also connected to ground, but with the ground clip mistakenly at a different node than USB ground. Disconnecting laptop supply and running off batteries fixed all of this. Jul 23 '17 at 14:52
• -1 for 80% of the message being ad-hominem and sarcasm. I know that's a meme in electronics discussion, but please.
– AnoE
Jul 23 '17 at 15:41
• @AliChen That's not the case. I blew a fuse in my circuit just before a current monitor that was part of the circuit (and in the ground loop) recorded a very high transient. This definitely wasn't in the milliamp range. Jul 23 '17 at 16:18

Since you are using Arduino as a base, the solution is easy ....use a disposable processor for programming and debugging. The Arduino development environment fits nicely on a Raspberry Pi which you can power from your embedded environment and talk to over wireless from your remaining laptops or perhaps a desktop.

This won't prevent you from frying a Raspberry Pi, but it will reduce the cost of a circuit failure to about $35. • I think until the root cause of blowing out laptop's ports is established, any advice would be premature. We don't know how crazy the washing machine hookup might be, black and white wires can be swapped, and Earth ground hanging loose. Then it might fry anything, Pi or not. I hope the OP has good life insurance... Jul 23 '17 at 0:55 • I disagree ....any advice that makes the environment less likely to be compromised should surely be considered. Jul 23 '17 at 1:05 • That indeed a novel idea - essentially the argument is that a pi (more like$5 + $5 card +$5 wifi) is probably now cheaper than a USB isolator. Neither does anything about possible hazards in the system being created that could persist beyond the engineering phase however. Jul 23 '17 at 1:31
• @ChrisStratton It's simply about managing risk. In a system where you may have catastrophic developmental failures you would isolate both equipment and the human from any potential failure risk. You can buy professional equipment or roll you own ...I simply suggested a viable roll your own solution. Ali Chen's criticism is IMO invalid since for multiple failures during development the root cause may be different. It's too late once the fire has started. Jul 23 '17 at 3:36
• My point is that if the power wiring is not isolated to the norm in this particular case, no amount of Pis in front of a laptop will be safe for ports and users. That's all I meant. Jul 23 '17 at 16:14

Ok, after multitude of clarifications and various presented cases, let me offer a solution to the problem how to protect a laptop from frying in the environment of field servicing:

1. Always connect your test/diagnostic equipment to the service object first, and power the thing up.

2. Before connecting the equipment to laptop, check for any suspicious voltages between USB shields using a low-impedance (standard 10-20k) DMM, between DUT port, and laptop port, both in DC and AC mode.

3. If a significant voltage is found (5 - 10 - 50 V), use a true isolation transformer on one of the ends.

Using a Pi/Beaglebone/Tinkerbox over WiFi would be cheap and easy. CHIP looks good, see https://getchip.com/pages/chip . 5-9$per device. You can murder 7 CHIPs for the price of 1 Pi3. Obviously you still need to address the issue that kill-voltages reach USB ports, but at least your workstation will be safe. Don't connect it to your LAN with ethernet, though. Transferring the files is simply a matter of using key-based passwordless ssh access to scp files to the Pi/other and a remote shell to upload. For arduino, there is the arduino-mk package, and there are similar tools for PIC. No doubt you can also just save your files on an exported SMB/CIFS share, and use the remote shell to make and upload it to your boards. If a kill-voltage occurs again, you will only lose 30-35$.

I still haven't found out how these voltages ever manage to traverse your MCUs and enter the USB port. Is it a short? Where does it come from? I have destroyed many arduino clones, and am sincerely curious.

Also, the USB ports are usually polyfused against moderate voltages. You actually need to place a negative voltage on the 5V pin to kill the port (or positive to GND pin), controller and perhaps motherboard. How are you managing murdering two laptops? Could it be the magic of alternating current at work?