The definitive MIDI controller | This is not rocket science


USBmidi2 4×4 teaser

Here’s a snap of the USBmidi2 4×4 fit on a lasercut half-rack proto panel (can you find it?):

USBmidi2 4x4 halfrack

USBmidi2 4×4 halfrack

The rack PC mount was another small side project. I have had that Nord Modular for some 13 years. Now finally I got its editor running in the place where it belongs, right next to the synth! The PC and screen are from ebay, with the PC hiding behind the display. The mount for buttons and the PC was manufactured Protocase. Some wires are still sticking out, the buttons are not hooked up yet.

USBmidi2 4×4 coming soon!

Second iteration: USBmidi2

usbmidi2 full frontal

usbmidi2 full frontal

* Download datasheet *

USBmidi2 is a USB MidiStreaming class-compliant device, in double. It connects your computer, over MIDI, to another computer.

USBmidi2 is also a component that you can embed in your own musical instruments. Add a USB MIDI device port to your project, along with the three standard MIDI jacks!

To skip to the end of the story, I built a few of them to share.

Drop me an email if you are interested in acquiring one at a reasonable price.

USBmidi 1x1Sold out!
USBmidi 4x4Almost there!

I got a few requests for a MIDI interface for the Raspberry Pi, so that the Pi could be used as a component in a hardware synth module. The point was that most MIDI interfaces only have a single USB device port for connecting to a computer, and that one is taken when you plug it to your Pi. Yet a synth should behave like a USB MIDI device itself, so there should be a second port for a laptop.

So two computers, talking to each other over MIDI over USB, both acting as USB hosts… no problem! Stijn had told me about these really really nice Kinetis KL26 microcontrollers with plenty of UARTs and a built-in USB interface. One USB interface, per chip.

The only MCU with two USB interfaces that could possibly fit this purpose was the NXP LPC43xx series that I used in the signal analyzer. But the LPC is massive – TQFP144 – while the KL26 is small and flexible. So it was clear: there should be two KL26’s, with one USB port each, connected together. And the overall design seems simple enough, this way:

usbmidi2 design

The board appears as two MIDI ports on both computers. First port goes directly to the other USB host. The second one is connected to the MIDI jacks, and data is interleaved from both computers.

usbmidi2 connections

You can see the MIDI in/thru/out ports and the slave USB connector in the picture of the front of the device, at the top of this page. The backside has just the USB jack for the Pi, and looks like this:

usbmidi2 left profile

First batch of usbmidi2. Fresh hand-made boards, mmm! :)

First batch of usbmidi2. Fresh hand-made boards, mmm! :)

This is how it works in practice:

usbmidi2 connected to a Raspberry Pi

usbmidi2 connected to a Raspberry Pi; the board is intended to be mounted behind a panel, so that the Pi fits inside the same enclosure.

I’m also working on the expanded version; since you read all the way down here, here’s a teaser ;-)
usbmidi2 4x4 front viewusbmidi 4×4 – not announced yet!

Mounting dimensions: See datasheet.

Further technical details: TBD

Source distribution:

USB MIDI interface

The RPC is a MIDI controller and implements the age-old 1980s serial MIDI bus, and the Protosynth must be capable of interfacing with it. But in general use a USB device port is much more practical than the three ubiquitous MIDI ports; it allows connecting the synth directly to a laptop or other computer at any time. And USB host ports are starting to become popular in sequencers also. So that means I need an interface module that has both, and that can talk to the main synthesizer board over two serial buses. The mainboard processor must take care of interleaving the commands received over the two buses.

Standard MIDI ports are no problem, I had the basic circuitry working with the RPC and could simply lift it from there. The synth’s LPC1678 microcontroller has several UARTs, and it’s very easy to configure them according to the MIDI standard. USB was going to take some more work though. I didn’t have enough space on the DSP mainboard to make use of the LPC’s built-in USB controller, so I decided to keep it that way and went for an off-board solution. My approach was to build an external board that could speak MIDI over USB, and pass the data stream over an UART to the mainboard.

Here’s the general idea:
DSPMIDI block diagram

Luckily USB-capable microcontrollers are a dime a dozen these days, so it’s only a matter of choosing a suitable one for the purpose. A little bit of searching found me MocoLUFA, which is a complete implementation of a standard MIDI USB device for the ATmega, created by morecat_lab. The ATmega8u2 it was intended to be used with looked very nice, and its bigger brother ATmega32u2, while pin compatible, would have plenty of capacity for future expansions if necessary. The Arduino Uno is one example of the use of these chips; the Arduino team very successfully replaced the previous FTDI USB controller with an ATmega8u2 to reduce the cost of their boards. With inspiration from the Uno schematic and from the ATmega32u2 datasheet, I drew up the first version of the MIDI board.

DSPMIDI rev1 assembled

The design was straight-forward. I used the 4N28 optocoupler and through-hole components for the MIDI side because I had those at hand. Except for the bypass capacitors. I have a lot of 0603 size 0.1uF caps now! :-) In the default configuration (F1 unpopulated in rev2 schematic) the device is self-powered: it will NOT draw its power off the USB bus. That means the it will disconnect from the computer when the it is powered off, as expected for a stand-alone device. It requires an external 3.3V power supply, and the signal voltage for all communication to and from the mainboard is 3.3V. The MIDI DIN5 connectors are very close to each other in the first revision of the board; while there are some DIN jacks that should fit, I dragged them a little bit apart for the second revision. Almost all of the GPIO pins on the ATmega are wired to am extra pin header next to it. Four are connected to SMD LEDs.

The ATmega8u2 does not have a dedicated VBUS pin for detecting whether it is connected to a USB host or not, and the MocoLUFA software can be configured to use some other GPIO pin for this purpose. In the end I left VBUS unconnected, because I wasn’t sure if the ATmega could handle overvoltage on the pins. The data sheet indicates this should be avoided. The USB firmware still works, albeit not completely according to the standard.

The two serial buses connecting the interfaces to the mainboard run at different bitrates. The real MIDI interface must be configured at 31250 bps. The USB interface doesn’t seem to have any such limitation, so I set it to 125 kbps. Just because it was a nice round number with the ATmega running by a 8 MHz clock. I’m not yet sure what kind of flow control the USB bus is capable of…

For programming the ATmega you will need an AVR programmer that can be hooked to the 6-pin ICSP port. I used a 5V Arduino Mega 2560 with the ArduinoISP firmware installed on it. The supply voltage of the Arduino is not an issue as long as you keep the MIDI board otherwise completely disconnected during programming. The MIDI ports are designed for a 3.3V power supply, so if they are powered by 5V they may fry any connected MIDI devices! During programming the board will draw power through the ISP port.

Here is the schematic, click for a larger image:
DSPMIDI rev2 schematic

And the board layout:
DSPMIDI rev2 layout

I will add the gerber files and BOM here later. Drop me an email if you’re interested in them or the Eagle source files (see bottom of page for the address). I have several rev1 PCBs left, and will most likely solder together at least a few more if all goes well. There are many possible interesting configurations of the board. For example, if the ATmega32u2 is sufficient for your application all by itself, the MIDI ports could be connected directly to it… How about a stand-alone arpeggiator board?