Quick And Dirty MIDI Interface With USBASP

[Robson Couto] recently found himself in need of MIDI interface for a project he was working on, but didn’t want to buy one just to use it once; we’ve all been there. Being the creative fellow that he is, he decided to come up with something that not only used the parts he had on-hand but could be completed in one afternoon. Truly a hacker after our own hearts.

Searching around online, he found documentation for using an ATtiny microcontroller as a MIDI interface using V-USB. He figured it shouldn’t be too difficult to adapt that project to run on one of the many USBASP programmers he had laying around, and got to work updating the code.

Originally written for the ATtiny2313, [Robson] first had to change around the pin configuration so it would work on the ATmega8 in the USBASP, and also updated the USB-V implementation to the latest version. With the code updated, he programmed one of the USBASP adapters with a second one by connecting them together and putting a jumper on the J2 header.

He had the software sorted, but there was still a bit of hardware work to do. To provide isolation for the MIDI device, he put together a small circuit utilizing a 6N137 optoisolator and a couple of passive components on a piece of perf board. It’s not pretty, but it does fit right into the programming connector on the USBASP. He could have fired up his PCB CNC but thought it was a bit overkill for such a simple board.

[Robson] notes that he hasn’t implemented MIDI output with his adapter, but that the code and the chip are perfectly capable of it if you need it for your project. Finding the schematic to hook up to the programmer’s TX pin is left as an exercise for the reader.

If you don’t have a USBASP in the parts bin, we’ve seen a very similar trick done with an Arduino clone in the past.

11 thoughts on “Quick And Dirty MIDI Interface With USBASP

    1. The usbasp is configured to be polled every 10ms, which is the maximum polling rate for low speed devices. I have tested using linux (amsynth) and windows (analog lab) and can’t notice the latency, but perhaps a more skilled person can.

    2. Nah: Midi clocks at 31.25 kHz, and this implementation uses just the receiving channel.

      I once had it implemented with an Apple ][ (CPU @ approx. 1MHz, no DMA, just bit banging). We will be OK with USB 1.1; Even receiving a continuous sysex stream should be no problem at all.

  1. I had the same need recently. I tried a few different solutions, from a VUSB-based Arduino Nano converter, and a couple of the canned arduino MIDI library examples on a 32u4 (pro micro). (the best one I fond was this one: https://github.com/BlokasLabs/USBMIDI/tree/master/examples/UsbMidiConverter). I also had some success with a ttymidi converter, that reads MIDI from a UART device and feeds it to ALSA.

    The best (and cheapest!) ended up being an STM32F103 ‘bluepill’ board, with this project here “https://github.com/TheKikGen/USBMidiKliK4x4”. The bluepill has 3 hardware UARTS, and sells for <$2. I didn't have a suitable opto-isolator, but got a PC817 mostly-working by using a speedup transistor (the gist of it is to use the external transistor to do the switching, which means you don't need to swing the isolator from 0V to 5V, but only for a few mV right around the 0.7V to drive the external transistor), while I was waiting for some 6N137's in the mail.

    The end result is the cheapest possible USB-midi adapter I could come up with, using parts already in my bin. It's native USB-MIDI on the PC side, so, no drivers or custom software needed. As a plus, it's hugely powerful, can do 3x IN and 3x OUT, and all sorts of customizable routing. And it handles sysex perfectly (a limitation of the other approaches I tried). Oh, and the author built it so that you can cascade several STM32's together to get even more expansion.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.