Sunday, October 16, 2011

Atmel Attiny45 / Attiny85 based USB MIDI controller

Today I made a MIDI controller out of an Attiny45 and a potentiometer.

This project implements the V-USB firmware from Objective Development to emulate a class compliant audio / MIDI stream device using an Atmel AVR microcontroller. It is based on the V-USB-MIDI project by Martin Homuth-Rosemann and partly on the 4-key-keyboard project.



The nice thing about this project is that it takes advantage of the internal RC oscillator of the Attiny and therefore doesn't need a crystal.

Hardware needed:
  • 1x Atmel ATTiny45-20PU or ATTiny85-20PU microcontroller
  • 2x Diodes (1N4148)
  • 2x 68 ohm resistors
  • 1x 1.5K resistor
  • 1x 0.1 uF capacitor
  • 1x 10K potentiometer
  • 1x USB cable with USB-A plug
  • Programmer for Attiny45 / 85

Schematics:





The Fuses have to be set to 0xC1 (low), 0xDD (high) and 0xFF (ext.). 

The PID and VID used in this project are sponsored by Objective Development.
AVR is a registered trademark of Atmel Corporation.

Download the project and the .hex file here. It should work equally well on both the Attiny45 and the Attiny85.

16 comments:

  1. Greetings from Estonia.

    Nice project. Simple and cheap. U inspired me to take out my tools and work with my midi project again. What is been sleeping 1,5 years. But can u send me your project files? The link above is death.

    Edu,
    vana.peni@gmail.com

    ReplyDelete
  2. Thanks! It's great to hear that this little experiment is useful for someone. Sorry for the dead link, I didn't know that the file hoster I used deletes files after a certain period of time. I updated it, now it should work again.

    Greetings from Germany,

    Thorsten

    ReplyDelete
  3. Hi
    Nice project.
    How can i complie the project file under windows?
    I tryed both WINAVR and AmtelAVR with no success
    Thx

    ReplyDelete
    Replies
    1. Hi! Sorry for not replying right away. I am using an avr plugin for Eclipse, so I don't have any experience with WINAVR and AtmelAVR. But as far as I know WINAVR has a makefile template which should be easily adapted to this project.

      Delete
  4. I had no problems with understanding the code, but I'm sort of a noob when it comes to electronics. I figure I could replace the 68-ohm resistors with 100-ohm right? Or, would that lower the voltage of the data lines too much?

    BTW, this is an awesome project! I had been looking for a well documented and useful example just like this to learn from.

    ReplyDelete
    Replies
    1. Hi! Thanks! Unfortunately I still haven't had the time to make something useful out of it.

      The 100 ohm resistors work fine. Somewhere I read that "68" is an "educated guess" and anything between 30 and 100 ohms should work well enough. Reportedly you also can leave out the zener diodes and use a 2.2k ohm resistor instead of the 1.5k one, but as my electronics knowledge is also very limited I can't say anything about that. ;-)

      Delete
    2. It's just "diodes" instead of "zener diodes", of course.

      Delete
    3. Thanks for the reply. This has proven to be a good learning experience for me. I have a few thoughts I'd like to share.

      It works well with your circuit (I built it the same day I left the previous comment), but I occasionally got a "USB device not recognized" error in Windows. This was fixed by adding zener diodes (3.6v 250mw) between the data lines and ground.

      USB doesn't like anything above 3.6v or below 3v. Since we're using such small current (20ma I believe) and the response curves of real world diodes is not perfect, the real voltage out of the data lines is about 3.3v at 20ma (what we need).

      I also used a 10k resistor for pull-up instead of the 1.5k one because I couldn't find any and because that's the usual value I've seen so I hoped it wouldn't matter. It worked fine. :-)

      I'm thinking of putting this circuit to use as a MIDI guitar pedal. I could probably put the guts in an old, broken pedal I have. I just need figure out how use the hall effect sensor inside it.

      I use Amplitube 3, so this should map nicely to the virtual wah, volume, etc. pedals in the software. I'm also considering implementing a mode switch function where I can use the same physical pedal to control multiple pedals in various ways. e.g. virtual pedal #1 is inverted and pedal #2 is not, deadzones, auto-oscillation, etc.

      Thanks again, man! I now have something to keep me busy!

      Delete
    4. You're welcome! Thanks for sharing your findings!

      Delete
    5. is it possible to program these hex files into the attiny using arduino as isp?

      Delete
  5. The same question:

    "is it possible to program these hex files into the attiny using arduino as isp?"

    thanks in advance

    ReplyDelete
    Replies
    1. It should work. I've never used the Arduino as an ISP, but as far as I know you can use avrdude (the WinAVR uploader program) together with Arduino ISP.

      Delete
  6. hello,

    Is it possible to update the link for download, it seems broken link without any progress for long time.

    ReplyDelete
    Replies
    1. Hm, for me the link still works. Perhaps you just have to try again.

      Delete
  7. Can you give us the source code of the attiny? I wonder if i can make a 4 pot controller... thank you

    ReplyDelete
    Replies
    1. Hello Alex! The source code is part of the ZIP file I posted the link to in the last paragraph of the article (just click in the word "here" ;-) )

      Delete