When I first began designing devices that support MIDI, I searched for schematic examples on Google. After reviewing a few examples, I realized that I needed to delve deeper into the matter to create a well-functioning MIDI implementation for all N-audio devices. In this topic, I’d like to share my experience with you.
What is MIDI?
MIDI stands for Musical Instrument Digital Interface, which is a serial communication protocol operating at 31,250 bits per second. It uses 8 bits per byte, along with a start bit and a stop bit, and operates at 5 volts DC. The standard MIDI connector is a 5-pin DIN connector, with female connectors on the device and male connectors on both ends of the MIDI cable.
Designing the MIDI In Schematics with 6N138 Optocoupler:
Galvanic isolation of all MIDI inputs is crucial, as it helps to isolate the digital ground loops. This is done through an optocoupler, which is a component that contains a separate LED and phototransistor (or an opto component) in a single package with galvanic isolation within the range of 1000-5000 volts between both elements. It’s important to choose an optocoupler that is fast and can adequately transfer the MIDI data without skipping bits. My choice here is the 6N138 optocoupler, which is relatively cheap and available in DIP and SMD packages, although it’s relatively large in size.
Designing the MIDI In Schematics with 6N137 Optocoupler:
The 6N138 is a widely used optocoupler from the 1980s, particularly in the era when the first digital guitar effects processors with MIDI capabilities were introduced. Another cost-effective alternative for MIDI input schematics is the 6N137. It is a high-speed optocoupler with a logic output making the rising and falling edges even faster. Both optocouplers are pin-compatible, allowing for easy interchangeability with minor modifications when utilizing a universal PCB design.
The 6N137 has a digital output optocoupler, distinguishing it from the 6N138. Surprisingly, the prices of both optocouplers are relatively comparable these days. While the use of a bypass capacitor with the 6N138 is optional, it becomes important for the 6N137. The sole distinction here lies in the absence of one resistor compared to the 6N138 schematics. Here you can see the fully working schematics using the 6N137 optocoupler:
Designing The MIDI Out Schematics:
When it comes to the MIDI out schematic, simplicity is key. To achieve this, I opted for a single transistor buffer, which is not only fast but also affordable. Moreover, this transistor also isolates the microprocessor, ensuring added protection. I selected the 2N5551 (MMBT5551 SMD) transistor specifically for its high Vce (collector-emitter voltage) of 160V. For EMI protection, I incorporate two 100p capacitors into the circuit. Implementing this circuit with two 220 Ohm resistors effectively limits the current across the 6N138 LED from the MIDI in schematics to approximately 5mA. R3 plays a role in limiting the base current, while grounding the middle pin enhances shielding across the MIDI cable. It’s important to note that when using this circuit, you must invert the signal from the microprocessor.
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.