A Modular PCB Layout



This project started as a result of my frustration and consternation with etching my own PCBs. Now, if I could draw out a board to perfection in Eagle on the first try, I probably wouldn't have thought of doing this. However, my Eagle skills are somewhat lacking, as are my soldering skills. I needed a simple way for me to avoid having to build and debug large and complex boards for each project on my list. In addition to reducing the risk of me screwing up a large board, I found that it creates a bit of a "plug and play" environment where I can add and remove modules as needed for my various projects. Changing from a robot controller with motor driver and sensors to a temperature sensor with LCD display is as simple as swapping out the modules you need and reflashing the AVR. (I know, I don't have an LCD module yet, but I will!)


As I took a look at some of the projects I wanted to create, I realized that there was a common basis for these projects; what I will call the AVR baseboard. There was always a socketed AVR (atMega168 for me), a reset button w/ resistor, and a decoupling capacitor. I wondered if I could build a VERY simple AVR baseboard and then just create modules for the functionality I wanted to add to it. Hey! While I'm at it, I could make them all stack together in a nice neat stacking bus arrangement. At first, I thought it was going to be a bit ambitious for someone of my skill level. Well, I did it, it seems to work pretty well, and I want to share it so that I can inspire others and also (selfishly) get some good feedback from the community on improvements, errors, etc. Here's how it goes.


Note: In this tutorial, there are several pictures of actual PCBs that I etched for this project. In most instances, you can plainly see the traces on the under side of the PCB when viewing the PCB from above. This is because the copper clad I bought off Ebay was super, super thin. At first I was cursing myself for being ignorant and not knowing what I am buying, but now I kind of like the stuff. I can cut it with regular scissors. It also bends very nicely, so a strip of it could be used in clothing or in a rounded panel for mounting LEDs, etc. Its not so great when you are trying to create a structured project like this one, but I managed to work through it. I worry about the flexing causing weakness in the solder joints and causing pads to lift. Nothing like that has happened yet though.



1) Form Factor



First, I decided on a physical form factor. If I was going to connect multiple modules together, it would be nice if they were all of a "standard" size. I picked a 2" by 3" PCB dimension for the AVR baseboard and for a large module. I picked two other sizes for smaller modules, 2"x1.5" and 1"x1.5". (see the first attached graphic "Module Sizes.png")


This effectively gives me a full size, half size, and quarter sized modules. It also breaks the AVR baseboard into what I like to call "quadrants". I've labeled the quadrants A, B, C and D.  Each of the modules that I've built are built specifically for one or more quadrants. You'll see why when I go into detail on the ISP and Serial modules.


Module Sizes



I guess there's not much more left to say, so let's move on to the board to board connectors.



Module Sizes.png36.75 KB

2) Connectors


The board to board connectors for this idea turned out to be the hardest part for me to figure out. I was essentially copying the stackthrough bus on the PC/104, but I didn't need 104 pins. Not even close. So, for a while I was cobbling it together with a male header soldered from the bottom of the board, and a female header receptacle soldered onto the male pins that were sticking out through the top of the board. It was very problematic for my soldering skill level, but I managed to get it to work fine after much trial and error.


Note: I designed the connectors based on the pinout of the ATmega168P because this was my target MCU. This strategy could be extended to other, more or less powerful MCUs.


The pinout of the ATmega168P lends itself quite nicely to my "quadrant" strategy. Looking at the pinouts, the pins are split into two rows 1-14 and 15-28, simply because it's a DIP package. Additionally, each row is further divided in half, roughly, by the GND, VCC, AVCC, AREF pins. This gives you four clusters of pins in each quadrant. Pins 1-6, 9-14, 15-19, and 23-28. There's, at most, six signal pins in each quadrant.


Power is something I thought long and hard about. I'd like for each module, regardless of size, to have access to regulated power, unregulated power, and ground. This will allow for the ultimate flexibility. That adds another three pins to the connector for each quadrant. So, that adds up to 9 pins for each quadrant.


The connectors I created, and then ultimately found a supplier for, create a stackthrough bus between the PCBs in the stack. All pins are passed through the connector to the board above it, in addition to being connected to a trace on the PCB if needed. This allows modules to share pins, if necessary. I haven't actually needed to share pins yet (except for the I2C bus), so I'm not even sure it's possible/recommended, but I can see where it might be necessary in some cases. There's no magic going on here, so don't start thinking you can just plug a module anywhere and it will work. This is simply a method for organizing and connectorizing.


Here's the AVR baseboard with the connectors attached. Note that since the baseboard is designed to be on the bottom of the stack, I don't use the stacking connectors on this board.


Modular Baseboard

ATmega Baseboard w/ four 1x9 female header receptacles


I was able to find some female header receptacles with longer solder tails. The solder tails are actually shaped like regular header pins, so they're specifically made for this purpose. I sourced them from Samtec and just got my samples in a couple days ago, so you won't see them on my pictures. I think they'll work great. The part number is ESQ-109-14-G-S and they're $1.40 each in quantities less than 555. Over that, I think they drop to about $1.19. You can order the tin version rather than the gold versions using part number ESQ-109-14-T-S and they're $1.02/$0.87.




Modular One Quadrant

One Quadrant Module with Stackthrough Connector



Modular Two Quadrant

Two Quadrant Module with Stackthrough Connector



Modular Stacking Example

Module Stacking Example



Note: I realize that there may be some over-current concerns on the connectors, specifically with using the unregulated power for driving motors. I will try to address these in version 2 of the PCB designs by creating some sort of external power bus for the unregulated power.  Perhaps another module!  :D



Modular Stacking Example.png52 KB
Modular One Quadrant.png47.67 KB
Modular Two Quadrant.png38.81 KB
Modular Baseboard.png44.62 KB

3) ATmega168P Baseboard


The ATmega168P baseboard is very simple. The goal is to break out the pins to the four connectors while only adding additional components if absolutely necessary or highly convenient. You will note that I took this to the extreme in that there is no power supply on this board. I did this intentionally, because I have a few projects that I will likely end up using 3.3V for, so why not make the regulated power supply just another module? I couldn't think of a reason not to, so I did it.


The only parts on this board are: a 28-pin socket, a momentary switch for the reset button, and a pull-up resistor for the reset pin. Later, I added a decoupling capacitor for the ADC Voltage Reference pin. I laid the traces for an external resonator, but that is completely optional. Using the clock internal to the ATmega168P works just fine, but I did want the option of boosting the processing power if necessary.


You might notice that I labelled the quadrants A, B, C, and D. This is simply a marking system that will help me remember on which quadrants I can connect my modules. Each module I made has a similar marking. This just keeps things straight when I take a week or two off and then come back to it.


I didn't build this board with a top layer. The board layout uses the top layer to help me figure out where to put my wire jumpers. In the future, I'll probably try to see if I can do a double layer board. It's not really a priority for me right now though. If you want to use my files for a double sided board, make sure you increase the width of the top layer traces.


The Eagle files are in the attached Zip file.


Baseboard Schematic

ATmega168P Baseboard Schematic



Baseboard Layout

ATmega168P Baseboard Layout


I decided to place the unregulated power, regulated power, and ground rails on the connector pins closest to the ends of the PCB. The problem with this is that for the single quadrant modules, the power pins only match up for two of the four possible quadrants, so they can only be used for those two quadrants. For the other quadrants, the pins are reversed from what they need to be. I didn't notice this at first, but honestly I don't have a whole lot of single quadrant modules that can go in any of the four quadrants. Most of them have to be in a specific quadrant anyway, so no big deal.


I've got another way of doing this in mind which may be more flexible, but this is how I've chosen to do it for now.



Finished Baseboard

Finished ATmega168 Baseboard



Note: I'm not sure if I should have also connected the resonator pins to the bus connectors. I was worried it might affect the operation of the resonator if I decided to put one in, so I didn't connect them. Can anyone comment on this? I think the length of a trace going to a resonator needs to be as short as possible to avoid picking up interference on the traces. Passing these traces from the MCU to the resonator and then on up a bus connector strikes me as a bad thing to do. I guess I could put some jumpers in there or something. Comments?



Baseboard Board Schematic.png68.94 KB
Baseboard Board Layout.png61.79 KB
ATmega168P Baseboard.zip17.8 KB
PCB Modular 003-small.jpg54.81 KB

4) Regulated Power Supply



Of course, the first module I built after completing the AVR Baseboard is a regulated power supply.


This module is a two quadrant module and can be connected to either side of the board. You have to be careful to rotate the module properly so that the power and ground matches up with the baseboard. A commercial product would probably have the connectors keyed, but I really didn't want to have to deal with that. I simply marked the board as being compatible with AB and CD and left it at that. Since this was my first module, honestly, I was having other, much larger, issues.


There is nothing spectacular about the circuitry. It is a standard 5V power supply, based loosely on the breadboard power supply tutorial at Sparkfun. It includes a on/off switch, a status LED for the 5V rail, a terminal block for easily connecting power, and a fuse on the 5V rail so that I don't blow up my electronics with a short. It's saved me at least once so far.


So now, with this module, I can power a 3.3V project or a 5V project with the same components. Maybe I should socket the Voltage Regulator with a female header receptacle. Then I can use the same board for any regulated voltage I want. Hmm...good idea...


Power Supply Schematic

Power Supply Module Schematic


Power Supply Layout



Finished 5V Power Supply Module

Finished Power Supply Module


Power Supply Module attached to AVR Baseboard

Power Supply Module attached to Baseboard



Note: The addition of the screw terminals was something I added in after the board was already made. I simply coerced the 5mm spaced pins into the 1st and 3rd holes and jumpered the third hole to where it needed to go. Also, I omitted the reverse voltage diode because it wouldn't fit with the screw terminal in place.  All things I plan on fixing in the next revision.



PCB Modular 001-small.jpg45.57 KB
PS Schematic.png50.47 KB
PS Layout.png30.9 KB
5V Regulated.zip13.8 KB
PCB Modular 004-small.jpg126.77 KB

5) ISP Programmer Module


The next step is to build something that you can program your AVR with. So, I decided to build the ISP Programmer Module next. This module is simply a conversion from the 1x9 pin connectors to the standard 2x3 ISP connector used with the AVR-ISP MKII programmer. There's no reason this couldn't be modified to have the 10 pin 2x5 connector used with other (older?) programmers.


There is one oddity with this module. If you take a look at the pins required for the ISP connection, you'll notice that all but one pin is available in the "D" quadrant of the baseboard (SCK, MISO, MOSI, VCC, and GND). The only pin that is not in quadrant D is the Reset pin, which is in quadrant A. Argh! I don't want to build a full sized module just for ISP!


My compromise is this. I connected a length of wire to the Reset pin of the ISP connector, then stripped the other end of the wire. This way, I can plug in the module and then plug the Reset wire into the Reset female header in quadrant A. Reading that description, I don't think that was terribly clear...easy concept, hard to explain, I guess. The picture will clear it up.


I'm not terribly concerned with this departure from the standard way of connecting things because the ISP Module probably won't be on the finished project once it's been programmed anyway.


ISP Programmer Module Schematic


ISP Programmer Module Layout


Finished ISP Programmer Module

Note: I had to jumper a couple traces because I got them backwards in the first revision of the board. DOH!


ISP Programmer Module and Power Supply Module Installed on the Baseboard

(The module is crooked because of the crappy soldering job I did on that module...don't laugh!)



ISP Module Schematic.jpg36.85 KB
ISP Module Layout.jpg21.43 KB
PCB Modular 005-small.jpg35.27 KB
PCB Modular 006-small.jpg47.38 KB




That's all I have time for right now. I will post additional modules in the near future. These are:


Currently Designed:

On the Drawing Board:


I also plan on posting code samples with these modules so, if you build them, you can get them up and running quickly.