Attiny45 based USBtinyISP Programmer

For a long time, I was looking for a solution to the size of my stk500.  Its big, fragile, and requires external power and a large USB to serial cable.  It seemed like the solution was one of these, a tiny (haha) programmer based around an attiny45/48.

Since I had the parts left over from The Secret Knowledge (more on this later) that would let me implement v-usb, and some attiny45 in my room, I decided to give it a shot.  Along the way there were a few roadblocks:

1. I didn’t read the instructions carefully enough, so I didn’t set the fuses properly the first time around.

2. Mysteriously, I couldn’t program the target chip if some of the outputs were set to high at the time of programming.  I resolved this with a .1uF capacitor across power and ground.

The rest of this post will be documentation on how to build the programmer, which hopefully will improve upon the instructions in the instructable.

Materials used (sources of parts at end of post):

  1. USB cable.  Any one will do, so long as it plugs into your computer on one end.  This is normally a USB A cable.
  2. Breadboard.  I made some PCBs for this but a breadboard is more accessible, and if they work I will post the files up on this blog.
  3. two 68 ohm resistors
  4. one 1.7K ohm resistor
  5. two 3.6 volt Zener diodes
  6. one .1uF capacitor
  7. one pre-programmed attiny45 in a DIP package OR an attiny45 and a way to program it
  8. .1″ pitch male header pins

The first thing you want to do is cut the USB cable in half, and extract the four wires that are inside.  There should be a red, black green, and white wire inside.  Red is 5 volts, black is ground, green is data+ (D+) and white is data- (D-).  strip the ends of these wires and solder them to the header pins, like in the picture below:

5 Volts and Ground are soldered to one pair of pins, while D+ and D- are soldered to another pair

The next step is to program the Attiny45/85.  I would just grab the .hex file from here, and flash it onto the attiny with whatever programmer you have.  If you are using AVR studio, just open a random project, connect to your programmer, and choose vusbtiny.hex as the file to burn to the chip.  Then, when you are SURE the correct program is written, set the fuses (click the fuses tab on the programming menu) and set the lower fuse to 0xe1 the higher fuse to 0x5d and the extended fuse to 0xff.  you can do this by directly editing the fuses in the menu by just clicking on the numbers the fuses are set to, and changing them.

If you are using avr dude, you want to use the command “sudo avrdude -c *your programmer here* -p t45 -U flash:w:usbtiny.hex” and when you are SURE it is written, you can burn the fuses with “avrdude -c usbtiny -p t45 -V -U lfuse:w:0xe1:m -U hfuse:w:0x5d:m -U efuse:w:0xff:m” (These commands are from the instructable)

You may notice that I emphasize making sure the program is correctly written BEFORE burning the fuses.  This is because you are going to burn the fuse that turns PB5 into an I/O pin instead of RST.  This makes it so that you have to use “high-voltage” (12V) programming to clear the fuses, and some programmers can’t do that.  If you burn the fuse before the program is correctly loaded, you cannot program it with ISP which which the majority of programmers use.  This is because ISP requires the RST pin.

Once you have all of that done, go ahead and build the circuit.  I have drawn up an improved circuit diagram (the one on instructables is awful) that includes a decoupling cap between power and ground.  This is really important because without it I tended to have problems programming chips when the target chips pins were high.  The hypothesis is that there was some sort of voltage surge, and the USB controller in my computer was turning off the device.

An improve schematic without over 9000 overlapping wires. Note the decoupling capacitor, and the orientation of the diodes. The band on the diodes is the same as the bar/z-shape on the schematic.

Once you are done, it should look something like this:

This is how my breadboard looked when I was done. Note the diodes and the orientation of the chip. Specifically pin one is on the upper right hand corner.

Then, take the whole thing and plug the USB A end into your computer.  You should hear a “Dun-Dah!” noise (in windows, linux users can use “lsusb” from the command line), and your computer might search for a driver.  You can get the driver here from ladyada.  If just downloading the driver doesn’t work (windows), plug in the device, go to start>control panel>hardware and sound>device manager and look for a device called something like “tinyusbisp”, and right-click install drivers and then manually search for drivers.  If you are on windows, you will need WinAVR to use this programmer, or if you are on Linux, just “sudo apt-get install avrdude”.

Now this whole thing should work…The easiest way to test is is to try flashing some random .hex onto another Attiny device.  You will need avrdude (included in winavr) to do this.  The command will look something like this “sudo avrdude -c usbtiny -p t45 -e -V -U flash:w:yourfilename.hex”.

Part Sources:

Digikey part numbers for the resistors: 985-1023-1-ND (68 ohm), PPC1.69KYTR-ND (1.69k ohm), 568-5907-1-ND (zener diode), ATTINY45-20PU-ND (attiny45), P4525-ND (.1 uf capacitor).

You can get a breadboard of your choosing (in size), and a USB cable from amazon.

10 thoughts on “Attiny45 based USBtinyISP Programmer

  1. Twang says:

    Wow, that actually looks really nice: I’d prefer that over what sells at Adafruit.
    Well, I’ll leave that link up so that all the hobbyists can DIY.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s