Could you help me improve my PCB design? - Page 1
Forum section: electronics / projects

author: jakob
author_rank: Newbie
timestamp: April 12, 2018, 07:56:38 pm
content: Hi! I am in the process of laying out a PCB, the purpose of it is basically to controll mains-appliances. The main components is; an ESP8266-12U, a Step-down transformer, and a Relay. And a microphone with a N5534N-chip for regulation. The circuit works as it should on a proto-board. But as this is the second time i am designing a board, i am not that confident of my choices yet :'DAnd so my question is this, could anyone critique my board-layout and routing? Are there anything i should change? I was thinking about minimizing the amount of vias, by making one of the traces go around the whole board. But what do you folks think?In advance, thank you for taking time to help me!

author: georges80
author_rank: Frequent Contributor
timestamp: April 12, 2018, 08:25:18 pm
content: Looks very dangerous to me. Why are you running live 240VAC so far and under a bunch of IC stuff?Consider what can happen if there's a breakdown in PCB insulation, consider if the board gets 'dirty', consider you don't want to electrocute yourself or others that may have access to this board.Your clearances from mains traces to digital signals are way too little. Do you have fuses to deal with catastrophic failure (shorts/component failures/etc)?Have you searched for clearance/creepage to determine what trace separation is required?I'd suggest your do a bunch of reading before attempting to layout a board that has mixed 240VAC and digital signals and headers to presumably a programmer/debugger/console etc...'You should prioritize on keeping the live 240VAC stuff very short and basically just from the input/output of the relays versus routing it across the board. Once you have the AC stuff 'safe', then you can worry about routing your other stuff and keep it away from the AC traces/relay connections etc.Redo your layout once you understand clearance/creepage and provide a schematic for review as well.cheers,george.Edit: Fixed some stupid caffeine free typos

author: tautech
author_rank: Super Contributor
timestamp: April 12, 2018, 08:33:44 pm
content: Quote from: georges80 on April 12, 2018, 08:25:18 pm+1Pads, some are too small so the annular ring is too fragile.Hole sizes need modifying.IC1, Q1 and Q2 look great but that's about all.Keep working on it.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: April 12, 2018, 09:58:28 pm
content: Quote from: georges80 on April 12, 2018, 08:25:18 pmThat's what creepage is about: contamination and stuff. But not clearance -- PCB material is considered a cemented joint, with whatever breakdown rating the manufacturer specifies, no further derating required.So this is fine, except where pads and vias penetrate the board. If you can realize a single sided design for each voltage, you can put them right on top of each other. (Some power supplies do this -- it's the only way to get a super compact 5V charger, like the Apple charger plugs. I mean, the only way without compromising ratings, as the Chinese clones of those do...)Now, about those "Q" components that are clearly not transistors.......Tim

author: georges80
author_rank: Frequent Contributor
timestamp: April 12, 2018, 10:20:58 pm
content: Running mains traces under components may meet clearance but can still be problematic.I've seen components that fail badly that can damage the PCB sufficiently to 'carbonize' the PCB material and thus causing serious problems due to now creating a breakdown path to the high voltage paths. Stranger things have happened... Getting UL/ETL etc for a product will often educate you one on failure issues that you never imagined.One has to consider failure modes, not just when things get a bit of dirt/contamination on them (the pollution levels with UL specs etc).Given the OP project and apparent knowledge of mixed AC and digital/human accessible components, I'd suggest being very conservative with where those AC traces are routed. There's also nothing that states that the PCB will be fabricated professionally versus a home etched board...cheers,george.

author: mdijkens
author_rank: Regular Contributor
timestamp: April 12, 2018, 11:05:00 pm
content: Another remark:Shouldn't you keep the antenna of the ESP outside your PCB?

author: viperidae
author_rank: Frequent Contributor
timestamp: April 12, 2018, 11:21:12 pm
content: If it were me (and I am in no way a professional) I would keep mains and low voltages physically separated.The terminals, input side of the power brick and switch side of the relay on one half of that board and your low voltages stuff on the other half.I'd also not put any ground plane under the PCB antenna of the ESP or sandwich it under the power brick.

author: TomS_
author_rank: Frequent Contributor
timestamp: April 13, 2018, 07:00:03 am
content: I would echo the sentiments of others here (although Im no EE and have little to no experience in this particular field), and suggest that with a bit more work you could re-work this board to be much safer.Move all of the mains related components and traces so that they are on one side of the board, and the low voltage logic is on the other - dont mix them, even if on the other side of the board (better safe than sorry kind of thing). Leave as big a gap between high and low voltage traces and pads as you can. Maybe there are opportunities to introduce opto isolators for additional protection.Watch some videos by bigclivedotcom on YouTube where he tears down USB power supplies (i.e. phone chargers). He usually points out whether the clearances between the high and low voltage sides of the circuit is good or bad, or in some instances non existant. This might give you some ideas how to go about achieveing similar things with your design.

author: dmills
author_rank: Super Contributor
timestamp: April 13, 2018, 02:06:49 pm
content: Were it me, I would be looking to redo the placement (placement is EVERYTHING in PCB design).Rotate the relay 90 degrees and push it hard up against the top edge of the board.Now the PSU will probably fit at 90 degrees below the relay and all the way to the right.This gives all the mains stuff being in the right third of the PCB so you can restrict the mains to just that area and keep the plane out of that zone, the remainder of the board then becomes the low voltage region.I don't see an earth connection on that board? Are you trying for class II? Class II is a pain in the arse, I would earth the negative output of the supply.Also, how is the board to be mounted? Mounting holes are a good thing.....Regards, Dan.

author: TomS_
author_rank: Frequent Contributor
timestamp: April 13, 2018, 02:38:16 pm
content: Quote from: dmills on April 13, 2018, 02:06:49 pmYeah, and always place them FIRST, so you dont have to re-do parts of your layout to fit them in later.

author: dmills
author_rank: Super Contributor
timestamp: April 13, 2018, 03:37:36 pm
content: Quote from: TomS_ on April 13, 2018, 02:38:16 pmThat is a mistake everyone makes ONCE!Also when placing mounting holes switch to a sane grid before doing it, mounting holes on a 95.3456789mm centre just looks stupid on the assembly drawing for the metalwork.On that note "Controlling dimensions : mm" and then noticing that everything is on a 1.27mm pitch, just annoying (Connector manufacturers, looking at you!).Regards, Dan.

author: jakob
author_rank: Newbie
timestamp: April 15, 2018, 10:48:29 am
content: Hi folks, thanks for your feedback! I have worked some more on it, and i have redone it.Things i have done:Made (almost all) signal-traces on one layer, and 230V on the other.Moved the ESP8266-antenna outside the board.Reworked the low-voltage-layout, to make it fit on a smaller portion of the board.Added some mounting holesChanged namingThings i am worried about:The ground-plane having too small "traces", and therefore the potential for voltage-differences across the board.If i should add fuses, I am not convinced that they actually will be able to do any good in this application, unless i use heat-sensing fuses. Since the power-loops here have fuses on them...The cutout around the relay-pin making for a rather weak spot.The one trace on the overside beeing stupid. But i couldn't get it on the underside, whitout obstructing the ground-plane

author: RR
author_rank: Contributor
timestamp: April 15, 2018, 04:26:02 pm
content: Where are decoupling caps?also NE5534 is not a good choice here when you power it just from 3V3.

author: jakob
author_rank: Newbie
timestamp: April 15, 2018, 04:34:16 pm
content: Quote from: RR on April 15, 2018, 04:26:02 pmI haven't thought of caps really, but that might of course be a good idea. And the NE5534 is supposed to be powered with the 5-volt. It is on the prototype-board

author: T3sl4co1l
author_rank: Super Contributor
timestamp: April 15, 2018, 10:28:14 pm
content: Much better.Now, put a copper pour on top, and add GND stitching vias into every island / peninsula on the bottom layer. Also, check the RF module datasheet if you need to add copper cutouts for antenna reasons.Tim

author: BrianHG
author_rank: Super Contributor
timestamp: April 15, 2018, 11:16:29 pm
content: 1. Your traces on the left and right go too close to the edge of the PCB. Either widen the PCB or find alternate routing/component placement.2. Don't rely on your current GND fill as it loops around with a few opens. I would fill or route some thick GND traces on the bottom and stitch a few additional vias.

author: jakob
author_rank: Newbie
timestamp: April 16, 2018, 12:08:36 pm
content: I have now added a ground-plane on the top. I don't believe there are nececary with any vias in addition to the through-hole-components already there. I connected the NE5534 to 5V, instead of the 3,3volt. I rearanged the traces that are closest to the edge, and believe they are well within limits now. Last thing i did was add some caps.Any more improvements you see that could be made?

author: tautech
author_rank: Super Contributor
timestamp: April 16, 2018, 04:17:54 pm
content: Quote from: jakob on April 16, 2018, 12:08:36 pmYeah it can do with a bit more polishing yet.Time to ditch the autorouter and do trace layout by hand. Use it mainly just to prove the layout can be routed.Re-examine how your mounting holes will actually work in practice with the existing clearances to componentry.Manually shift traces to provide bigger clearances to traces.Make several pads larger and hole diameters smaller to optimize annular ring sizes.Consider using low density (larger) SMD footprints for ease of hand soldering.Did I mention make TH pads larger and holes smaller ?0.7mm (30mil) is a good common size for holes for all the smaller TH components. Measure leads and adjust holes accordingly to fit larger components.

author: james_s
author_rank: Super Contributor
timestamp: April 16, 2018, 04:19:53 pm
content: It looks like the pot has the adjustment screw facing into the relay?

author: mdijkens
author_rank: Regular Contributor
timestamp: April 16, 2018, 05:15:40 pm
content: Looks good3 remarks:- Check that all GND connections can 'see' eachother. On the blue (bottom?) plane I am not sure...- I would make the 3V3 lines at least 20mil..- make sure C3 is at least 220uF

author: jakob
author_rank: Newbie
timestamp: April 16, 2018, 08:14:16 pm
content: Quote from: james_s on April 16, 2018, 04:19:53 pmHaha, it's an "upright" pot. I just didn't care to make a new footprint

author: james_s
author_rank: Super Contributor
timestamp: April 16, 2018, 08:50:31 pm
content: I remember a PCB program I tried early on had an auto-placement "feature", it would do stuff like place a jack in the middle of a board with something right in front of it!

author: dmills
author_rank: Super Contributor
timestamp: April 16, 2018, 10:25:08 pm
content: I think your plane clearance to the HV tracks is now a bit suspect, I like at least 5mm if I can do it, and see no reason not to on something like this.Top right mounting hole, with a metal screw in it, how much clearance from live mains?Via stitching, seriously it costs nothing and will improve your signal integrity (You have radio gear on here so are doing things fast enough for this to matter).Regards, Dan.

author: KhronX
author_rank: Frequent Contributor
timestamp: April 17, 2018, 01:17:19 am
content: Just a few semi-random observations:1) Does the NPN driving the relay really need to be a TO92 through-hole one? Something like an MMBT5551 can be had for pennies, and is good for half an amp. Your relay should(?) only need under 100mA, if it matches the part number on the schematic2) Any chance you could program the output pin to be, say, 13 or 14? Just so that trace wouldn't need to snake all the way from the other side of the ESP8266...3) If you take care of 1) and 2), maybe you'll find a way to get the relay-driving NPN and the snubber-diode closer to the coil terminals of the relay (and perhaps not have them connected by those hair-thin traces?).4) In the schematic, make sure the NE5534's power pinISconnected to the 5v. A few posts up, it's (still) marked as VCC, which looks to be the output of the 3.3v regulator.5) Just a tip - most bog-standard relays don't care about the direction of current through their actuating coils, so feel free to swap the connections around in the schematic, if it leads to shorter tracesAs it stands, the 5V trace (in addition to being hair-thin as well, despite having to pass nearly 100mA for the relay, plus whatever else the rest of the circuit needs) seems to snake from the bottom-left of the board all the way around the right edge of the board, only to end up at the end of the relay coil that's in the MIDDLE of the boardI think you'll agree, not exactly optimal.6) Ditto for the placement of the 3.3v regulator - as far as i can tell, only the ESP8266 needs 3.3v; everything else will happily run from 5v, so... Why wouldn't you have the regulator closer to (at least one of) the VCC pins of the MCU? Shuffle the analog stuff closer to the right edge, that'll make room in the middle area of the board to shoehorn in the regulator.That being said, you'll also wanna double-check how much power the regulator will need to burn off (1.7v drop times whatever current the MCU daughterboard needs). That may or may not require some copper area for heatsinking. According to AN-994 from International Rectifier, that "minimum pad" area would end up in a junction-to-ambient thermal resistance of almost 90C/W. But if you have less than, say, half an amp of load there, you should be fine with no extra copper pour.7) For peace of mind, i'd also try to clear out more room around the common of the relay switch (NetP2_1, relay pin 5, if saw that right?). Perhaps "even" see if you can rotate the opamp 90deg clockwise.