Wednesday, 8 March 2017

arduino - 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. MIDI Input


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.


PC123 ratings


these ratings can be found in the specification here.



Answer



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:


PC123 response time vs. load resistance



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:


MIDI input with phototransistor optocoupler and transistor amplifier


No comments:

Post a Comment

arduino - Can I use TI's cc2541 BLE as micro controller to perform operations/ processing instead of ATmega328P AU to save cost?

I am using arduino pro mini (which contains Atmega328p AU ) along with cc2541(HM-10) to process and transfer data over BLE to smartphone. I...