Search This Blog

Loading...

Friday, August 27, 2010

Building Blocks: The Microcontroller

As part of the building blocks series, I thought I would share a modular microcontroller design that I came up with over two years ago and that I am using for the scoreboard project. The Arduino craze not yet peaked and I was not fully aware of what it was, however, I did see some value in what they were doing and couldn’t help but allow the Arduino influence my design. Basically I took the shield concept, added a passthrough bus, and threw out the rest. Arduino is beneficial to those that don’t have a Programmer or who are not familiar with C/C++ or assembly. I had both, so I saw Arduino as having way too much circuitry for my tastes. So, what did I do? I built my own. (This is a common theme with me, in case you haven’t noticed.)

What follows is an admittedly lengthy excerpt of a contribution that I made on the Society of Robots website back in 2008, where I first cut my teeth in all things electronics and mechanics. It’s interesting for me to go back and read my thoughts back then.

A Modular PCB Layout

Introduction:
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.

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.





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.

ATmega Baseboard with 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.

One Quadrant Module with Stackthrough Connector

Two Quadrant Module with Stackthrough Connector

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


The 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.


ATmega168P Baseboard Schematic
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 ATmega168 Baseboard

I think I’ll stop for now. There is quite a bit more, but this post is getting way too long as it is. I have several “modules” that I’ve developed for this board, including an ISP module, a Serial module, a Power module, a Motor controller module, and an Analog sensor input module.

1 comment:

  1. Hey, nice site you have here! Keep up the excellent work!
    5v SMPS

    ReplyDelete