The definitive MIDI controller | This is not rocket science

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?

10 Responses

  1. John

    Hi, it looks like you have come up with a solution I am looking for. I am wondering, is it possible to take your midi interface with USB, and connect to a raspberry Pi? If you have any tips to make that happen would be much appreciated.

    Also eagle schematic and BOM would be welcome as well.
    Thanks and keep up the great work


    December 5, 2014 at 06:29

    • ld

      John, the midi board implements the standard USB interface, so it should work practically anywhere, and Raspberry Pi is just a normal Linux box. Ah, I haven’t tried it on a Mac… but I guess it should work the same.

      Drop me an email (see bottom of page for the link) and I’ll send you the schematics.

      December 5, 2014 at 08:25

      • John

        Hi, Did not see a link to send you a email directly, Please use to send info. I am very excited to try this out!

        December 5, 2014 at 23:36

  2. Sel

    Hi! Can I ask You!
    Can You do the USBmidi>to>5-pin MIDI converter?
    (with bus power on standard 5V USB)
    To I can use the USB-midikeyboard with my analog synth (which have only 5-pin midi and can feed the 5V bus power) standalone from computers

    Complex to explain, but I can send a scheme picture to Your e-mail

    January 13, 2016 at 17:16

    • ld

      Sel, sure, it’s certainly possible.

      But that kind of cables are not that expensive in stores either, so I don’t think that you would really save any money that way.

      See for example for one.

      January 14, 2016 at 19:41

      • Chris

        I don’t think that’s what Sel is asking you about. I think he is asking if your device will convert a USB midi controller to the 5 pin standard midi output like the Kenton USB MIDI host? If that’s not what he is asking about, at least that is my question. If it can, can your device also take a USB hub so that I can connect multiple USB midi controllers?


        February 16, 2016 at 19:10

        • ld

          Ah, right. No, this device won’t do that as it’s not a USB host. It won’t take a USB hub either because of that.

          March 1, 2016 at 21:17

  3. gabriel

    Can i buy this interface?

    May 30, 2016 at 17:19

    • ld

      I don’t have complete boards available… send me an email, let’s see if I can help you. You can find my mail address at the bottom of the page.

      June 2, 2016 at 06:10

  4. Hello, not everyone wants to have the bottleneck of a computer between their keyboard and Synth. I have the Arduino and Raspberry Pi 3 platforms and I am looking for software to connect my older MIDI (5 pin DIN) keyboard to a newer USB-MIDI synth without the problematic delays of a computer acting as middleman. I believe what I am looking for is software which converts 5 pin DIN to USB-Host! I would like to find the source code for this function as I also need to try to do some voltage to USB-MIDI conversion! The only software I have found is 5-pin DIN to USB-DEVICE not 5-pin DIN to USB-HOST! I am not looking for a “Product” as I want to experiment in true Linux practice. If you visit my web site you can find a free program I developed many decades ago and have continued to support. Thank you

    January 25, 2017 at 17:42

Leave a Reply

Your email address will not be published. Required fields are marked *