The definitive MIDI controller

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?

3 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

    John

    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 jtemplar1@gmail.com to send info. I am very excited to try this out!
        Thanks!!!!

        December 5, 2014 at 23:36

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>