Monday, January 11, 2010

Quick and Dirty Arduino Midi Over USB




A lot people use arduinos as a starting point for diy midi controllers. A perfectly reasonable assumption many of them make is that you can use the on board usb port to send midi data to your computer. While you can send serial data, it is not possible for your computer to recognize this as midi messages right out of the box.

One popular way around this is to have a piece of software running on the computer which listens for incoming serial data from the arduino and passes the midi data on to the appropriate places. Various methods exist ranging from running a Max patch listener to writing and installing custom drivers. There is a lengthy thread on the arduino forum explaining the issue in depth as well as what poeple have done to get thier projects to work.

I wanted my devices to be able to work on any machine without first having to install special drivers or running separate programs.. It seems cleaner and more straight forward that way.. plus I am lazy and installing drivers is boring.

While looking for options, I stumbled on this ridiculously cheap midi-usb converter cable and got the bright idea to just embed the whole thing in the controller.



The set up is pretty straight forward... you basically just need to bypass the cables and wire the arduino directly to the circuit board inside. The final product is plug and play, powers the arduino, and fits nicely inside your enclosure.



To begin, pry open the enclosure and disconnect the cables. You could make your life easier by leaving the usb cable connected and just have the cord sticking out of your project, or remove it and wire up a usb socket.  Either way, the important part is that little green board in the center. Midi data goes into one side and midi-over-usb magic comes out the other. The chip on board will be recognized as a usb midi device when its connected and use your computer's native midi support.  Neat-o.



As far as the arduino is concerned, it is just sending straight midi, so the circuit is the same as if you were just connecting a midi socket. Of course, instead of connecting to a socket, you connect to the midi side of the board like so:



The darker lines are all thats needed if you are going to leave the usb cable attached. Note the line from the usb side reaching over to the arduino Vin for power.  The rest are if you want a usb socket instead of the dangling cable (the rectangle on the right is a type b usb socket shown from the top).

Thats about it. This is set up just to provide midi out from the arduino, although midi-in would just involve another wire from the board to the Arduino's Rx pin.

To test everything out, load up the midi example that comes with the Arduino environment, plug in the usb and let it rip. If it doesn't work, you probably messed something up.. good luck.

Tuesday, December 1, 2009

Calculator MIDI USB Controller

Borderline useless, more trouble than its worth, but cool nonetheless.


Make cool things look as nerdy and boring as possible!

One of the first things I thought of doing with an arduino was turning an old calculator into a MIDI controller. The buttons are simple momentary switches.. no velocity sensitivity, but its nice for a pretty compact set of buttons.. and it looks neat. stfu.

Eight of the buttons are connected to the arduino digital inputs through a 4021 shift register as explained here. The rest make their way directly to the remaining digital ins.


The shift reg as well as the actual connections to the keypad are hidden on the underside of that slightly burnt perf board

Button matrixeses are generally pretty similar. Each button can be checked by a unique pair of contacts on the terminal or ribbon cable or whatever is connecting to the board. The trick is finding out which ones go where. All it takes is a little patience and a volt meter with a continuity tester.

Here's a tutorial I just found showing how to interface with a keypad. You're welcome.

The arduino patch checks the state of the buttons and generates the MIDI signals which are sent to a butchered $6 MIDI to USB converter cable/board/thing.


The midi-usb converter is the green board at the far right. 
Midi from the arduino's serial out goes into the bottom, usb comes out of the top. 
It also powers the arduino.

I mainly use it to trigger cue points in Torq, but it works just as well for triggering clips or controlling a drum rack (minus velocity sensitivity, of course) in Live.

This is actually the second calculator I've tried. The first one is a mess and lacked the tricky USB support. I'll find some time to redo it and document it from the start, in case someone else would like to do something similar.