Using AVR microcontrollers: Minimalist target boards

USBtinyISP and simple target
This is a quick how-to guide on making ultra-simple development boards for programming AVR microcontrollers. Most recent-vintage AVRs can be programmed through an ISP (in-system programmer) connection; all that is really needed is a place for the chip to sit and a way to connect to the programmer. That's where these minimalist AVR "target boards" come in. These little boards cost only about $2 and take only a few minutes to make. It turns out that I build a lot of these because asking "how do you make a circuit to program the AVR?" is really the same as asking how you can program an AVR that is in a circuit. And, we might as well start with a simple circuit.

There are two basic types of microcontroller programmer that you can imagine: one that has a socket for your chip, and one that hooks up to your circuit where your chip is installed. We're interested in the latter, the set of so-called in-system programmers, sometimes called in-circuit programmers. You can also get programmers with dedicated sockets, of course, but they are typically more expensive and are not fundamentally "better." With an in-system programmer, not only can you program microcontrollers that are in larger circuits, but you can also easily make programmer target boards with sockets, giving you the benefits of a programmer with a socket.

AVRISPII The de facto standard USB in-system AVR programmer is the Atmel AVRISP mkII, part number ATAVRISP2-ND from Digi-Key, for $36. I actually wrote a bit about using this programmer last year. It's a good very-few-frills programmer and it works quite well. It has a hard plastic shell with a USB "B" connector on one end and a cable ending in a 6-pin ISP connector on the other end. (If you take the case off of the AVRISP mkII, the circuit board has a place for you to add a 10-pin ISP cable as well, but this is an unpublicized feature.)
One drawback to this programmer is that it requires external power to be applied to the target board in order to operate. That's kind of silly, because the programmer draws the power that it needs to operate from USB, but does not pass that through to power the microcontroller during programming. Ideally, the programmer should have a switch, so that you can either use the programmer to power your target board or not.


USBtinyISP, assembled


The new USBtinyISP AVR Programmer from Adafruit industries (Reviewed here) is probably a better choice for most applications. It comes as an easy kit for $18.00 $22.00 and it includes both 6-pin and 10-pin interfaces. The killer feature versus the AVRISP mkII is that it lets you use the USB power to directly power your target board. Well, that and that it comes with both 6-pin and 10-pin ISP cable connections.


One other neat option (for some of you): You can use Arduino as an AVR-ISP programmer.

For folks that don't want USB, there is no shortage of serial and parallel ISP programmers. Most of them use the 10-pin interface. Adafruit has one of each serial and parallel. You can also get them from other sources (e.g., SparkFun), but usually at a higher cost. And, if you do have a parallel port, let's not forget that you can almost whip one up out of thin air.

Anyway, back to the target boards. Previously we've mainly used "real" development boards that include power supplies, communications, and a crystal oscillator.

ATMEGA168, and its messy dev board Typical varieties are these available from SparkFun Electronics, which are mostly made by Olimex. There is also an excellent board from Futurlec, and there are dozens of others from other sources as well. (Notably these excellent open-source reference designs by Pascal Stang.)

It's often overkill. In the dev board shown here, I'm only using the power connector, socket and the ISP connector of the original board-- none of the other features turned out to be handy for what I ended up building on this board.


So, when does it make sense to solder your own target boards? For starters, it's easier to use through-hole (DIP) packaged AVRs. One of the really nice things about the AVR series of microcontrollers is that a many of them are available in hobbyist-friendly through-hole (DIP) packages. (However, if do need to use one of the varieties that is only available in a surface-mount package, getting somebody else's development board or laying out your own can really make sense.)

Let's get started.

To begin with, we'll make a minimal target board for programming an ATtiny2313, a popular 20-pin AVR microcontroller.

Components - big board

Here are the components: Prototyping perfboard (BG Micro part number ACS1053, $0.99), a 2x3 DIP header (Part of BG Micro part number ACS1019, $0.33), and a 20-pin DIP socket (BG Micro part number soc1029, $0.55). We also have a couple of optional components: a zero insertion force (ZIF) socket and a 3 x AAA battery box. ZIF sockets tend to be quite expensive-- we found these on eBay for only a few dollars each, so we'll actually build this board with one.

Mark pin 1

The first step is to position the socket and the ISP connector header on the protoboard, and then (important!) to mark one end of the ISP connector as being the end that contains pin 1. When you eventually hook up the ISP connector cable to the header, you will need to make sure that you have the correct orientation.



The next step is to determine how to hook up the pins of the ISP header to the pins of the socket. Atmel Application Note 42 describes the pinouts of the 6-pin and 10-pin ISP interface connectors. From above, they look like this:


The pins on the 6-pin interface are power (+Vcc) and ground, and the four "signals" of the ISP connector, which are called RESET, SCK, MISO and MOSI. You will notice that the 10-pin interface is just padded by a lot of fat-- it doesn't provide additional functionality.

(Note: The nature of the power (Vcc) line is context sensitive, and you will need to think about which way your power goes through that connector. If you are using the AVRISP mkII or most other programmers, the Vcc is expected to be provided from the target board to the programmer. This is used to indicate to the programmer that the target is "live" and ready to be programmed. If this is the case, you must provide a separate power source for the target board. If you use the USBtinyISP, you have the option to use the Vcc pin on the ISP interface to provide power to the target board. That option should be disabled if your target board does supply power to the Vcc pin of the ISP interface.)


Next, we need to identify the pins of the AVR that attach to those of the ISP connector. You can begin by looking at the datasheet for your particular flavor of AVR ( list here) and finding the six pins that match up to the names of the pins on the ISP connector. Here, I've highlighted the relevant pins of three AVR devices that I happen to like and come in 8-pin (ATtiny45), 20-pin (ATtiny2313) and 28-pin (ATmega168) DIP packages:

Many but not allof the AVR devices in a given package (e.g., DIP-8) share the same ISP connector pinouts, so these target boards can sometimes (with caution) even be used for different AVR microcontrollers. For example, the ATmega8, ATmega48, ATmega88, and ATmega168 share the same 28-pin pinouts. Note that in the figure above there are more than six connections to the ATmega168. That's because there are extra power and ground lines running to the analog circuitry of the chip, which should be wired up even when the analog section is not in use.


wired


Now that we know where the various ISP pins of the header and the chip are, we can wire things up. We need six wires (obviously)-- hook MISO to MISO, MOSI to MOSI, and so on, and solder up the lines. Remember to index the header from the end that you marked earlier, the end with pin 1.

That's actually all there is to it-- the rest is just icing.


Back side


Here's what the back side looks like; not much to look at!


Completed board


You can optionally add a power supply to power the board, which may be not-so-optional if you are using a programmer that requires power from the board. Since the chip uses so little power on its own, a battery box is a good idea and can last a very long time.


Using board


To use the target board, put the AVR in the socket and hook up the programmer to the ISP connector. Pay attention to the orientation. The end with Pin 1 is often marked with a stripe on the cable and/or a little triangle on the connector.


Target w/battery box


tiny target board w/ socket


Tiny target board


You can build a simpler, smaller, and much cheaper version of this target board by omitting the ZIF socket. It's more difficult to use if you take the chip out *a lot* but otherwise it's a good solution. And of course, if you are using a programmer that supplies power to the target microcontroller, you can even omit the battery box. Cost under $2 and assembly time under 5 minutes. Nice.


So where do you go from here? First, get that programmer if you haven't already got one. Then install the GNU toolchain that's appropriate for your system (e.g., winavr for Windows or OSX-AVR on the Mac), and then download some sample code and go to town-- there's no shortage of cool AVR projects out there, and we hope that that these hints will give a push in the right direction.




MetaBlog links for this story: [ del.icio.us | technorati ]

Technorati tags: , , , , , , , ,

6 comments

The following comments are owned by whomever posted them. This site is not responsible for what they say.
Authored by: Anonymous on Wednesday, November 28 2007 @ 02:06 AM PST Using AVR microcontrollers: Minimalist target boards
> The killer feature versus the AVRISP mkII is that it lets you use the USB power to directly power your target board.

Hmm, how? I'd be happy to open my AVRISP and bring the right leads over, should be no big deal, I just want to not fry everything in my tiny little setup in the process. :)
Authored by: Windell on Wednesday, November 28 2007 @ 02:18 AM PST Using AVR microcontrollers: Minimalist target boards
That's been done too, and you are certainly welcome to do so. I once found someone's page where they showed how they put a voltage regulator inside and everything-- but I neglected to bookmark it and haven't been able to find it since. Too bad, I wanted to link to it. =(

---
Windell H. Oskay
drwho(at)evilmadscientist.com
http://www.evilmadscientist.com/
Authored by: Anonymous on Wednesday, January 02 2008 @ 04:45 PM PST Using AVR microcontrollers: Minimalist target boards
Authored by: Windell on Wednesday, January 02 2008 @ 04:48 PM PST Using AVR microcontrollers: Minimalist target boards
Thank you! Thank you!

---
Windell H. Oskay
drwho(at)evilmadscientist.com
http://www.evilmadscientist.com/
Authored by: Anonymous on Sunday, January 06 2008 @ 06:35 PM PST Using AVR microcontrollers: Minimalist target boards
That's awesome except I can't quite exactly tell the details there. If all I want is to pass the 5v usb right on through, does someone have a simplified version available? I am looking at the board of my (exact same) programmer right now, is the goal to just get 5v on the vcc pin of the 6-pin cable? Can't be, that pin I assumed was to "sense" whether the chip was powered, not to power it, right?
Authored by: Windell on Sunday, January 06 2008 @ 06:42 PM PST Using AVR microcontrollers: Minimalist target boards
You just want to pull the 5 V off the USB, and deliver that through the ISP connector to your chip, right? So just do that-- use your multimeter and figure out which pin is +5 V and wire it up. You'll have to cut whatever line *was* connected to that pin of the ISP connector.

---
Windell H. Oskay
drwho(at)evilmadscientist.com
http://www.evilmadscientist.com/

Welcome to Evil Mad Scientist Laboratories. New projects are posted every Wednesday.


Bookmark EMSL

EMSL RSS Feed
Twitter: EMSL
del.icio.us
feedburner
Feed on Google Reader
Add technorati Fave

technorati search

Subscribe to get new articles by E-mail:

E-mail address:


Preview | Powered by FeedBlitz

My Account





Sign up as a New User
Lost your password?

Who's Online

Guest Users: 21

Forumposts

Order: New Views Posts
Latest 5 Forum Posts
 
Re: remote LED's?
 By:  MonsieurBon
 On:  Thursday, July 02 2009 @ 02:55 PM PDT
 Views 0 Replies 0
Re: remote LED's?
 By:  Windell
 On:  Thursday, July 02 2009 @ 11:38 AM PDT
 Views 0 Replies 0
Re: remote LED's?
 By:  dave
 On:  Thursday, July 02 2009 @ 11:35 AM PDT
 Views 0 Replies 0
Thanks for a great p..
 By:  Varne
 On:  Thursday, July 02 2009 @ 10:21 AM PDT
 Views 11 Replies 0
Re: what is the limi..
 By:  Windell
 On:  Thursday, July 02 2009 @ 10:04 AM PDT
 Views 0 Replies 0

DIY Hardware for Electronic Art


Interactive LED Panels


Meggy Jr RGB
LED matrix game
development kit.


Business-card sized
AVR target boards


Peggy & Peggy 2
LED Pegboard kits