Mains powered device with USB comms - Page 1
Forum section: electronics / beginners

author: Stefano
author_rank: Contributor
timestamp: November 24, 2022, 05:08:38 pm
content: Hello,I'm working on a PCB heater that is powered from mains and is controlled via an ESP32. (I'm the guy from the mosfet post)I've never made a device powered from mains that also has a USB port (ESP32 programming), and I was wondering if the two grounds can be simply connected together, or special care needs to be taken.I attached the schematics (look at power and usb section), in essence:Mains 230V --> AC/DC brick (12V) --> Switching voltage regulator (3.3V) --> ESP+CH340+USBThe USB port will be connected to a PC or anything that can read a serial port.The 5V of the USB is not used, so the pins are left floating, but the ground pins are connected to the GND plane of the circuit.My understanding is that there needs to be isolation when you are dealing with earth to avoid creating ground loops, in my scenario however, the enclosure of this device is 3D printed and the brick doesn't have any connection to earth ground, so I'm only dealing with Live and Neutral from mains.Can I connect the USB Gnd to the same Gnd coming from the AC/DC brick or do I need to take special care of that?Thanks

author: RJSV
author_rank: Super Contributor
timestamp: November 24, 2022, 11:33:36 pm
content: I would think a single ground connection won't create a ground loop, but later, your stuff connected (to USB) would have to be evaluated.Does the 12 V supply 'ground' have a metal box connection, or any metal panels ? Might be connected back to mains ground, which would be Earth ground.Shouldn't be problem, unless some fault or insulation break (is touched), and also that earth ground.

author: TimNJ
author_rank: Super Contributor
timestamp: November 24, 2022, 11:36:22 pm
content: How would you power your circuitry if you do not connect the (-) of the AC/DC brick? What is the alternative you are thinking about?You have no explicit earth connection so what loop do you think could be possible? Between where and where?

author: Berni
author_rank: Super Contributor
timestamp: November 25, 2022, 06:33:29 am
content: You can find mains powered USB devices that do one or the other.Some are non grounded "double insulated" devices that just have 2 prongs on the mains plug. This is usually things like TVs and printers.Some have a full 3 prong plug and will typically have a connection between USB GND and mains earth. Most test equipment with USB on the back is like this.

author: james_s
author_rank: Super Contributor
timestamp: November 25, 2022, 06:46:59 am
content: You'll want to verify, but the power brick should produce a fully isolated DC voltage. If it's some kind of non-isolated converter then you need to replace it with one that is isolated. The output of an isolated converter can be treated more or less like a battery, it is not connected to the input.

author: Stefano
author_rank: Contributor
timestamp: November 25, 2022, 08:43:38 am
content: QuoteIndeed it is, from the DS: "High I/O isolation test voltage up to 4200VAC".QuoteI have no reason to think a gnd loop can be formed, I was just woundering if special care needs to be taken in connecting the grounds together.QuoteYes indeed my device will be just like one of those two.QuoteNope, just a plastic case and four pins, live, neutral, V+ and V-.QuoteThe plug will have 2 prongs and the device will be kept inside its enclosure, so everything is fine.Thanks a lot guys.

author: xmris
author_rank: Contributor
timestamp: December 04, 2022, 01:23:07 pm
content: probably silly comment from me -not an electronics pro- but if you are going to use a 2-prong AC that is non 'polarised', don't you need double-fusing there?

author: tooki
author_rank: Super Contributor
timestamp: December 04, 2022, 02:46:18 pm
content: Quote from: Stefano on November 24, 2022, 05:08:38 pmYour AC/DC supply doesn’t have a ground at all. It has a floating output whose negative pole you’re using as the 0V reference of your circuit.Yes, we normally call the 0V reference in our circuits “ground”, but don’t confuse it with an actual earth ground (such as the PE (protective earth) in an AC cable). Your 0V reference doesn’t become an earth ground until you connect it to earth ground. The USB groundmightbe at earth ground (like with a desktop PC) or not (like with a laptop running on battery). Consequently, youmustdesign USB circuits with the assumption that USB ground is connected to earth ground.

author: Ian.M
author_rank: Super Contributor
timestamp: December 04, 2022, 03:07:01 pm
content: This becomes critically important when the USB device has high power DC supplies or loads in it or controlled by it. Its far too easy to create a ground loop that will destroy your PC motherboard by passing excessive current through its USB ground traces.e.g. any 3D printer with PSU 0V/negative tied to Mains PE/Ground, and a non-isolated USB interface can destroy your PC if the negative/ground wire between the PSU and the controller comes loose. All appears normal at first (except it wont power up if the USB lead is unplugged), as the return path for the controller's power is via the USB lead, and the ground wires in the PC and 3D printer power leads. Then as soon as you start a print (or preheat) the bed heater turns on, and its typically 15A load current has to return via the same undesirable path. If you are very lucky, the USB lead has a high quality low resistance shield connection at each end, and the PC USB A socket shield is well grounded to chassis and it will simply melt your USB lead. However if that ground return current tries to flow through the motherboard, expect your PC to let the magic smoke out.

author: David Hess
author_rank: Super Contributor
timestamp: December 04, 2022, 04:51:16 pm
content: Your "AC/DC brick (12V)" should be providing a galvanically isolated 12 volts, so the USB ground connection will not create a ground loop.For safety, it may still be desirable to use a galvanically isolated USB connection.

author: Terry Bites
author_rank: Super Contributor
timestamp: December 05, 2022, 11:34:55 am
content: Double fusing creates more problems than it solves.

author: tooki
author_rank: Super Contributor
timestamp: December 05, 2022, 11:51:57 am
content: How so?

author: tszaboo
author_rank: Super Contributor
timestamp: December 05, 2022, 12:08:32 pm
content: Quote from: tooki on December 05, 2022, 11:51:57 amNothing guarantees that the phase will break. Could be the neutral connection that breaks.OP: If you don't expose the USB connection on the outside, that solves your problem. Not everything needs to be user programmable.

author: golden_labels
author_rank: Super Contributor
timestamp: December 05, 2022, 03:22:15 pm
content: Captain Obvious makes an observation: the board has no earth connection to start with.So what was the question again?

author: james_s
author_rank: Super Contributor
timestamp: December 05, 2022, 08:34:05 pm
content: Quote from: golden_labels on December 05, 2022, 03:22:15 pmIt does if you plug the USB port into a desktop PC. The USB cable shield and DC ground of a PC is connected to earth ground.

author: tooki
author_rank: Super Contributor
timestamp: December 06, 2022, 12:19:43 am
content: Quote from: tszaboo on December 05, 2022, 12:08:32 pmAnd the consequence of this is...?

author: golden_labels
author_rank: Super Contributor
timestamp: December 06, 2022, 05:29:23 am
content: Quote from: james_s on December 05, 2022, 08:34:05 pmAnd the original question is about connecting USB’s ground to “the other ground”. There is no other ground, in particular on the high voltage side.

author: james_s
author_rank: Super Contributor
timestamp: December 06, 2022, 07:35:44 am
content: Quote from: golden_labels on December 06, 2022, 05:29:23 am"Ground" is often used to describe the negative terminal of a DC supply, it doesn't always mean earth ground. Since the power supply provides galvanic isolation this is not an issue, but from what I could tell that was the question the OP was asking.

author: Terry Bites
author_rank: Super Contributor
timestamp: December 06, 2022, 07:49:03 am
content: Becasue the neutral can blow leaving the live connected without the fault conditon being controlled. This can fool you into thinking mains is not present when it is. There is no phase to ground protectionDouble pole fusing makes sense in some shukoland distribution schemes or other situations where the power socket allows L and N to be reversed.This is why double pole fusing is mandatory in medical devices.We call ground "earth" in the UK to avoid the ambiguity. We call GFCI's RCDs to make clear the difference. Britsh electricity is a kwality item.In my local experience "ground" is a term more commonly used in DC systems.Hi and Lo, more problems! Telecoms -48V, mmmm.Ref adds to the problem. It might be an AC or DC ground/ earth/ ref/ frame earth/ common. I might be a protective connection or not.Grounds may connect to earth or may of the above of course. We need a better word for return conductors. I know, Return Conuctors!A good understanding of earthing and bonding is needed.Electricians talk a diferent languge and we need to translate carefully....... I choose my fuses to have the right poppage factor as an Ohmage to the Amperage of the Volteration.

author: golden_labels
author_rank: Super Contributor
timestamp: December 06, 2022, 08:42:55 am
content: Quote from: james_s on December 06, 2022, 07:35:44 amI know what GND is.Do you think OP speaks about DC side GND, against which USB data lines are already referenced? And builds the entire question around 230V mains, focusing on this being their first project that incorporates mains-powered PCB and USB, if it’s not relevant to what what they’re asking about?I do not and believe they are concerned about main’s earth.

author: Terry Bites
author_rank: Super Contributor
timestamp: December 06, 2022, 08:50:05 am
content: It sounds like the PSUs are not galvanically isolated in his power systems. If they were he wouldnt have the wierd behaviour when connecting the scope gnd. Still OP's, as ever, need to give us a drawing instead of leaving it to our imagination.