When I first started working on devices that use MIDI, I did what most of us do: I turned to Google for schematic examples. I found a few, but after reviewing them, I quickly realized I’d need to dig deeper to build a reliable MIDI setup for all N-audio gear, including the 8X7 and 4X4 amp switchers. In this post, I want to share what I’ve learned along the way.
Using the 6N138 Optocoupler for MIDI In Schematics
Galvanic isolation of all MIDI inputs is crucial, as it prevents digital ground loops. This is achieved using an optocoupler, a component containing a separate LED and phototransistor (or similar opto element) in a single package, providing galvanic isolation between the two elements. It is important to choose a fast optocoupler capable of transferring MIDI data reliably without skipping bits. For this design, I use the 6N138 optocoupler, which is available in both DIP and SMD packages, and although somewhat large, works very well.
To protect the LED inside the optocoupler, R1 limits its current, while D1 protects it from excessive forward voltage. MIDI voltage is typically 5 V, though some modern devices operate at 3.3 V. The 220 Ω value for R1 is standard in MIDI designs and corresponds to the resistor values used in typical MIDI Out circuits.
The optocoupler output contains two transistors and one or two resistors. Using 1 kΩ for both R2 and R3 works the best. Actually making the circuit roughly four times faster, and using identical resistor values, reduces the bill of materials. C1 is optional. I use a 100 nF capacitor placed close to the optocoupler, providing local filtering. Finally, the MIDI IN signal is routed to the processor as shown in the schematic above.
The yellow trace shows the input MIDI signal before the optocoupler. The green trace shows the output signal after the optocoupler.
Using the 6N137 Optocoupler for MIDI In Schematics
The 6N138 is a high-speed optocoupler with a logic-level output that provides fast rising and falling edges. Both 6N137 and 6N138 optocouplers are pin-compatible, making them easy to interchange with only minor adjustments when using a universal PCB layout.
The 6N137 features a digital output stage, which sets it apart from the 6N138. Interestingly, their prices today are relatively similar. The only schematic difference is the absence of one resistor compared to the 6N138 design.
Below is a fully working schematic using the 6N137 optocoupler:
Using the PC817 Optocoupler for MIDI In Schematics
The PC817 optocoupler is definitely too slow for direct MIDI signal transfer. However, by adding a single transistor after it, the switching speed increases dramatically. In fact, the same concept is used in the 6N138 optocoupler, which already includes an internal transistor.
So what makes this design better than the others? The price. It’s always the price. Making something cheaper while keeping it fully functional is the real art of electronics 🙂
Here are the prices for 1000-piece quantities:
PC817S – $0.019
EL3H7 – $0.034
6N138S – $0.24
6N137S – $0.14
A single BC847C transistor costs only $0.004, which is still an order of magnitude cheaper!
The component area on the PCB is smaller as well. You can even replace the PC817 with an EL3H7 in the small SSOP package if you need to save even more board space. Here you can see the full schematics:
Designing The MIDI Out Schematics
The MIDI Out schematic uses a single transistor buffer, which is both fast and inexpensive. It protects the microprocessor from high static voltages coming through the MIDI cable. I chose the 2N5551 (or MMBT5551 SMD) for its high collector-emitter voltage (Vce) of 160 V.
For EMI filtering, I added two 100 pF capacitors. The 220 Ω resistors limit the current through the optocoupler’s LED from the MIDI In circuit to about 5 mA, while R3 limits the transistor’s base current. Separately, connecting the ground to the middle pin of the DIN5 provides additional shielding for the MIDI cable. Finally, note that this circuit requires the microprocessor signal to be inverted to operate correctly.
Power over MIDI
One clever design feature of the N-audio amp switchers is the ability to power FX-Loop extensions directly through the MIDI Out connector. While this isn’t part of the official MIDI standard, some designs use pin 3 for +5 V and pin 2 as ground. This allows you to power other MIDI devices without a separate power supply. Even better, once the amp switcher is powered on, the connected FX-Loop turns on automatically.
Summary
I hope sharing my experience with MIDI implementation helps you in your own designs and understanding of this technology. These schematics should provide a good working solution, saving you time and effort in your search for an effective MIDI implementation. If you want to learn more about MIDI, check out this blog post where I explain more about MIDI for guitar players.
Niki Hristov