11

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?

Marcus Müller
  • 88,280
  • 5
  • 131
  • 237
andowt
  • 988
  • 1
  • 7
  • 25
  • 1
    They sell optoisolated USB adapters specifically for this purpose. – Ignacio Vazquez-Abrams Jul 22 '17 at 21:47
  • I agree with @IgnacioVazquez-Abrams but however, if you want to make your own device, could you draw out a circuit? We have a plugin on this StackExchange that allows you to draw circuits. –  Jul 22 '17 at 21:49
  • 3
    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? – Transistor Jul 22 '17 at 21:50
  • Yes I've seen those but they tend to be quite expensive so was looking for design advice to make my own! – andowt Jul 22 '17 at 21:50
  • 1
    @KingDuken: A schematic isn't enough. USB also requires proper routing in order to not turn the protocol into a pile of goop. – Ignacio Vazquez-Abrams Jul 22 '17 at 21:50
  • I believe there was a short to +12V on the board I plugged into the laptop – andowt Jul 22 '17 at 21:51
  • ... by the way, I am curious as to what USB device you're plugging in. If you broke two laptops doing this, there's an obvious indication of something that you shouldn't plug into the computer.... hence there's something wrong with the USB device. –  Jul 22 '17 at 21:52
  • 1
    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? – andowt Jul 22 '17 at 21:56
  • 1
    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. – Marcus Müller Jul 22 '17 at 22:00
  • Are you connecting directly to the laptop or through a hub? Even an ordinary powered hub would give some protection as there would not be a direct connection to the laptop and the target USB device. – Kevin White Jul 22 '17 at 23:05
  • 1
    What is this "programming development electronics through USB"? Full disclosure, please - more experienced engineers demand this. – Ale..chenski Jul 23 '17 at 00:44
  • @IgnacioVazquez-Abrams, bad programming may "turn the protocol into a pile of goop", but a reboot will fix that. A reboot can't revive a burned port. – Lenne Jul 23 '17 at 10:11
  • 1
    @Lenne: A reboot can't force external hardware to generate a proper eye pattern, which is the point of my comment. – Ignacio Vazquez-Abrams Jul 23 '17 at 14:38
  • related: [What measures should I take to protect the USB ports of my PC during development of a USB device?](https://electronics.stackexchange.com/a/94387/7036) – Nick Alexeev Jul 23 '17 at 21:32
  • Note that issue MAY not be USB per se but perhaps floating ground on one or other device or different ground potentials. Examine inter-ground potentials with scope / hi-Z AC meter / bare hand. Restart heart. Any difference in potentials? – Russell McMahon Jul 26 '17 at 04:57

5 Answers5

10

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.

Marcus Müller
  • 88,280
  • 5
  • 131
  • 237
  • 3
    "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. – Chris Stratton Jul 23 '17 at 01: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. – Marcus Müller Jul 23 '17 at 09:08
  • It might be clearer to explicitly say opto-isolating USB boards exist. An example is here https://www.adafruit.com/product/2107 - no affiliation, first link from Google. – abligh Jul 23 '17 at 09:25
  • @abligh though I agree with the fact that these boards exist, I reiterate: **having such a board solves the wrong problem**. – Marcus Müller Jul 23 '17 at 09:26
  • @MarcusMüller Unless these boards are permanently built into the controlled unit. – Lenne Jul 23 '17 at 10:14
  • @MarcusMüller The vast majority of ethernet cables are unshielded anyway, so you're probably in a bit of an edge case. – Bob Jul 23 '17 at 11:05
  • @Bob err. what? I have a box full of ready-to-use network cables, around 200m in total. Of these, about 4m in total are UTP. The rest is shielded. – Marcus Müller Jul 23 '17 at 11:12
  • 1
    @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](https://networkengineering.stackexchange.com/questions/6773/stp-termination-and-grounding), so even that isn't an issue. – Bob Jul 23 '17 at 11:16
  • Class Y decoupling capacitors (that won't fail to short) are also allowed to cross the boundary. – ratchet freak Jul 23 '17 at 11:19
  • @Bob I know that it would be proper to only ground one end of STP, but that's not what I've witnessed in *any* home network with >1 desktop PC; the switch/router is "floating", but ties all grounds together. Also: this is a NIC I bought 2002 (for about 5€), was sold at every corner. This is one of the cables that a former ISP of mine sent out to customers with their WiFi AP. http://i.imgur.com/PKfSxWn.jpg the non-zero resistance is mostly due to crappy contact between probe and outer connector. Hard to take picture with one hand and exercise a controlled amount of pressure with the other. – Marcus Müller Jul 23 '17 at 12:15
6

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?

bobflux
  • 70,433
  • 3
  • 83
  • 203
  • 2
    +1 for "have no idea about", and I wish to give another +1 for "blowing a laptop's USB port is like... difficult..." – Ale..chenski Jul 23 '17 at 00: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! – bobflux 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. – nanofarad Jul 23 '17 at 14:52
  • 7
    -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
  • @hexafraction, what you discovered is that your replacement adapter (as any one else) has a "leakage", which you found with scope, and likely only a scope can see it. If I remember correctly, the leakage can be up to 1 mA even on a certified equipment, which is equivalent of about 100k of resistor to live AC wire. This is hardly enough to kill a USB port. – Ale..chenski Jul 23 '17 at 16:09
  • 1
    @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. – nanofarad Jul 23 '17 at 16:18
2

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.

Jack Creasey
  • 21,428
  • 2
  • 15
  • 29
  • 2
    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... – Ale..chenski Jul 23 '17 at 00:55
  • I disagree ....any advice that makes the environment less likely to be compromised should surely be considered. – Jack Creasey Jul 23 '17 at 01:05
  • 2
    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. – Chris Stratton Jul 23 '17 at 01:31
  • 1
    @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. – Jack Creasey Jul 23 '17 at 03: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. – Ale..chenski Jul 23 '17 at 16:14
0

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.

Ale..chenski
  • 38,845
  • 3
  • 38
  • 103
0

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?

user2497
  • 312
  • 4
  • 13