Help to understand power supply isolation and USB please, to avoid future damage - Page 1
Forum section: electronics / beginners

author: DavidA
author_rank: Contributor
timestamp: December 25, 2017, 11:49:47 am
content: I would like to understand what happened with my circuit when I connected a USB AVR programmer to it. I clearly made a mistake and I want to learn from it.The AVR ATtiny84 is connected across the outputs of a LD1117v33 regulator (3.3V) however due to a mistake on my part, the ground of the ATtiny wasn't actually connected properly. I had the regulator inputs connected to a PC PSU, across the 12V/5V supply to give 7V. I know this "7V trick" is a bad idea, and I think I understand why now, but let me continue. The PSU's ground was not connected to my circuit at all.Because of the missing ground connection between the ATtiny and the regulator, the ATtiny wasn't powering up. But to really make things worse, I connected a C232HM USB programming cable to the ATtiny in-circuit (omitting the red VCC wire since it's already powered so I didn't need the 5V supply from it). I suppose, crucially, the ground wire was connected. When I connected this programmer to my powered USB hub (in turn connected to my laptop) the ATtiny got *very* hot. I managed to measure 8.something volts across VCC/GND on the ATtiny before I managed to disconnect everything in a big hurry.To cut a long story short, the ATtiny seems to be quite dead. As is my USB hub - it provides power but does not recognise any USB devices any more. Everything else seems ok, including the C232HM cable.I did notice that when I briefly touched the ground of the USB cable to ground on my circuit that the PSU shut itself down briefly - clearly a sign of bad things, but I didn't notice this until after I fried things unfortunately.What I think happened here is that the bad idea of putting 7V on the regulator using the "7V trick" meant that the 3.3V output on the VCC of the ATtiny was actually 5+3.3 = 8.3V above the PSUs ground. When I connected the USB programmer, if the PSU ground is related to the USB ground somehow, it would have put 8.3V across the ATtiny, as well as across the USB rails too, which would explain why the USB hub was also damaged.What I don't really understand though is that I thought the PC PSU was meant to be isolated, and even if the 5V and 12V supplies aren't isolated from each other, and have a common ground, they are isolated from the mains AC and therefore other grounds like the USB DC ground. So wouldn't this cause them to float relative to the USB ground (which I assume is not isolated?). However the PSU's DC ground wasn't connected so why did a potential difference develop at all? I'm really not clear on this side of things as I think I'm missing some knowledge so any guidance and advice would be welcome, please.

author: DC1MC
author_rank: Super Contributor
timestamp: December 25, 2017, 12:19:22 pm
content: Your laptop power supply, the PC PSU cable, all have have power cables with protective ground connection, the electrical ground of them is connected to the protective ground, so even if you didn't explicitly put the ground on the PC power supply was still connected via the protective ground of the laptop.The idea to make 7V as you've describe it, it's not stupid, it'sMONUMENTALLY STUPID,, for your safety and wallet sake don't do this shit anymore.

author: janoc
author_rank: Super Contributor
timestamp: December 25, 2017, 01:47:07 pm
content: PC ATX suppliesare not floating! They are mains earth referenced - actually have to be, for safety reasons. So your way of obtaining 7V is not only bad idea, it is outright dangerous and may blow up the power supply, along with whatever you connect to it. What you have done is only possible with totally floating supplies (being isolated from mains isn't enough!).Also watch the Dave's video on how to not blow up your oscilloscope. He explains the issues with the mains earth referenced gear.You really shouldn't play with an ATX supply unless you understand basic stuff like this - that thing can deliver 20+ amps and that means major fireworks if you misuse it like this.

author: David Hess
author_rank: Super Contributor
timestamp: December 25, 2017, 03:11:00 pm
content: The lack of galvanic isolation and lack of ease of implementing galvanic isolation is one of the reasons that USB is a terrible standard for use between devices which are separately powered and this goes double for development work. It is great for USB powered peripherals, acceptable between peripherals powered from the same circuit, and horrible otherwise. I am continually amazed that test instrument manufacturers include USB ports for connecting to line powered peripherals or computers without building in galvanic isolation.

author: Damianos
author_rank: Frequent Contributor
timestamp: December 25, 2017, 06:19:58 pm
content: Quote from: David Hess on December 25, 2017, 03:11:00 pmThe USB is designed as mostshort-rangecommunication systems. The problem is with stupid people that connect a point that is indented to be Earth-grounded, to a power supply or, generally, treat it independently of the rest of the circuit ... ...The next step may be to blame Earth because is conductive, while we want to have grounded but simultaneously floating circuits!

author: David Hess
author_rank: Super Contributor
timestamp: December 25, 2017, 06:56:01 pm
content: Quote from: Damianos on December 25, 2017, 06:19:58 pmI agree it is a misapplication but it is not just stupid people; manufacturers screw up USB and other grounding all the time. I forgot who did it but there was a series of VGA monitors which were destroying laptops and shocking people. Even if I do everything right, the last thing I want is a prototype development system connected to my expensive workstation through a non-isolated interface like USB and the same goes for test equipment.The thing which makes USB difficult compared to say RS-232 is that bidirectional signal lines are much more difficult to isolate. Inexpensive integrated isolation products are available now but since they are limited to 12 Mb/s, using them comes at a steep cost of not supporting USB 2.0's 480 Mb/s. Ethernet is a good solution but so much more complicated.

author: DC1MC
author_rank: Super Contributor
timestamp: December 25, 2017, 09:42:48 pm
content: Quote from: David Hess on December 25, 2017, 06:56:01 pmEh, if we've only had some kind of good tested, standardized protocol, that allows for high speed packetized communication and can form complex networks that GPIB could only dream of. Also the physical layer would be so nice to be easy to isolate the signals from whatever high-voltage floating ground, get at least 10m at 10Gb/s or 100m at 100Mb/s.Of course if there would by like widespread parts and software supporting that protocol and specifications will be open, like done by a standards body such as IEEE, that would have been so nice.I think two guys were working on it, some while ago, Bob and Dave, if I remember correctly, I think they wanted to call it Ethernet or Etherum or something, like this crypto coins, anyway I don't thing that with such a ridiculous name they ever finish it, and now we are stuck with the USB, very sad.

author: David Hess
author_rank: Super Contributor
timestamp: December 25, 2017, 09:57:27 pm
content: Quote from: DC1MC on December 25, 2017, 09:42:48 pmLike I said in the part you even quoted, Ethernet is a good solution but so much more complicated.

author: DC1MC
author_rank: Super Contributor
timestamp: December 25, 2017, 10:30:37 pm
content: The joke wasn't directed to you David, but at this vendors that really just wanted replace their RS-232 interfaces with some smarter "serial like" thingy.I actually fail to see how an Ethernet interface with a simple TCP/IP protocol stack would have been "much more complicated" than an USB stack with all these device class implementation, host OS drivers and all the other miserable stuff.I think the first PICs with a TCP/IP stack were available at the beginning of 2000's, and all the instruments based on a PC platform or having a "proper" CPU could have easily added an TCP/IP stack instead of the USB stuff.Not to mention how easy would have been interfacing with any type of PC/workstation or industrial controller. I remember seeing Serial over TCP/IP adapters in '99.DC1MC

author: DavidA
author_rank: Contributor
timestamp: December 25, 2017, 11:18:06 pm
content: Thanks for the responses everyone. I had a feeling it may not have been a smart thing to do however there's no substitute for real-life experience. Armed with this experience and your advice, I won't be making the same mistake again.Maybe it's time I invested in a proper bench-top power supply. I just wish they all weren't so damn expensive in this part of the world.

author: DavidA
author_rank: Contributor
timestamp: December 25, 2017, 11:23:53 pm
content: Quote from: DC1MC on December 25, 2017, 12:19:22 pmBTW, it seems to be a widely used "trick" for running PC 12V fans at a slower speed, and Google is full of people doing this, which is where I got the idea from. I did look around for serious warnings against this practice, but didn't really find much to suggest it was a bad idea. However now I understand the bigger picture better, it does seem like a really bad idea.

author: DC1MC
author_rank: Super Contributor
timestamp: December 25, 2017, 11:38:15 pm
content: David, now you're a seasoned electronics experimenter that have seen things, now throw away that improvised crap and get a proper power supply to start the year properly, a cheap one will do for starters and be many times better than what you're using now.Even for the PC modding camp, the kludge with connecting the fan between 12 and 5V it's still tragically stupid, it's so easy to have something crapping out in the fan and shorting 12V with 5V and puff goes in smoke the gaming rig, but that's OK, they need to learn as well.Cheers, DC1MC

author: DavidA
author_rank: Contributor
timestamp: December 26, 2017, 07:30:47 am
content: Quote from: DC1MC on December 25, 2017, 11:38:15 pmCan you give me any suggestions of which models to look at? Buying local new means $200+ for basic single-channel adjustable DC @ ~5A (Jaycar is the only option and their markup is as high as 5000% on some items), so I would consider importing something if I can be fairly sure it's a good and reliable choice. I will also need to get an idea of what to look for in a bench top power supply.I wasn't able to find a general "bench top power supply" thread here (might have missed it though).EDIT: can also get new "wanptek" and "korad" brands (I've never heard of them) for <$200 on local trade/exchange website. I'm guessing these are just cheap Chinese made ones imported by someone. I could get them cheaper direct from Ali Express I suspect.

author: rstofer
author_rank: Super Contributor
timestamp: December 26, 2017, 03:28:24 pm
content: Implementing USB HID and CDC is pretty trivial and well understood. There are no drivers to create as long as the device complies with the standard. Microsoft includes the drivers as does Linux.There are USB isolators. I picked up a couple but I haven't tried them.There is nothing wrong with using wall warts. I did it for decades. It's pretty easy to find a 5V 2A wart anywhere they sell Raspberry PIs. 9V and 12V are also pretty easy to find. One obvious downside: No current limiting. Sometimes this matters.Power supplies just has to be the most discussed topic around here. Dave did a video about a PS that caught fire but he also discussed the fix (now implemented)Here's the supply review:See also videos 1035 and 1036 for the fire and fixBottom line is a workable PS for $20.

author: janoc
author_rank: Super Contributor
timestamp: December 26, 2017, 07:14:11 pm
content: Quote from: DC1MC on December 25, 2017, 09:42:48 pmThe problem with Ethernet is that it doesn't solve what USB has been designed to solve - namely both replacing the legacy (RS-232, Centronics style printer ports, etc.) interfacesand alsoto provide power to peripherals, so that every little widget and gizmo doesn't need its own wall wart (neither RS-232 or printer ports provided power).Ethernet by itself is unable to do it, due to the fact that it is isolated. And the moment you start messing with the various power-over-ethernet schemes, you are back to square one with all those grounding issues.Furthermore, Ethernet is fairly slow, even by USB standards, and lacks support for things like time determinism (the isochronous transfer type USB has). That would have made it difficult to use for e.g. audio and (later) video without large buffers and associated latencies.So yes, by using Ethernet the manufacturers would have solved the isolation problem (which wasn't seen as a problem in the first place as it is extremely rare for a normal user to run into it) and complicated all the other issues they were trying to address.If you want an IEEE standard that is actually closer to what USB has been trying to do, it is IEEE 1394 - aka FireWire.

author: Rolo
author_rank: Regular Contributor
timestamp: December 26, 2017, 07:28:18 pm
content: One of these could be of some help. It works to isolate your computer's usb from your project. I will not give the max usb spec current and not the full usb 2.0 speed I think. But It does the job for usb bootloaders on dev boards.You still have the grounded BNC on your scope to watch out for.

author: janoc
author_rank: Super Contributor
timestamp: December 27, 2017, 02:40:48 pm
content: Generally, what helps to keep issues in check for a hobbyist - always, always work with your DUT powered from a completely floating supply - wall wart, lab supply, usb power bank, batteries. If you are using mains powered equipment - e.g. a PC or an oscilloscope, power it all from the same outlet to ensure there aren't any voltage differences (and thus stray currents) that could blow something up. Then even if you are using USB to connect it to PC or an earthed oscilloscope it won't cause problems.Avoid using "industrial" supplies such as PC ATX ones. They are cheap but they will also give you a lot of trouble unless you know exactly what you are doing. A laptop power brick and one of those lab supply modules from eBay/AliExpress are a very good option probably on par with many of the cheap lab supplies available from the same places if you don't want to spend money for a proper lab supply (not that they are expensive!).And don't tinker with mains or mains earth referenced equipment until you "grow into" it. That means don't try to build or repair switching power supplies in home audio/video gear, TVs etc until you are sure you know how to handle this safely and have the proper equipment - isolation transformer (not a variac!), differential probe for your scope, etc. - as required. Otherwise you are asking for a trip to a hospital or worse.

author: Bratster
author_rank: Frequent Contributor
timestamp: December 27, 2017, 09:41:36 pm
content: One thing to watch out for if you're using a laptop power brick and one of those little switching power supply modules is if you have a laptop power brick with a 3 pin ac power connector for the input side it is most likely has the output negative at Earth ground so you are back in the same boat as using an ATX power supply. Allbeit with current limiting this time.Also need to watch out for those little modules a lot of times have the current sensing shunt in the negative side so that's another trap to fall into.You need to make sure that you're using a laptop power supply with a 2 pin AC input.Sent from my Nexus 6 using Tapatalk

author: Gyro
author_rank: Super Contributor
timestamp: December 27, 2017, 09:58:31 pm
content: Hmm that's a tricky one. With 2 pin AC input laptop supplies you get the leakage current associated with the Y-Caps. This leakage, very low current obviously but by floating to around half mains voltage can damage CMOS inputs etc. if them make contact with the scope ground first (rather than your DC rail ground).I normally recommend using a 3 pin adapter to ensure that these primary filter leakage currents are routed back to mains Earth ground. Unfortunately this doesn't help you achieve a floating output.

author: janoc
author_rank: Super Contributor
timestamp: December 28, 2017, 03:57:23 pm
content: Good point about the laptop power bricks. Didn't think about that one.Probably worth poking an ohmmeter there to check whether there is actually continuity between any pin of the mains plug and the output first (if for nothing else then also for safety reasons because there are plenty of dodgy wall warts and similar around).