The MP-1 will include a wireless interface. I decided to test the possibilities of the technology I chose. Mainly, I will be using an RFM12B transceiver to exchange data between components.
So, I designed a very simple interface using off-the-shelf parts: An Arduino and an RFM12B radio. Because I wanted to test MIDI data trasmission initially, I used a Sparkfun midi board design.
The RFM12B is cheap, works well within 100 meters (line of sight) and Jean-Claude Wippler, of Jeelabs.org, wrote an excellent library and many examples to help you (and me) use the RF capabilities of the little transceiver. Why not a Zigbee transceiver? The Zigbee is more expensive: An RFM12B by itself costs $7. With a board (more on that below) it’s $17. Actually, the Jeenode V6 pictured here cost $22.50 and includes the radio. A Zigbee costs $20 to $40. Add the $10 board, then the Arduino… you get the idea. Of course, the Zigbee is more versatile, but the RFM12B does what I need for this project (and others ).
But wait… you need two to tango! So I needed to build a second transceiver, using a Jeenode and my own midi interface.
Both MIDI interfaces share a very simple circuit (from Sparkfun.com’s site):
In the first picture, the part on the top right is a Jeenode V6, from Jeelabs, but this one is a variant, using smd components, and the battery on the left is just that. But it has something special: it’s mounted on a AA battery board from Jeelabs, which effectively bumps the voltage of a single AA cel to 3.3 volts! It will be enough to power the Jeenove and the simple interface to the MIDI connector. The current demand is about 18.9 mA when idle, and close to 20 mA when working. The battery will last long enough for the testing phase. Go to the link to understand the technology behind it.
I tried to simplify the MIDI interface by omitting the opto-coupler (replacing it with a 820 Ohm resitor) and while it worked when the Jeenode was powered by a USB port, the battery version would not provide enough of something… Why not use the opto-coupler? The MIDI electrical specifications explain that the MIDI IN connection needs to be electrically isolated to prevent current loops between different equipment because of possible ground level differences. But since this circuit is not physically connected to any other piece of equipment, the isolation is redundant. But I found that it was simpler to use the opto-coupler to do Logic level voltage matching. The Jeenode uses 3.3 throughout.
It might be possible to extract power (5V) from the MIDI interface (from MIDI IN) from your instrument, but many MIDI connections won’t let you do it. Also, the MIDI THRU implementation might create new problems.
So, the two hardware configuration presented here cost ~$25 for the Jeenode/My MIDI interface and ~$60 for the Arduino/Sparkfun shield/External RFM12B version. Again, keep in mind that these were all parts that I had on-hand. But you can see that cost can vary a lot for equivalent hardware. I have a bunch of external RFM12B boards to add RF capabilities to standard Arduino boards. They are fairly expensive compared to solo RFM12B radios, but provide logic level matching (the RFM122B works with 3.3 Volt only) and even contains a voltage regulator to provide 3.3 Volts to the RFM12B or anything else.
The software (MP-1 V0.1) is exactly the same in both hardware configuration: The program reads the MIDI port continuously, expecting MIDI messages. It then transfers control to sub-routines within the Arduino Midi Library. I decided to use the official MIDI library because it contains code that I will need in the future. It also doesn’t seem to insert excessive delays in the MIDI processing. The sub-routines then use the RFM12 library to send the MIDI messages wirelessly. At the same time, the processor listens to incoming wireless messages using the RFM12, driven here by an interrupt. The RFM12 library handles all communications and prepares “packets” of data, containing MIDI messages. Each message will trigger a piece of code that sends the newly-received MIDI message on the serial port.
Basically, the software contains two independent loops. One waits for incoming wireless messages and transmits each one on the serial port (MIDI OUT port) and the other loop waits for incoming MIDI messages on the hardware serial port (MIDI IN port) and sends each one over wireless.
The code is compact because I use the libraries. I could make it more efficient by writing the whole thing myself, but using existing libraries I haven’t had buffer saturations or dropped MIDI commands, even when continuously pressing more than 40 keyboard keys simultaneously (by quickly and repeatedly pressing both forearms on the keyboard)(which makes me look like a chicken!).
The sample code included here only processes NoteOn, NoteOff and ControlChange commands. The next version will process more MIDI messages and some home made extra messages.
I haven’t tested transmit range. Also, I don’t know how this would fare in actual show venues. But I know that there are at least 4 other devices using the same radio frequencies in my house (915 MHz). After all, this is not WiFi. 915 MHz is used by alarm systems, weather equipment (digital thermometers, etc) and some others. But because this is an unregulated spectrum, PRO equipment doesn’t use it. PRO is all cramped in the 2.4 GHz (WiFi) band. Go figure.