Learning to use the V-USB (AVR USB firmware) library

The V-USB library is a pretty handy piece of code that lets you add USB connectivity to ATtiny microcontrollers (it was previously named tinyUSB). But if you’ve ever looked into adding the library to your own projects you may have been stymied by the complexity of the code. There are many examples, but there’s a lack of a concise quick-start for the uninitiated. [Joonas Pihlajamaa] has been working to correct that shortfall with his four-part V-USB tutorial series. It’s not for the absolute newbie; you should already be comfortable working with AVR chips but that’s the only real prerequisite we can see.

He starts the series with a look into the hardware considerations. USB provides a 5V power rail but the data lines expect 3.3V logic so this must be accounted for. With the test rig built on a breadboard he moves on to pick apart the code, covering various user-defined variables that you’ll need to set based on your project’s needs. We’re going to keep this on the back burner and hopefully the Troll Sniffing Rat will get a makeover (although we must say comments have been a lot nicer as of late… keep it up!).

We’ve embedded links to all four tutorial parts after the break.

Comments

  1. Stan says:

    V-USB is very intuitive to use, highly recommeded. There is bit of learning curve, once passed possibilities are endless.

    I did an example project a while back that includes SHT-11 sensor, if anyone interested, it’s available:

    https://github.com/baracudaz/usb-sht

  2. YS says:

    That’s really great! I have already tried to start with V-USB, but it really looked too complicated for kick-start without proper tutorial. Now I hope things will get a lot better and I will finally be able to start using USB in my projects.

    Thank you!

  3. Steve-O-Rama says:

    Perfect timing, yet again. :) I’ve been having an interesting time getting an ATmega32U4’s USB to work as I want it, and this looks like a great help to better understanding how it works, particularly the fourth part of the tutorial. Thanks, HaD!

    And look, no tArduino stuff! :D WOOHOO!!!!

  4. macegr says:

    Nice tutorial…have loved V-USB since back when it was AVR-USB and I used it in the Capslocker project. Just this week I set up V-USB on an ATtiny45 as a custom class device, to act as an I2C gateway to a ChronoDot (trying to re-create the Maxim DS3231 live demo). The V-USB documentation wiki is also pretty useful.

  5. macegr says:

    Also, doing USB device interfacing on Linux or Mac is SO EASY compared to Windows. I would say that USB interfacing using LibUSB is actually easier on Linux, in some cases, than RS232!

  6. Drevious says:

    Sadly, serial is still much easier to use.

  7. bob23 says:

    libusb is great for developing, but a PITA for non-technical end users.

    Where possible, I try to make HID or MIDI devices.

    Hardware:
    http://hackaday.com/2011/08/26/dev-board-from-an-avr-programmer/

    Software:
    http://cryptomys.de/horo/V-USB-MIDI/index.html

    Done!

  8. patrick says:
  9. follower says:

    If you are interested in using V-USB with Arduino I ported it a couple of years back:

    http://code.google.com/p/vusb-for-arduino/

    I haven’t checked if it needs to be updated for 1.0 though.

    • gr0b says:

      The problem with all the V-USB examples is that most of them require libusb-win32 which I found to be too complicated for the common user.
      I would like to see a dumb’ed down Arduino lib like Rancidbacon’s http://code.google.com/p/vusb-for-arduino/ but with HID comms examples (not keyboard/mouse) that are easy to get working for Win7x64 users without libusb or custom/hacked drivers.

      But I think most of the Arduino crowd are just moving to atmega32u4 style chips that support USB CDC (serial) natively.

  10. Drone says:

    Those are some loooong wire runs on those breadboards Pilgrim. You sure are lookin’ for trouble there. You’d also do right to add a lot of bypass caps to those power rails.

  11. jokkebk says:

    Thanks for every reader who visited the tutorial, I was really happy to see such interest and hope many found the articles useful! As a thanks, I added a post on turning the project to a USB HID mouse:

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

    Those are some loooong wire runs on those breadboards Pilgrim

    If you were referring to me then yes, placing ATtiny, regulator/USB circuit and ISP programming header on different corners of the breadboard for clarity made for some long wire runs. Don’t try this at home! ;)

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

Follow

Get every new post delivered to your Inbox.

Join 91,934 other followers