Introduction: How to Make Your Own AVR Programming Station for Under 8 Bucks

About: I study Computer Science and generally tinker with stuff. Be it software or hardware. I have my software periods and my hardware periods.

Hello again!

The last year I have been practicing with AVR microcontrollers and Arduinos.

I first bought a *classic* Attiny85 and programmed it through my arduino Leonardo. It was awesome to see a bare chip do programmed things (in a fraction of arduino cost). After getting some knowledge on AVRs I made my first really useful Attiny85 usage (you can see in this instructable). At first I used Arduino IDE but later I started using the AVR toolchain.

***BASIC KNOWLEDGE: an AVR microcontroller chip can be fundamentally programmed in the following way: get a 6 pin interface (4 signals + 2 power) from the PC (typically using a USB device or an Arduino called ISP- details on next steps) and connect each pin to a certain IC leg (as the microcontroller datasheet implies). After that, a PC program is used to pass the actual binary (via the USB device or Arduino) to the IC. Finally, the IC legs specified in the code will act as arduino pins.***

I liked programming like that but it was not convenient for me to program the chip on the breadboard as I had to plug and unplug the jumpers on every upload. It could be done in a better way... It could be nice if I had a board to program every AVR microcontroller (with different pinouts) with minor changes, without plugging and unplugging... In other words: "a programming station"...

Step 1: Sure, But What Is an AVR Programmer?

An AVR programmer is the device that changes the USB signals to SPI signals. This can be anything though! There are dedicated ICs that do exactly this but you can even program a microcontroller to read the USB signals and translate them to SPI. Exactly the last one is what happens with the "Arduino as ISP" sketch and the USBasp programmer.

*** ISP stands for "In System Programmer" and it is completely different from SPI protocol that stands for "Serial Peripheral Interface". The only common is that ISPs use the SPI data transfer protocol. ***

You can make one using a dedicated IC or a microcontroller or an arduino (the easiest way - if you have one). You can also buy one. I bought USBasp from ebay for about 3 bucks. If you have an Arduino UNO, you can just load the ArduinoISP sketch and follow the instructions in the sketch. If you have an Arduino Leonardo (like me) see this Instructable.

The sure thing is that you have to get a programmer, as you are gonna need it for the Programming Station...

Step 2: IC Independence!

I won't spend my whole life programming Attiny85s! But it is almost sure that I will continue to use DIP packages for a long time.

There is big chance that I am going to need more IOs. Maybe 5 more. Maybe 25 more... This is why I tried to make my Station IC independent. For that I used a ZIF (Zero Insertion Force) socket of 40 pins.

40 pin is the maximum size of a DIP, and while the smaller ICs fit on a big ZIF socket, the reverse is not true. So I bought the biggest ZIF I found, to be sure that there won't be any ICs that I won't be able to program...

Also, every AVR microcontroller is programmed via SPI protocol. The problem is that not every IC has its SPI pins in the same position. So there should be a way to rearrange the connection for different ICs.

Step 3: HIgh Voltage Programming and Fuse Resetting

Fuses are fundamental for a microcontroller. They define many crucial things about it, that are needed for its performance.

Generally fuses are a set of bits that have their special location in the microcontroller. Usually 2 to 3 bytes. Every bit enables a different feature of the microcontroller. Some features are EEPROM erase lock (locks EEPROM so programming won't erase it), Reset pin usage (IO pin or Reset), Brown-out Detection (BOD), External Oscillator usage... More on fuses and what they are doing here...

But fuses are also dangerous! You can set them using your ISP, just like you upload your program, but there are cases that your ISP is incapable of resetting them. In some cases this bricks your microcontroller completely. A classic example is the following:

You need to use the Reset pin as an IO pin. You upload the code nicely using your ISP and then you enable the RSTDISBL fuse (the fuse that makes the Reset pin an IO port). Now the microcontroller has no external Reset. Suddenly you realize that there is a bug in your code, so you fix it, compile it and you try to reupload it in the microcontroller... This can no longer be done! This is because the ISP uses the external Reset to make the microcontroller understand that is is getting programmed. Now you have a bricked microcontroller...

However there is a solution to this. The solution is called High Voltage Programmer... This beast ramps up the microcontroller's Reset pin with 12Volts (instead of 5V) and shows who is the boss! Seriously, microcontrollers are programmed to understand that 12V on the Reset pin means "Programming" whatever the fuses are and this way, you can change back the RSTDISBL to normal (to continue using a classic ISP). You can find an Arduino sketch for resetting the fuses to default (along with a schematic) here.

My Programming Station implements an external power source (controlled by a transistor by the ISP Reset signal) to be used as 12V source. This way High Voltage Programming (and brick rescue) is possible...

Step 4: The Prototype!

Finally! In the photos you can see many useful things, so take a look...

There is no general schematic because this is not actually a circuit but a bunch components soldered in perfboard.

The basic thing is that near every component there are some female headers breaking it out. The whole ZIF is broken out, the ISP connector is broken out to 2 headers per signal. There is also a resonator (Crystal-Capacitor system) slot with 2 broken out pins that go directly to the IC's XTAL pins (to use the external oscillator). The LEDs are used for the Arduino ISP sketch, which defines 3 LED signals: the Heartbeat (a pulsating LED that shows that the arduino hasn't crashed) - for that I use the Green LED, the Programming (this lights up when there is communication with the IC) - for that I use the Blue one, and the Error (lights up when an error occurs) - for that I use the bigger Red one.

When I want to program an IC, I mount it on the ZIF socket, I find the MISO, MOSI, SCK, RST, VCC, GND pins by the datasheet or google images (this is much much easier than it seems), **something optional here described below**, I connect jumpers from those pins to the ISP connector breakout, connect the ISP cable to the Programming Station and the PC, and I use avrdude or Arduino IDE to do my job nicely!

**If I want to use an external oscillator I locate the XTAL1 and XTAL2 pins, I connect the Resonator (only 3-leg resonators are supported - they are pretty common and cheap) to the special resonator slot and I connect with jumpers the broken out resonator pins to the IC's XTAL pins.


Thank you for reading my third Instructable!