MIDI Experiments: Arduino as master

Arduino as a Midi master

The previous two posts explained how standard MIDI can supply some current at 5 Volts if implemented according to the MIDI standards. In this post, I go a little further and explain how an Arduino, set up as a MIDI device, can power a second Arduino using a standard MIDI cable.

The setup:

The first Arduino is a Mega, but it could be any model. It’s connected to my Ultimate MIDI Board, providing it with +5 Volts, Ground and MIDI OUT (Arduino TX —> MIDI OUT). If you have read the previous two posts, you know that this setup adheres to MIDI Standards. A simple MIDI cable (2 connectors and a shield) is connected to a second Arduino. This one draws power from pins 4 (+5 Volts) and pin 2 (Ground). Pin 5 (MIDI IN) is connected to Arduino RX.

The code:

The first Arduino runs a small program that will flash its LED every second and send a MIDI Program Change message through its TX pin.

The second Arduino checks for MIDI ProgramChange messages and will flash its LED a number of times, according to the Program Change number (5 in this case!).

PLEASE NOTE: A MIDI connection is not really made to power equipment but it can when setup properly. Most MIDI equipment can only supply a few milliAmps. Many can’t supply any. But since this is a micro-controller used as a MIDI master, we can use it’s power, within the Arduino parameters: 200 mA maximum. This circuit draws 12 mA from the Arduino Mega. This is safe and won’t break anything. Also, there is a reason the MIDI standard specifies that pin 2 is left un-connected on the receiving side: used this way, it helps the MIDI cable reject interference. If you connect pin 2 to ground on the receiving end, you also share the ground between two different circuits and this can cause AUDIO problems (ground loop causing “hum”). But, in this example, the receiving Arduino is not connected to anything. So we don’t care about sharing ground. Read on…

A second experiment:

This setup can be used to filter/modify MIDI messages. If the second Arduino is programmed to it, it can intercept the incoming MIDI code and send a filtered/modified version on its MIDI OUT port to another instrument/synthesizer/computer.

What about ground loop then? If the second Arduino shares ground with the sending equipment (as above), you rely on the receiving equipment to properly implement the MIDI standard and use an optocoupler to isolate the incoming MIDI connection. Most do this well. In the next video, the second Arduino send MIDI OUT to a computer. That computer’s interface is using proper MIDI standards and isolates the MIDI signal.

Here, I use Midi Monitor to show the signal generated by the first Arduino, passing thru the second Arduino (powered from the first, as above) and to the computer.

This entry was posted in Arduino, Electronics. Bookmark the permalink.

Leave a Reply

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