Wednesday, 22 June 2016

Sacrificing pins to make PCB layout easier

Wherever possible, we like to try to keep to single-sided boards, even for designs going "into production". While it's easy to throw together a poorly-designed, double-sided PCB and send it off to a factory to get made up, that means delays and waiting; and quite often, a much slower development cycle - particularly if, like us, you have an iterative design process!

Keeping designs to single-sides means you can knock up some ferric chloride, try out your design and have a working board in hours, not days or even weeks.

But even if your project isn't time sensitive and you can afford to wait weeks, between ordering and receiving your boards, it often means either:

a) when the board needs redesigning (because you forgot to include the ground plane, or re-route that pin you left a "to-do" note against and then ignored - don't pretend it hasn't happened) you've got another four-to-six-week wait while the new boards arrive OR

b) tack-soldering a few wires and slicing traces with a craft knife, just to get the thing up and working.

Either way, you end up with a less-than ideal PCB or weeks and months of delays.
Homebrew etching is ugly. The results are less than perfect. It's messy and you'll stain your hands yellow for days (and possibly the sink forever if you're not careful). But it gets a result - quickly.

So if you need to redesign a board, you can simply print out a new design, slap down some toner transfer, whack it in some ferric chloride and an hour or two later, you've an amended design. And once you're absolutely sure your design works, you can send the exact same PCB layout to your favourite factory/fab-house and then wait (one time only) for the nice, shiny, silk-screened-and-solder-masked versions to arrive, for the final product.

That's why we still make our own PCBs.
It might not be fashionable (in fact there are plenty people who ask why, when having PCBs manufactured is so cheap, would you want to still etch your own boards) but it is quick and allows the iterative design process to complete fully - no boards with bits of wires tacked on because we've committed to a single design now (even with faults/errors) and can't wait any longer to get the thing soldered up and tested! That's why we favour single-sided designs.

But there are a couple of cheats we use to simplify our single-sided boards.
And they're not always obvious.

The one we use a lot - and that generates a lot of questions - is "pin sacrificing".
Simply put, it means identifying not only which pins on a microcontroller we want to use, but also which ones we can live without. And for every pin we can live without, we have a little bit more room on our board.

Here's an example of  a board we recently came up with.
Space is really tight with this one, so routing complex round-the-houses traces everywhere was out. We also wanted to etch the board ourselves, so double-sided wasn't an option either.

The chip in the middle is a 32-pin ATMega328 TQFP with pin one in the top-left corner. In our design, power is coming in on the bottom-right of the board (where the upside-down number 16 is).

In order to route power to the AVCC and VCC pins on the board, we'd probably have had to used either a double-sided board or made the whole design much bigger, to accommodate either 1206 jumpers across tracks, or routing tracks around, in and through many other pins on the board.

But, looking at the layout of a TQFP atmega chip:

The pin we're trying to get to is 18 (AVCC).
But if we sacrifice pin 17, we can simply join them together. There's no need to go around pin 17 (B5) we can just plough straight through it! Then in our firmware, we can make B5 a digital input or hi-Z tri-stated pin and it's as if it's not even there.

Similarly, when trying to route power to the top of the board, we struggled to run a trace around the outside of pins 4 and 6. But by sacrificing pin 1 (D3) we can run our power trace straight through it, and up towards the top of the board with plenty of room to spare.

It's all too easy to take a working breadboarded layout and try to shoe-horn it into a PCB layout - when changing a few pins would simplify the design no end.

Well it's also possible to make things much easier on yourself if you give up a few of the pins on the microcontroller. After all, if you're not using them, does it matter if they're tied to ground (or power, or even other pins on the mcu)? And if not, don't waste time trying to around them!

No comments:

Post a Comment