# Use a PC123 optocoupler for MIDI input

Im trying to connect a MIDI input cable to an arduino. To do that, I need an optocoupler, that secures the internal circuits from damage.

This is the schematic as shown by the MIDI specification: edit: The input uses 5V.

I have a PC123 optocoupler by Sharp lying around, so I'd like to use it in the circuit. The problem is, that I'm not quite sure if this optocoupler can be used for this circuit. I think that the maximum ratings are acceptable but maybe I'm missing some details.

these ratings can be found in the specification here.

• What are the midi in voltage levels? – Andy aka Oct 17 '15 at 12:21
• The voltage is 5V (used in combination with 0V to create a bitstream of data). – tly Oct 17 '15 at 12:56

There is no problem with the absolute maximum ratings.

However, there might be problems with the other parameters of this optocoupler. The MIDI specification calls for a high-speed optocoupler. which the PC123 is not.

At the 5 mA specified for the MIDI current loop, the PC123 has a guaranteed current transfer ratio of at least 50 %. This means that to get a 5 V signal out, you need at load resistor (Rd above) of at least 5V/2.5mA = 2 kΩ. As the datasheet shows, the typical raise/fall times in this case are about 20 µs:

This is way more than the 2 µs limit of the specification. At 31250 baud, the length of a single bit is 32 µs; this optocoupler will distort the signal beyond all recognition.

With the Arduino's Schmitt trigger inputs, and a portion of luck, you might actually be able to get the signal out, so you might as well try it. However, this is nothing I would recommend you rely on.

If you don't want to buy a suitable optocoupler like the 6N137, 6N138, or H11L1, you could try to use additional circuitry to prevent the phototransistor from saturating and to amplify its signal:

• Thanks for the clarification. I totally forgot the connection speed, it seems to be reasonable to buy an appropriate optocouper instead. – tly Oct 17 '15 at 16:49

You can expect forward current If = (5V-1.2V) / 220 ohm = 17mA. Ic is (5V-Vcesat) / 280ohm = approx 4.7/280= 17mA.
IMO it shall work without any problem.

• MIDI is specified a 5 mA; you forget the other two 220 Ω resistors in the sender. – CL. Oct 17 '15 at 14:50