PCB Layout Tips and Best Practices: 2023 Edition

Started by BlueLdr, August 12, 2023, 02:18:55 PM

Previous topic - Next topic

BlueLdr

Hey everyone,

I've been reading and learning a ton about PCB layout and design for the last few weeks, and there are a handful of questions that I still haven't found the answers to. For reference, here are the main resources I've been using:



1. Regarding trace width/spacing: R.G.'s book mentions that you should choose (minimum) trace widths, pad sizes, etc. based on the skill of the builder because of the risk of the copper peeling off the board, among other things. From reading the book, it's clear that some time has passed since it was written (not knocking the usefulness of the information though!). So I'm wondering, do these limits still apply with modern manufacturing techniques, assuming the board is made professionally with Gerber files?
I'm no soldering expert, but I've done enough that I think I'm past the beginner stage. Can I get away with 10 mil traces and spacing?


2. Everyone says to avoid long traces. But how long is a "long" trace? I know it varies based on the impedance, but rough numbers would still help a lot.


3. In my reading, I've gathered that digital and analog (audio, at least) parts of the circuit should be completely separated. But as with the previous question, I don't have a solid definition or example of what that means in practice for stompbox circuits. How far apart should they be?
If I can draw a 0.1" line across the board between all the analog parts/traces and all the digital parts/traces (excluding the relays doing the switching), is that good enough?


4. This one feels like either a beginner concept that has managed to elude me, or a rule I've just imagined because of how my brain works: For a given net, is it important for the "common" connection point(s) between components to be the same on the board as they are in the schematic? In other words, when routing in a PCB program, should I connect components based on the schematic, or the rats nest?

For example, in the figure below, the signal goes through R1 and reaches the bias resistor R2 before going into pin 3 on the opamp, so R2 is the "common" point of the net, as it sits between the other two points. Similarly, the output from C2 reaches the pulldown resistor R3 before reaching the output resistor R4, so R3 is the "common" point. With that in mind, I've routed it two different ways. One matches the schematic, R2 sits between R1 and pin 3, and R3 sits between C2 and R4. In the other, R1 is the "common" point for its net, connecting to R2 and pin 3, and R4 is the "common" point for its net, connecting C2 and R3.

Ignoring the part placement and trace length, is there any electrical difference between the two routing schemes? Or should I always go for the shortest traces possible?



Of course, if you have other PCB layout advice that's not related to my specific questions, you're very much encouraged to share that too!  ;D

ElectricDruid

1) Modern manufacturing techniques don't affect the skill of the builder! They'll be able to manufacture stuff you can't solder - that much is a fact. Modern PCB fabs produce PC motherboards with four or more layers and such mind-bending complexity that we'd run screaming from the room. So the question is "what do you think you can cope with?" If you're feeling like you don't over-heat stuff and lift tracks these days, then sure, go narrower and start putting stuff closer together and see how you get on.

2) How long is long?!? It's a good question. It depends on frequency as well as everything else. If I was feeding a MHz or even multi-100s KHz signal down a particular trace, I'd want that one shorter than another that wasn't being pushed so hard. To answer your question, I'd say simply "Inches". If you're measuring the length of the traces in inches rather than centimetres or millimetres, then that's getting pretty long (and *don't* start being pedantic and saying that 0.01" is still inches - you know what I mean!)

3) They should be as far apart as you can get them. If you can get a 0.1" gap between the analog side and the digital side, that'd be great. It's not a question of physical spacing (although that helps too) as much as thinking about current flows. The power supply and ground paths for the two sides of the circuit need to be separated as much as possible, and typically only linked back at the supply.

4) This is over-thinking it. If it's equivalent in terms of connections, it's equivalent. E.g. if you do the "matches the schamtic" check in your PCB software and it comes back with "no errors", then you're ok. That's not *always' true, but for the sort of stuff we're mostly dealing with for effects circuits, it's fine. Certainly the examples you posted are *completely* equivalent and there's no way you could find a measurable difference between them. The trace length differences are tiny and the trace widths are wide enough that the resistances involved are going to be tiny too, so who cares?
With small/tiny traces and high frequencies, this starts to matter more, but we're using big wide traces and talking about audio (25KHz max, if we're lucky and still have young ears) so it really doesn't matter.

You can get into style points, and I quite *like* the way different people have different styles of laying out similar circuits, but I wouldn't go so far as to claim one is better than another. If they all work, they all work, and that's *it*.



BlueLdr

#2
Quote from: ElectricDruid on August 12, 2023, 03:50:37 PM1) Modern manufacturing techniques don't affect the skill of the builder! They'll be able to manufacture stuff you can't solder - that much is a fact.
I guess the real question I'm asking is, has manufacturing changed such that tracks are less prone to lifting now (at 10-25 mil width/spacing)?

Quote from: ElectricDruid on August 12, 2023, 03:50:37 PMSo the question is "what do you think you can cope with?" If you're feeling like you don't over-heat stuff and lift tracks these days
So I totally shouldn't mention that the closest thing I've done to PCBs was those prototype boards from Radioshack :-X

Quote from: ElectricDruid on August 12, 2023, 03:50:37 PM4) This is over-thinking it. If it's equivalent in terms of connections, it's equivalent.
Okay, good. It's just my brain then :icon_lol:
Though on a similar note, how does this apply to star grounding? Does it matter how or where all the ground traces of the same group (signal, digital, etc.) touch each other before they reach the main star ground point?

ElectricDruid

Quote from: BlueLdr on August 12, 2023, 04:33:30 PM
I guess the real question I'm asking is, has manufacturing changed such that tracks are less prone to lifting now (at 10-25 mil width/spacing)?
No, they're no less prone to lifting. The question is "Are you less prone to lifting them?!"  A skinny track is a skinny track and if you mess with it, you probably will pull it off the PCB. But if you know what you're doing and can solder the parts without a lot of mucking about, no problem.
Or maybe they *are* somewhat less prone to lifting than the used to be, but the thinner you make them, the more fragile they'll be - so the question remains: what can *you* cope with?

Quote
Quote from: ElectricDruid on August 12, 2023, 03:50:37 PM4) This is over-thinking it. If it's equivalent in terms of connections, it's equivalent.
Okay, good. It's just my brain then :icon_lol:
Though on a similar note, how does this apply to star grounding? Does it matter how or where all the ground traces of the same group (signal, digital, etc.) touch each other before they reach the main star ground point?
Yes, of course it matters, or this sort of stuff wouldn't be a question. The question is *how much* it matters. You have to think in terms of resistances and currents, because that's what makes voltage differences. If your ground paths have big current differences and some significant resistance, then there will be voltage differences between them - e.g. your "grounds" won't all be at ground any longer. The smaller you can make the currents and the smaller you can make the resistances (e.g. the thicker the tracks) then the less problems you'll see.

As an example, people on here often worry about "ground loops" formed by connecting the sleeves of both jacks in a pedal, since the jacks are also electrically connected to the enclosure (which is generally good, for shielding)  but that technically makes a "ground loop" and ground loops are *bad*! Except no, in this case, I don't think I've ever really heard anyone being bitten by this, since the resistance around the enclosure and the resistance down a chunky wire between the ground of two jacks is so low (fractions of an ohm) compared with the currents that are flowing (milliamps, at max) that it's all negligible and can be regarded as one thing.

The problems often start when you have bigger currents (for us that often means LEDs, but LFOs or the 555 chip are culprits pretty often too) and those parts of the circuit share supplies or grounds with other more sensitive audio parts of the circuit - anything with plenty of gain is a risk, since the gain multiplies the problems. Luckily, a lot of modulation pedals that feature potentially "ticky" LFOs rarely feature a lot of gain - this is true in phasers, flangers, and chorus. Not that that *prevents* problems, but it certainly *limits* them.

marcelomd

Hi,

Re 4: Not sure how important it is, but I like to. When running the power trace to a circuit, I make the trace run "through" the decoupling capacitor before reaching the power input/pin/whatever it's feeding.

PRR

Why do you want smaller traces? They cost more (though they don't charge more). The size of most audio gear is the knobs and jacks and caps, NOT the traces.

In pedals it would be hard to make a "long" trace. It can be an issue in rack-mount.

What is good practice? Study the field. Plagiarize plagiarize plagiarize! Look at ALL the board layouts you can find. Audio and computer and radio. The 900MHz memory bus on a PC won't be over 3 inches; I have seen buffered audio traces run around 3 sides of a 8"x13" board to get from back jacks to front switches. And I have owned a doughnut memory board 16 inches each way with databuses down both sides (but this was 400kHz memory).

Whatever you are building, I am sure it is "like" some well-known product (almost nothing new in audio, in any decade) and today the gut-shots are usually online.
  • SUPPORTER

POTL

Interesting questions. Especially the separation of analog and digital parts, even in a purely analog device, for example, to reduce LFO noise. If separating the power rail is easy, a few ohm resistor and a large capacitor to ground are usually used. But how do you separate the ground of the digital, control, or LFO part of the circuit from the main ground?

Rob Strand

#7
Quote
Regarding trace width/spacing: R.G.'s book mentions that you should choose (minimum) trace widths, pad sizes, etc. based on the skill of the builder because of the risk of the copper peeling off the board, among other things.

Quote
Why do you want smaller traces? They cost more (though they don't charge more). The size of most audio gear is the knobs and jacks and caps, NOT the traces.

In pedals it would be hard to make a "long" trace. It can be an issue in rack-mount.

Maybe the meaning is: The "skill of the builder",ie. the capabilities of the PCB manufacturer, determines the minimum track widths, spacings etc.   More a statement of fact than a prescribed recommendation to push the limits.

The closer you push things together the more chances of problems caused by unforeseen events eg. shorted tracks, open tracks, solder bridges.  Also risk of PCB damage during repairs.   These issues have been discussed on the forum in the past.   (Yes it is possible to build insanely small devices.   I worked on an implant which had (IIRC) 4 thou tracks!  The PCB manufacture and assembly needs to be done by people who are qualified.)
Send:     . .- .-. - .... / - --- / --. --- .-. -
According to the water analogy of electricity, transistor leakage is caused by holes.

R.G.

Quote from: BlueLdr on August 12, 2023, 02:18:55 PM
1. Regarding trace width/spacing: R.G.'s book mentions that you should choose (minimum) trace widths, pad sizes, etc. based on the skill of the builder because of the risk of the copper peeling off the board, among other things. From reading the book, it's clear that some time has passed since it was written (not knocking the usefulness of the information though!). So I'm wondering, do these limits still apply with modern manufacturing techniques, assuming the board is made professionally with Gerber files?
I'm no soldering expert, but I've done enough that I think I'm past the beginner stage. Can I get away with 10 mil traces and spacing?
As E.D. notes, what you can get away with is what you personally can get away with. The only way to find out is to get some 10/10 mil boards and go do the soldering to see if you're up to it.
Modern manufacturing includes solder masking, which makes a HUGE difference in whether manual soldering is practical or not. You're right, the info in the book was oriented heavily toward beginners working on not-necessarily-pro manufactured boards. The best advice is to be sure your Gerber/pro boards made with solder mask on the side(s) you'll solder on.

Quote
2. Everyone says to avoid long traces. But how long is a "long" trace? I know it varies based on the impedance, but rough numbers would still help a lot.
Again, E.D.'s comments are correct. To add to that, PCB traces should be as short as >practical< given that wavelengths for audio are so long that the traces don't need to be considered transmission lines. There's no idea that they have to be shorter than 10mm or 2 inches, or some other number. There are a few reasons, not least of which is that if traces wander around they are more likely to get near some other signal that will cause interference or parasitic capacitance coupling and oscillation. The shorter and more direct the traces, the lower the chances you'll run into this kind of cross-contamination.
Then there's logic coupling. Most effects boards will have some kind of switching/logic on them these days. A logic edge can have frequency components up into hundreds of MHz or more, so they can well have capacitive or magnetic coupling more easily, and can need transmission line considerations taken into account. You really don't want your CMOS switching logic coupling ticks into the audio.
So good practice is to make PCB traces as short as possible. Only make them longer than "as short as possible" when you have a clearly expressible reason why not. High impedance stuff like JFETs, MOSFETs and CMOS make this very, very important. A JFET input opamp can hear signals through a fraction of a pF of coupling. These pins deserve extra consideration for short, short, short traces.
I wish I could tell you a distance. Unfortunately, the best guideline is to make them as short as possible, unless you really just can't.
Quote
3. In my reading, I've gathered that digital and analog (audio, at least) parts of the circuit should be completely separated. But as with the previous question, I don't have a solid definition or example of what that means in practice for stompbox circuits. How far apart should they be?
If I can draw a 0.1" line across the board between all the analog parts/traces and all the digital parts/traces (excluding the relays doing the switching), is that good enough?
Strictly speaking, they should be across the room from each other. That clearly won't work, so you're forced to do less than that. It's another of those things you need to do the best you can, because it's an electrical distance, not a physical distance you're trying to meet. The thing is, the impedance driving the PCB trace and the impedance terminating the trace AND the frequency content of the signals on the trace matter.
You want the 5V logic signals to NOT be able to capacitively couple over to the MOSFET inputs. This might even need you to place them 0.5" apart and to run a ground plane or ground trace between them. And you don't want the 9V audio on the output of the opamps getting into the JFET inputs of the other opamps.
Separating the analog section from the logic section on the surface of the PCB is a good start, but often you can't draw a straight line separator within the available space. A dividing line does minimize the transmission from one glop of circuit to another, but it can be crooked. Electrical separation matters. Ideally, the analog ground traces would be separated from the digital ground traces and only join one another at the power ground feeding into the board. Also any analog vs digital ground planes.
About now you're thinking "I can't do all that, and it's no guideline at all." You're right. It is very, very difficult to do a PCB design that you can know ahead of time is going to work 100%. In human layout work, you use experience. Some of the experience is not directly expressible as a fixed separation distance.

Quote
4. This one feels like either a beginner concept that has managed to elude me, or a rule I've just imagined because of how my brain works: For a given net, is it important for the "common" connection point(s) between components to be the same on the board as they are in the schematic? In other words, when routing in a PCB program, should I connect components based on the schematic, or the rats nest?
The rats nest >>is<< the schematic, assuming that the software that made the rats nest is working right. The only difference is that the lines between part pins are re-drawn on the fly from a component pin to the next-closest pin in that same net.
The right answer is to lay out for smoothest, most direct signal flow. Inputs should come onto the board either on one edge or at the soldered-in input connectors. The signal is typically amplified, shaped or tone-filtered, amplified more, adjusted, amplified, etc., until it becomes an output. The output should be as far as it reasonably can be from the input, within the limits of the board. There should be some kind of logical flow of the signal from input to output. That is the concept from the book where it talks about linear and U shaped signal flow on the book. The simple, unbranched, un-zigzagged signal flow path is least likely to cause signal feedback and or interference.
Power and grounding are "signals" too, and should be routed based on current flow and preventing current-caused voltage wobbles caused by the trace resistances. These are related to but not the same as the simple routing of signals.
I guess the answer is "neither". Placement and routing should be based on what the electrical signals are doing. This is related to the schematic [assuming that the schematic is well-drawn for information transfer!] but the schematic is not enough info to do a full job. Audio-only PCB routing can typically be sloppy and negligent and still work OK-ish because of the low frequencies involved.

I apologize for not being able to give you more clear, distinct numeric guidelines. I could make up clear, distinct numeric answers, but I would be doing you a disservice if I did.
R.G.

In response to the questions in the forum - PCB Layout for Musical Effects is available from The Book Patch. Search "PCB Layout" and it ought to appear.

BlueLdr

Thanks SO much for all the information, everyone! This is exactly what I was hoping for ;D

At this point, it'll probably be useful to go into the specifics of my project. I'm building a buffered switching box (pseudo-schematic here, the KiCad project is linked below if anyone wants to take a look at it). Before designing the PCB, I made a 3D mockup in Fusion360 of all the jacks/switches/etc. positioned inside the enclosure, a 1590DD (I don't want this thing taking up any more space on my pedalboard than that).





After that, I replicated the mockup in the PCB editor, as exact as I could get with the smallest grid snap. I created footprints for all the parts that would take up space but didn't mount to the PCB. From there I set the board outline and added mounting holes.



Then began the tango. Or the waltz. I can't dance so I have no idea what the equivalent is. Anyway, I had done several iterations of the PCB up to this point, and I did one more with this thread's feedback in mind. Here's the KiCad project on GitHub, and a screenshot of the PCB (I know it's virtually useless without being able to inspect the nets, but whatever).



Here's a quick summary:

  • Signal/digital tracks are 12/12 mil, everything else is 25mil width, 18mil clearance
  • Copper-to-hole clearance: 24 mil, copper to edge clearance: 50 mil
  • Ground plane under all the digital stuff
  • Separation between analog and digital is drawn in green
  • All the offboard wiring is connected with molex headers

Quote from: PRR on August 12, 2023, 07:35:15 PM
Why do you want smaller traces?

Purely because of board space. As you can see, this is a lot to stuff into a 1590DD (with all the jacks and everything).



soggybag

This might fly in the face of more experienced advice but my current "technique" is to determine the enclosure, position the pots, switches, and LED. Then I lay out the off board connection. At this point I'm ready to place the components.

Using this allows me to use as many board mounted parts as I can to make assembly easy. I also have a standard layout for off board wiring that I use. This means every board wires up the same and I don't have to look up the wiring or even check the connections since they are always in the same arrangement.

Having the LED amounted to the board saves on wiring, and makes the assembly easy.

ElectricDruid

I'm with you on this, Soggybag. I hate doing offboard wiring, so if I can board mount stuff, I generally will. In my view it's more reliable and it makes for a much neater build.

R.G.

Quote from: soggybag on September 04, 2023, 03:26:57 PM
This might fly in the face of more experienced advice but my current "technique" is to determine the enclosure, position the pots, switches, and LED. Then I lay out the off board connection. At this point I'm ready to place the components.

That's hugely important! It's in PCB Layout... but it's' worth repeating: the FIRST thing to do is to figure out where the pots, switches, jacks, mounting holes, and so on that you really can't (or shouldn't) change go, so you can place PCB parts around them. Always, always know the enclosure, controls and jacks locations, where off-board wires run and so on before ever placing a component, and if you have a rats'-nest capable PCB program, place all the part before routing any traces. It's amazing how easy routing traces becomes when the placement is good.

I like to put all the off-board wire locations on one side or end of the PCB. This lets you lift up the PCB for service without unsoldering wires. One of the worst things to service is a PCB with off-board wires coming out in the middle of the PCB, and/or around two or more edges. On my boards to replace the preamps in Thomas Organ Vox amps, I placed the um, 70 or so off-board wires along one edge so the whole board could be bent up to get at the bottom for repairs. The original boards had wires on two long (~ 10") edges plus some trailing out from the middle. Repairs are so hard that most techs simply refuse to work on them.
R.G.

In response to the questions in the forum - PCB Layout for Musical Effects is available from The Book Patch. Search "PCB Layout" and it ought to appear.

POTL

agree with Electric Druid and soggybag. If you can not use wires, it is better to solder everything to the board. I love terminal wires like the Way Huge or flat wires like the MXR, they look neat and modern. I love neat boards, with components of the same type (only SMD or only THD). Ideally components of the same size, such as capacitors and resistors with 5mm foot spacing, or all smd components of the same size (only 1206 for example). I do not like randomly scattered components, like EHX. Making a board is a separate art form.

BlueLdr

Quote from: ElectricDruid on September 04, 2023, 03:51:09 PM
I hate doing offboard wiring, so if I can board mount stuff, I generally will. In my view it's more reliable and it makes for a much neater build.

I really wanted to, but with 9 jacks across 3 sides, plus top-mounted switches/etc., I decided to heed R.G.'s advice in his book and mount everything to the enclosure.

Quote from: R.G. on September 04, 2023, 04:11:23 PM
I like to put all the off-board wire locations on one side or end of the PCB. This lets you lift up the PCB for service without unsoldering wires. One of the worst things to service is a PCB with off-board wires coming out in the middle of the PCB, and/or around two or more edges.

I tried my best to keep them on the top half of the board (see image), but it was difficult with the offboard connections having to go to both the buffers and the relays, while also keeping traces short, and keeping digital away from analog.
Is there any particular reason I should solder directly to the board rather than using molex headers?


R.G.

Quote from: BlueLdr on September 04, 2023, 05:55:37 PM
I tried my best to keep them on the top half of the board (see image), but it was difficult with the offboard connections having to go to both the buffers and the relays, while also keeping traces short, and keeping digital away from analog.
I wish I had a better solution, but yes, it can be difficult.
The best analogy I have is that it's much like playing guitar. With practice, even difficult passages get easier. The more times you go through the process, the faster your mind recognizes and leaps to solutions similar to the ones you've seen in the past.

Quote
Is there any particular reason I should solder directly to the board rather than using molex headers?
Molex headers are a mixed blessing. Yes, they're easy to plug and unplug. That helps a lot with getting a board in and out for service, but you still have to leave enough wire length to connect the board up with it out of the box. The good headers, from a recognized supplier and gold plated, are reliable, but even then you have to use the locking or friction locked headers and shrouds or they can come loose. Non-gold-plated headers and wire sockets oxidize in short order and can get noisy. You need special tools to crimp molex-style wire terminals reliably. The bifurcated insulation displacement mating plugs are not necessarily reliable in the insulation displacement.

This is probably not an issue for a home builder, but for commercial sales, I'd recommend against pin headers and wire terminal shrouds. In my professional experience, these account for a significant amount of warranty and repair issues. For one or a few pedals, you're probably fine.

I know that sounds odd, as computers use huge numbers of these contacts. But computers have signals that have a couple of volts of swing between logic high and logic low, and remarkably few insertion/removal cycles.

So for diy stuff, in my opinion, it's better to forgo the headers and terminals in favor of soldered-in wires, and even then on 150mil or wider spacing if you can possibly do that. It's not a binary decision.
R.G.

In response to the questions in the forum - PCB Layout for Musical Effects is available from The Book Patch. Search "PCB Layout" and it ought to appear.

MrStab

Recovered guitar player.
Electronics manufacturer.