Wednesday, April 18, 2012

AVR ATMega328 Target Board

Like most contemporary electronics hobbyists, I got my initial start on the Arduino four years ago.  Of course, after about a year playing around with their bulky blue PCBs, you want to start being able to put Arduinos in projects without paying $30 a piece for the whole development platform.
The trick is that the Arduino platform essentially boils down to an ATMega328 running a bootloader, which lets you reprogram the chip through a serial port instead of needing an in-circuit AVR programmer.  You can then buy just the ATMega328 chip online for a few dollars, and then build around it only the parts of the Arduino board you truly need. The problem is that when you buy the AVR from a chip supplier, it doesn't usually have the Arduino bootloader preloaded on it, so using the Arduino IDE there is no way to reprogram it. (Note: you can buy preprogrammed chips, but you pay a $2 premium)

I opted to buy a tube of 25 blank AVRs, which saves me money as I continually drop Arduinos into projects, but I need some way to burn the bootloader the first time before I can start reprogramming it.  Of course, burning the bootloader uses a different six pin header than the serial port, so you need to either wire both headers into every project or have a separate board which you can use just for the initial burn. One board you can use for this is actually the original Arduino board, because they have the ICSP header and are often at hand, but trying to get more than a few new chips into and out again from a normal DIP socket gets tired fast. New DIP chips come with their pins bent out 20-30 degrees, so to get one into a regular DIP socket requires bending pins and a light hand as you put it in and pull it out to prevent breaking off pins.
Meet the Zero Insertion Force (ZIF) socket! There are most commonly used on computer motherboards to allow users to replace the hella-high-pin-count CPUs, but you can get them for DIP parts as well.  Mine happens to be designed for 40 pin 0.3" or 0.6" DIPs, which I got on eBay for $2. Ideally, I would have gotten a 28 pin version to match the ATMega328 28 pin package, but this one happened to be cheaper, and I plan to add in ATtiny85 programming capability at the bottom of the socket.
Grabbing a random piece of perf board and all the components shown in the schematic, it only took me about an hour to solder this target board together.  Now, I can sit down with a new tube of 25 ATMega328s, an ICSP programmer, and easily burn all of them with the Arduino bootloader without running the risk of breaking any pins off.
I first plotted out about where I wanted all of the connectors; ICSP in the middle, serial port on the left, and reset button between.  I left space on the right for a DC jack and 5V regulator to allow this to be programmed independent of the programmer, and will eventually wire up the right 8 slots of the ZIF to support the ATTiny85 AVR as well.
Most of the wiring was done on the bottom using 32 gauge wire-wrap wire.  Feel free to use any technique you like, as it suits you and your perf board.
One thing to notice is that I've started using mostly 0603 surface mount passives, even when I'm working on through-hole projects on 0.1" perf board.  Removing the need to figure out where to fit a 0.2" capacitor when you can just tack it between pins makes layout quite a bit easier and cleaner.  Can you spot the four capacitors in the bottom view of the board? :-P
In the end, this is a very useful little piece of kit to have rubber banded to your programmer, such that any time that you just need to program an AVR one time real quick, it's just a matter of dropping in the chip, pushing down the ZIF lever, running avrdude, and then lifting out the programmed chip and installing it in your project.

In my next post, I'll show you one of these applications of the Arduino which profited both in size and price from not using the entire Arduino board. I'll also eventually post an update to this post showing the power supply section built (which you won't normally need, but I will need it for a future project) and the wiring to program ATTiny85s on this target board as well, but I'm looking to be rather busy for the next few weeks.

6 comments:

  1. I use ATmega328 the same and also get them blank. I just add the ICSP header to my projects and use the Arduino IDE programming environment to code and upload using the USBTiny programmer.
    This way I don't need the bootloader overhead and I still get to use the Arduino IDE and I never have to take the chips out of my projects in order to re-code them.

    See my detail post on how I normally do this at ToddFun dot com under all posts titled:
    "Make a custom minimal Arduino board and program a blank ATmega168 or ATmega328 directly from the Arduino IDE."

    ReplyDelete
  2. Argh... Just buy an AVR Dragon and put some sockets on it. For fifty bucks you get ISP/HVSP/JTAG programming and in-circuit debug. Since AVRStudio 4.X ATMEL removed the artificial memory limit in the Dragon. David

    ReplyDelete
  3. For $2 plus my junk box, I got exactly what I need. I do hope to use this target board for more than just burning bootloaders, but my soldering iron is currently packed in one of many boxes as I'm currently moving.

    ReplyDelete
  4. Kenneth, Did you give any thought to my post at ToddFun on skipping the bootloader and just using the Arduino IDE to burn the code to the chip using your USBTinyISP? It works great and instead of putting a UART port on your target board you just set it up with a ICSP port. I have also built a parallel port programmer cable that doesn't the exact same but doesn't need a programmer because the cable does it all. I have a USBTinyISP so I just use that most of the time.

    ReplyDelete
    Replies
    1. I did. I couldn't find your blog post, so please link to it directly. Skipping the bootloader does give the advantage of getting those 2kB of flash back, but I'm rarely pushing my projects anywhere near that close to the edge, and I usually use the serial port for debugging, configuration, etc, so I would still need to install both connectors, which was what I'm trying to avoid.

      It will be a good trick to have up my sleeve should I need it. I knew it was possible, but didn't know the specifics, and look forward to seeing your post on the subject.

      Delete
  5. Nice timing. My USBTinyISP kit and a ZIF socket from Adafruit as well as a whole bag of parts including ATMega328 and ATtiny2313 chips from Tayda arrived the same day this post went up. Going to try and put together a target board myself when I can get a bit of free time.

    ReplyDelete