MIDI (Musical Instrument Digital Interface) is a technical standard which describes the protocols and digital interface to control electronic music instruments, recording equipment, drum machines and lights. First published in 1981 the MIDI standard still remains the number 1 protocol possibly used by all manufacturers of music instruments today.
I have for some time been interested in seeing if I can use an Arduino to control MIDI instruments and after a short bit of research I found that MIDI is actually a very simple serial interface running at 5v and, although not advisable, you could simply transmit and receive MIDI by connecting directly to an Arduino’s RX and TX pins.
Reading some more, I found out that in order to correctly connect a MIDI cable to an Arduino for MIDI Out purposes it is advisable to add a 6N138 optocoupler in-line on the TX out. An optocoupler is an electronic component that transfers electrical signals between two isolated circuits by using light, the purpose of this in our case is to prevent ground loops which often plague audio systems.
For my project I wanted to add a MIDI In and a MIDI Out interface to my Arduino and although there are a couple of different Arduino MIDI Shields available I wanted something a little simpler, for a couple if reasons:
Firstly, I simply wanted to have a go at building my own PCB circuit and this MIDI interface seemed like a good starter project to do this and in doing so would learn a bit more about how it is built.
Secondly, I wanted to build something which was a little more universal, in that I wanted to possibly connect it to a Raspberry Pi, Arduino Nano, Espruino etc, the Arduino shields available are quite big and are only meant for larger Arduino Uno etc.
With the help from someone on Fiverr I had the following schematic and PCB design drawn up for my prototype circuit:
As part of the design I was supplied with a GERBER file containing the above schematic, PCB and BOM (Bill of Materials). The next step was to send the this GERBER file off to be fabricated, for this I chose PCBWay who were offering manufacture of 5 PCBs for $5 (plus a little extra for shipping). I found PCBWay’s order process incredibly simple and after support excellent. Although they are based in China, after only a couple of weeks, the following parcel arrived in the UK:
While I was waiting for the PCB’s to arrive I sourced the other components; resistors, diodes, 6N138 optocoupler and connectors. Once I had all the parts it was fairly quick to soldier them all up:
We are now ready to connect them to an Arduino and play! Connections:
|Pin 1 : +5V||Pin 0 : 5V|
|Pin 2: RX||Pin 0 : RX|
|Pin 3: GND||Pin x : GND|
|Pin 4: TX||Pin 1 : TX|
In my next post I will talk about how to use.