[TUT] [HARD] [SOFT] [C] USB tutorial with V-USB & ATtiny

19 posts / 0 new
Last post
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi all!

I recently managed to implement an USB powered device using ATtiny2313 and V-USB library. As a beginner, I needed several evenings of research prior to the project so I decided to compile a tutorial covering the steps for building a simple USB device:

http://codeandlife.com/2012/01/22/avr-attiny-usb-tutorial-part-1/

This first part covers the basics of getting USB connector to breadboard and using it to power a simple LED circuit. It can be extended to any USB-powered project.

http://codeandlife.com/2012/01/25/avr-attiny-usb-tutorial-part-2/

The second part goes through rest of the test breadboard setup, including wiring the ATtiny2313 to the USB with proper pullups for a low-speed device on D+ and D-, as well as enabling the 12 MHz crystal.

http://codeandlife.com/2012/01/29/avr-attiny-usb-tutorial-part-3/

The third part is the longest of the three and contains both device side and host side code, as well as a chapter on creating Windows drivers for V-USB devices using libusb-win32's INF-wizard.

http://codeandlife.com/2012/02/04/avr-attiny-usb-tutorial-part-4/

Fourth part details how to send data from and to your device. It also wraps up the tutorial series and contains the source code and schematic as well as needed libraries and drivers for Windows in one neat package.

I'm using quite a lot of pictures so I put the tutorial to my blog, but would appreciate any comments, feedback and discussion here. The spark for my electronics hobby started here in AVRfreaks tutorial section, so I felt it was time to contribute something.

Update: Two new parts have been added, first for making a HID mouse, and second which goes through adapting the tutorial for use with zener diodes to run the AVR at 5 volts, as well as switching to ATtiny85 (45 and 25 probably work just as well) and using internal oscillator instead of external crystal!

http://codeandlife.com/2012/02/11/v-usb-tutorial-continued-hid-mouse/
http://codeandlife.com/2012/02/22/v-usb-with-attiny45-attiny85-without-a-crystal/

Update2: Due to some requests, I've continued the tutorial with treatment of HID keyboards, too:

http://codeandlife.com/2012/06/18/usb-hid-keyboard-with-v-usb/

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Second part is now also up. I felt that the breadboard connections, reprogramming the fuse bits for 12 MHz crystal & testing was suitably long already so I'll cover the V-USB in part 3. Stay tuned!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Seems to be quite some nice tutorials there, will surely check back for part 3! :)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm glad someone is doing V-USB tutorial. I was too lazy to figure it out by my self.

Waiting for the critical 3rd part : )

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Part 3 is now finally up, thanks for all the comments so far. This is the longest and most detailed part, I may yet do some housekeeping work on the article, add one zip file for all the source code and insert proper copyright and license notices in the beginning of the files.

There will be part 4 with some additional techniques shortly, at least sending and receiving short buffers of data will be covered then.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Will go through it when I hit the bed tonight on my TV-pc, will be fun to read it. Good job jokkebk!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Fourth and so far final part is now released. It will explain transferring data from a to device in more detail, and I zipped everything up in one package so you don't have to cut-and-paste so much if you don't want to.

Planning to do a simple 7 segment multiplexing tutorial and a brief bit on driving LCDs directly with MCU when I get some free time. :)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Wow, I made it to Hack a Day with the tutorial!

To celebrate this, I made a new post outlining how to turn the tutorial project into a HID mouse. The current implementation just randomly moves the cursor, but with a few buttons a simple directional pad or joystick would be really easy to implement.

http://codeandlife.com/2012/02/11/v-usb-tutorial-continued-hid-mouse/

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I've received several questions regarding USB HID keyboards, and decided to continue the tutorial with a new post on that subject.

This should enable all kinds of data logger and interaction projects, especially since the type of keyboard I cover can also receive caps/scroll/num lock state changes from PC and react to them. :)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Awesome effort..!! However I had a question. Can this method be employed for making a USB programmer for Atmega 8,16,32,64 or 128?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
Can this method be employed for making a USB programmer for Atmega 8,16,32,64 or 128?

Yes: http://dicks.home.xs4all.nl/avr/usbtiny/

Pages