after making a usbtiny isp programmer and using it for 6 months, i was looking at making another one for carrying around. i like the simplicy of the usbtiny isp design but would like to make it even smaller and take less parts. one thing in the original design that i want to change is to eliminate the use of clock crystal. one solution i found is that v-usb drivers supports the 16.5Mhz internal oscillator on attiny25/45/85 devices. so i start out this project to have usbtiny isp employs v-usb for usb communication. the immediate benefits is that it saves space and have less component counts (no more crystals).


description from http://www.xs4all.nl/~dicks/avr/usbtiny/

USBtiny is a software implementation of the USB low-speed protocol for the Atmel ATtiny microcontrollers. Of course, it will also work on the ATmega series. The software is written for an AVR clocked at 12 MHz. At this frequency, each bit on the USB bus takes 8 clock cycles, and with a lot of trickery, it is possible to decode and encode the USB waveforms by software. The USB driver needs approximately 1250 to 1350 bytes of flash space (excluding the optional identification strings), depending on the configuration and compiler version, and 46 bytes RAM (excluding stack space). The C interface consists of 3 to 5 functions, depending on the configuration.


description from http://www.obdev.at/products/vusb/

V-USB is a software-only implementation of a low-speed USB device for Atmel's AVR microcontrollers, making it possible to build USB hardware with almost any AVR microcontroller, not requiring any additional chip.

video on construction and usage

Step 1: Features and Parts

* programming logic from usbtiny isp, mature avr-dude support
* small foot-print
* minimal components
* powers target device

note that the io lines to the target mcus are not protected. you can add 1k-2k resistors to SCK and MOSI and protect against possible wrong connections


based on the works found at

v-usb from framework http://www.obdev.at/vusb/
usbtiny isp http://www.xs4all.nl/~dicks/avr/usbtiny/

parts list

* attiny45/85 (85 is more easier to come by)
* 3.6v zener diodes (1n747,BZX79,..avoid 1W types)
* 68ohm resistor x 2
* 1.5K resistor
* mini breadboard 170 tiepoints
* usb cable (dollar shop usb printer cable is fine)
* 1k/2k resistors for io lines protection (optional)

tools required

* a working avr programmer (yes, it's a catch22, we need one to make one)
* working avr programming environment

Step 2: Breadboard Layout, Schematic, and Construction


* follow breadboard layout, there ain't that may components, 3 resistors, 2 diodes, 1 cap, plus an 8 pin mcu.
* get a dollar shop usb printer cable cut off the printer end, there will be 4 exposed wire, secure and make them into a 4 pin male header, we will use it to connect to the breadboard. consult schematic for layout and pin assignment (J1).
* watch out for diode polarity.

building and flashing the project

the project was built in a linux ubuntu lucid box with avr-gcc toolchain. it is assumed you already have such an environment, or you can find out from the internet how to setup one up. source codes are gnu gpl v2 licensed from inheritence.

the source code follows a convention recommended by v-usb, you can download the source package vusbtiny.tgz and untarred in into a project directory. within your source directory, there is a main.c, which is my version of modified usbtiny programmer. and a usbdrv sub-directory, which contains the v-usb layer. please observe licensing term from the above two projects when building this. my source on the programmer logic is based on Dick Streefland version and not the ladyada version (although they are almost the same).

for those who do not have a build too-chain, you can use the following binary

click to download vusbtiny.hex

and use avrdude to flash firmware

avrdude -c usbtiny -p t45 -e -V -U flash:w:usbtiny.hex

(if your device is a tiny85, replace -p t45 w/ -p t85)

source can be download here
click to download vusbtiny.tgz

untar the source package into your working directory

tar -zxvf vusbtiny.tgz

* do cd vsubtiny, to change into vusbtiny working directory
* ajust makefile for target device according to the chip you will be using. i.e. PROGRAMMER_MCU=t45 or t85
* do a make
* attach your favorite ISP programmer
* modify makefile and change your avrdude parameters if needed. the stock one assumes USBTiny programmer. i.e. AVRDUDE_PROGRAMMERID=usbtiny
* flash firmware via make install

after flashing firmware, we need to properly set the fuse, we are using pin 1 reset as io in this project

* ppl clock used as required by v-usb layer for usb timing
* reset pin disabled as we need to use it as io

avrdude -c usbtiny -p t45 -V -U lfuse:w:0xe1:m -U hfuse:w:0x5d:m -U efuse:w:0xff:m

this setting disables further programming via 5V SPI as we need the RESET pin (pin1) for io. you will need access to a HVSP programmer to recover the fuse.

Step 3: Usage and Application

direct flashing on breadboard

if you are using vusbtiny to flash 8 pin AVR devices, you can just press your target device on top of the programmer device. the programmer had been designed so that the programming pins matches w/ targets. there is one trick though, you will need to isolate pin 2 and 3 on the programmer mcu, as they are the USB D+ and D- pins connecting to the PC. i use a cut of scotch tape to achieve this, you can see it on the photos. show below is a tiny13v "riding" on the tiny45, ready to receive firmware.

ISP flashing via jumper

to program a target circuit via ISP (in-system programming), you need an ISP cable. here i am not using the standard 2x3 or 2x5 pin headers. instead i am using a 1x6 jumper which is more breadboard friendly, you can make 2x3 or 2x5 pin header by mapping them to J2 as shown on the breadboard layout and schematics. the following photo shows an tiny2313 ready to get flashed via ISP.


* cannot flash the firmware? check your original programmer, might need to adjust timing via -B flag in avrdude. try to read chip 1st, may be a bad fuse, may be your chip need an external clock signal. you may need to fix your chip back to default 1st.
* check connections
* if use different io pins, check code and connections
* you may substitute zener diodes w/ 500mw, 400mw types
* you may try reduce R3 value to 1.2K or less
* you are more likely to encounter avrdude timing problems, try -B flag of avrdude, have a shorter USB cable all helps

<p>this worked avrdude -v -pt85 -cstk500v1 -b19200 -U flash:w:vusbtiny.hex</p><p>set com port of programer to 1</p>
<p>does it need drivers because i says that windoes does not recognise the usb device</p>
<p>Hi guys correct way to upload that using arduino: <br>HEX: avrdude -P com3 -b 19200 -c avrisp -p attiny85 -v -e -U flash:w:usbtiny.hex<br>FUSE: </p><p>avrdude -P com3 -b 19200 -c avrisp -p attiny85 -v -e -U lfuse:w:0xff:m -U hfuse:w:0xdf:m</p>
<p>Thanks for the project, man! Everything went fine up until flashing the firmware you supplied onto the attiny (I'm using an Attiny45-20SU). After that and after setting the fuses the programmer is not recognised by the computer (either Windows or Linux). I will build another one (identical). I have an Arduino board to use as ISP, do I need to set specific options before flashing the driver? Maybe that's the reason why I can't see the new programmer?</p>
<p>Nice, thank you, the funny piggy back method worked too, but is a little bit unstable :-). The t45 is programmed using the red Sparkfun tiny Programmer, also I used a STK500 (a little bit bigger - avr studio) high voltage programming to reprogram a lost t85...and all this because my beloved avr mkii programmer died after years of service without complaining- i am guilty for that - applying a servo voltage of 7V to it....</p>
<p>Hello all,</p><p>Just finished assembling a USBtinyISP. As always I have double check my soldering and component placement. However when I connect the USB plug to my computer </p><p>I get a Power surge window. Reads as follows</p><p>Power Surge on Hub USB Port. device has exceeded the power limits. </p><p>This a large computer I am sure the little programmer does not exceed the limits.</p><p>Any hints ? Seen this before?</p>
<p>works great every time!</p>
<p>Hello Badetise,</p><p>Can you explain how could you make it work through the &quot;avrdude: Error: Could not find USBtiny device (0x1781/0xc9f)&quot;?</p>
<p>Same problem here :(</p>
<p>finally, i made it,<br>you have to set the fuses of the microcontroller(it works like flashing a program):</p><p>remove the div by 8 on the clock</p><p>set brown-out detection</p><p>disable external reset, so you can use pin1 as i/o</p><p><a href="http://www.engbedded.com/fusecalc/" rel="nofollow">http://www.engbedded.com/fusecalc/</a>, here you can calculate it for a bunch of mc-s, but i tell you the cmd command that did it for me (found it on a forum, but don't remember where):</p><p>i used an arduino as an isp -&gt; -c avrisp, but change it according to your choice of progammer</p><p>avrdude -c avrisp -p t48 -v -U lfuse:w:0xe1:m -U hfuse:w:0x5d:m -U efuse:w:0xff:m</p><p>these settings(except the reset disable) helped me for other projects with atmega48 - i do not need reset disable with this chip because it has more pins, but in case of the tiny it is neccessary.</p><p>Have you succeded?</p>
<p>Trying to run this command:</p><p>avrdude -c avrisp -p t85 -P COM3 -v -U lfuse:w:0x62:m -U hfuse:w:0x5f:m -U efuse:w:0xff:m -U flash:w:vusbtiny.hex</p><p>results in avrdude: ser_open(): can't open device &quot;\\.\COM3&quot;: Access is denied. My Uno is definitely on COM3 and my PC sometimes hangs when I try to use this command. Same thing happens if I try to use the arduino flag rather than the avrisp one.</p><p>Any ideas? Thanks</p>
<p>do you use linux?</p>
<p>Using Windows at the moment but I can boot into Linux on my laptop if that'll help.</p>
<p>Theeen, i think you use your programmer with something else on the computer, try restart the computer</p><p>i have never got this access denied message...</p>
<p>Ah OK thanks. I was at least on the right lines by changing the usbtiny part. I'll give it a go in the morning and get see how it goes, thanks. I'm trying to program it using an Arduino Uno as the ISP and an ATTiny85.</p>
<p>I built this but it doesnt work.I got the same error as Badetise.</p><p>I used 100 ohms instead of 68.They are the probem?</p><p>As pull-up i used a 1,8kohm resistor.Also i added a led with a 1,8kohm resistor between Vcc and CND.I also used a 47microfarad electrolitic cap.If anybody can help?</p><p>Thanks.</p>
<p>now my pc makes its bing sound and tells me it doesn't recognize it.</p>
<p>Hi, I just built this, but when I try to flash a program, it says &quot;avrdude: Error: Could not find USBtiny device (0x1781/0xc9f)&quot;. I have double and quintuple checked all of my connections, I am completely stumped. Any help would be greatly appreciated, Thank you!</p>
<p>For more clear about how to load a hex file in microcontroller you can browse this video.<br>https://www.youtube.com/watch?v=4rHWzO7tqQc</p>
<p>Hello, </p><p>I realized the programmer with an attiny45 and it's work very well. </p><p>But now i want to try with a tiny85 and I can not compile the source. </p><p>i recieve this errors and many others:</p><p>usbdrv/usbdrv.h:455:6: error: variable &lsquo;usbDescriptorDevice&rsquo; must be const in order to be put into read-only section by means of &lsquo;__attribute__((progmem))&rsquo;<br> char usbDescriptorDevice[];</p><p>Do you have the same results or i don't have the goods ressources?</p>
This is really a great little project! I built it on a little stripe of of prototype board and arranged it in such a way that one end of the prototype stripe also serves as a usb plug.<br><br>Every thing worked perfectly on the first try - so big congratulations for presenting such a useful project and making things so simple and the instructions so precise!<br><br>Thanks!!!
<p>that is awesome what you did turning the breadboard into a usb stick</p>
<p>Great Tutorial, I've setup 2 of these on breadboard already, one t45 and one t85. This circuit is just too easy to replicate! I did initially have issues with requiring the use of 'sudo' with avrdude, but this simple rule for udev fixed that.</p><p>SUBSYSTEM==&quot;usb&quot;, ATTR{idProduct}==&quot;0c9f&quot;,ATTRS{idVendor}==&quot;1781&quot;, MODE=&quot;0660&quot;, GROUP=&quot;adm&quot;</p>
<p>Built one of these and it works great! Do you know if there are any limitations? For example, Adafruit's USBtinyISP kit can't program any AVRs that have over 64k of flash like the Atmega1281/1280/2561/2560. I don't have any of those AVRs on hand to test.</p><p>Also, I built one and it takes about 2 minutes to burn the Arduino bootloader to an ATmega328. Do you know what could be done to speed that process up, at all? </p>
<p>Wish there was a way of doing this without needing an avr programmer... Ah well, Teach me for looking for the easy way out</p>
<p>Just a thourght, do you know if its possible to get the ATtiny45/85 preprogrammed with vusbtiny?</p>
<p>Not from me. I have not do an AVR for more than one year. On MSP430 now. If you have friends that got a programmer, you can download the hex and have him flash one for you. Or try local avr forums. It might be wiser to get a programmer from ebay. They are about $3 shipped nowadays.</p>
When I plug it in the USB i get in dmesg:<br> <br> [257309.496223] usb 4-1.1: new full-speed USB device number 50 using ehci-pci<br> [257309.562747] usb 4-1.1: device descriptor read/64, error -32<br> [257309.732580] usb 4-1.1: device descriptor read/64, error -32<br> [257309.902371] usb 4-1.1: new full-speed USB device number 51 using ehci-pci<br> [257309.968926] usb 4-1.1: device descriptor read/64, error -32<br> [257310.138778] usb 4-1.1: device descriptor read/64, error -32<br> [257310.308634] usb 4-1.1: new full-speed USB device number 52 using ehci-pci<br> [257310.714804] usb 4-1.1: device not accepting address 52, error -32<br> [257313.126003] hub 4-1:1.0: connect-debounce failed, port 1 disabled<br> <br> Any help appreciated...
simple probably vacuous question, what is SPI and why would I want to program it? Post a link if it's a fairly good explanation. Thanks in advance
There are a few ways to program an avr, SPI (serial peripheral interface) is the simplist way as it only require three signals, Clock, MOSI and MISO (master-in, slave-out and vice versa). SPI is easier to implement (most uses bit-bang style) and require fewer HW resources. See linked docutment from amtel for details. <br>http://www.atmel.ca/Images/doc0943.pdf
Need help on swapping PB3 and PB4. <br>Modified usbconfig.h as below and flash the attiny85. <br>#define USB_CFG_DMINUS_BIT 3 <br>#define USB_CFG_DPLUS_BIT 4 <br>I monitor reset line. <br>It stay high for a few seconds and then started pulsing. <br> <br>I think I have to modified MCUR setting but do not know how. <br>Can you please help? <br>Thanks. <br>
I use <a href="http://mightyohm.com/blog/2010/03/run-avrdude-without-root-privs-in-ubuntu/" rel="nofollow">this</a> udev rule for my actual USBTiny but even though the id is the same it makes me use sudo for the vusbtiny. Any ideas?<br> <br>
Could you clarify where the &quot;1k/2k resistors for io lines protection (optional)&quot; go?<br> <br> Also, what benefit does the&nbsp; &quot;optional 0.1uf capacitor&quot; bring, and where does it fit in the circuit diagram? I'm feeling really fuzzy today and I'm having trouble working backwards from the photo of the breadboard.
io line resistors protects the device when u accidentally connect high-voltage input and output pins. most builds don't use them to make the project footprint smaller. <br>the 0.1uF capacitor is just a bypass cap to stablise power supply (like any other projects). if u have one, put it it. <br>there are many successful builds of this project. google vusbtiny and u can find other's experience / modification to make it work.
I haven't tried but I can imagine it might work nicely to solder SMD resistors between two adjacent perfboard holes for compact I/O line resistors (using a heat gun to keep both melted at once) similar to what spless did with all of his resistors in the photo he posted.<br><br>As for the I/O line resistors, I got that but I'm not sure where they're supposed to go in the circuit diagram. (That's also my second question about the bypass cap since, lately, I've been jet-lagged and my free time coincides with the time I'm too dozy to make sense of how the breadboard photo maps to the circuit diagram.)
Thank you for this guide, I succeeded in programming both an AtTiny45 and an Atmega328. <br>Note that in this last case I had to wire pin4 of J2 to the Atmega328's SCK (that is pin 19), not to the SCL (that was pin 28). <br>And I was on Windows7 64bit, if anyone cares.
Great tutorial. I am porting this to a protoboard.<br><br>Can the 68Ohm resistors be replaced with any other values (47Ohm, 100Ohm...) and the 150K one be replaced by another value say 1K or 2.2K ?<br>Would avoid burning fossil-fuel to get only those 2 from the store. Rest, I have pretty-much everything.<br><br>Also for your USB printer cable hack, can you explain the header connections ? You only seem to have Vcc and D+ connected to the header, and GND, D- isn't clear from the pic, if they are on their own headers or just plain terminated (left floating).
here are my understanding...<br>. the 68ohms are current limited (to protect the pins), so u should make them as close to 68 as u can. 47ohm definitely works. sometimes even better than 68ohms if u have a long usb cable.<br>. the 1.5k is a pullup, so anything between 1k to 5k is fine.<br>. follow the schematic / diagram, there are only 6/7 parts in this, the schematic also make notes of the 4pin header position. if u are talking about the usb cable itself, they can be different colored wires inside, u sould use a multi-meter to sort out which is which. i.e. measure between the contacts on one end against the 4 exposed wires against a usb pin-out diagram.<br><br>good luck on your build.<br><br>
Did anybody test it under Win7? I got an error saying that the installation could not be done!?
As far as I can tell, reading various posts at the Objective-Development site (&amp; forums), very few people seem to have had success in using V-USB under Windows 7. Apparently, some initial / early Win 7 (that too, possibly only on 32-bit mode), installation did work, but people do seem to have issues.<br><br>Here's one such thread: http://forums.obdev.at/search.php?fid[]=8&amp;sid=ffe64be8b944f53757abea58c378899a
It is sufficient if i just flash the given HEX file using SinaProg???
never used sinaprog before. if it can accept hex file and works for u in flashing avrs, yes, u can use it as my hex files are no different. u do need to toggle the fuse bit on your target device and u should find out how it's done w/ sinaprog.
The usbconfig.h says: <br>&quot;Please note that D+ must also be connected to interrupt pin INT0!&quot;<br><br>Can you tell me what you have done to avoid that?<br><br>Thanks for sharing!<br>
thanks for your interest.<br><br>the default D+ pin is INT0, but it can be changed, for attiny45/85 layout, i used portb.3, we can re-define USB_INTR_VECTOR to be the &quot;pin change&quot; interrupt. and any one of the 6 io pin level change will trigger the interrupt, which includes portb.3.<br><br>note that if u are also using some other higher priority interrupts this may fail.<br><br>inside usbconfig.h, toward the end of the file, u can see the various options.<br><br>#define USB_INTR_VECTOR SIG_PIN_CHANGE<br><br>//#define USB_INTR_VECTOR INT0_vect<br>//#define USB_INTR_VECTOR PCINT9_vect
hey im trying to build a smd version of your tiny avr programmer (will post pictures as soon as i get it finished) and im waiting for the board to arrive anyway my question the programmer uses the 8mhz internal oscillator ? <br>so i can order this part ATtiny85V-10SU or this ATTINY85-20SH :) ?
@putyn <br><br>use the 20mhz version (attiny85-20??), we need to use a internal oscillator clocked at 16.5Mhz to avoid external crystals.<br><br>for more technical details if u need, go to the vusb site for explanations.<br><br>good luck w/ your project.
ok thanks for your answer will order this ATTINY85-20SH - can you take a look at my schematic and design if i post them ?
not sure, i think this is the most simple programmer already? are u changing anything? If not, build it and if u ran into problem. Post a comment here I am sure either myself or someone can help.<br><br>
Thank you for this guide, I made my tiny programmer with the help of this :)<br> I made mine to a piece of stripboard, and used an Arduino to program the chip.<br> I'll link my materials here, so people can see how it would fit to a stripboard.<br> The board could be made smaller if I used more wires instead of jumpers, but It's small enough for me like this :)<br> <br> I don't take any responsibility for wrong schematics though, these are <strong>made from memory and might not be correct</strong>:<br> <br> http://koti.mbnet.fi/johnedwa/misc/vUSBtiny_stripboard_v1.PNG<br> http://koti.mbnet.fi/johnedwa/misc/vUSBtiny_stripboard_v1_schematics.PNG<br>
That ATtiny is bigger, my ATtiny45V is smaller than that one in the clip. <br>Or am i wrong?

About This Instructable




More by simpleavr:Tix Clock Gems Vintage TI DataMath / Sinclair Scientific Calculator Emulator AVR HVSP Fuse Resetter 
Add instructable to: