6
\$\begingroup\$

I have the following circuit which I would like to use to connect a MIDI enabled device. I am not getting any signal on pin 5, could it be because the resistor from the base to ground in too small? I am not sure how to calculate it from the datasheet.

enter image description here

Update #1

I have replaced the opto-isolator, tested the input using an LED and could see the LED light up indicating current flows in the MIDI loop. I have placed a scope probe on the output of pin 5 of the device. pin 6 is now not connected to anything. Normally (idle) the signal is pulled high, when a signal comes in the signal goes low but only down to ~2.8V which is not enough to register as a logic low.

enter image description here

Update #2

I have replaced R17 with 360 Ohm. Now the signal goes as low as 1.6V.

Update #3 - Final one

I've swapped the 360 Ohm resistor for 1K. Now the signal looks much better and it reaches almost 0V when low. It is worth mentioning the scope claims rise time of 7us and fall time of 3us (probably on the low side). Considering the MIDI freq. with about 32us per bit this is short enough not to have false readings. The MIDI signal goes to an Atmel AVR and from testing I did right now it seems the messages are going through clearly. I agree that this is not the optimal device for this task though, and the circuit one would make for it (if he desires) looks very similar to what is contained by the PC900 optocoupler from Sharp.

enter image description here

\$\endgroup\$
3
  • 1
    \$\begingroup\$ Mmmm 31.25 kBd is quite a challenge with that opto, it may prove hard to get to a reliable reproducible design. Then, yes base resistor is for sure too low, its value is better find out experimentaly: adjust till out pulses are not distorted (compare input and output high/low times). It may also help increase R17: risetime is basically ruled by R17 and output stray cap but delay time (which is much more important for pulse distortion) is strongly related to time taken to pull transistor out of saturation, hence as far as this is concerned the lower Ic the better. \$\endgroup\$
    – carloc
    Commented Jul 2, 2017 at 19:44
  • \$\begingroup\$ Where did you get the values of R? and R17 from? \$\endgroup\$
    – CL.
    Commented Jul 2, 2017 at 21:11
  • \$\begingroup\$ @CL - I waned to use a 100 Ohm to begin with but only found a 200 Ohm and from the graph you can see they are not that far from each other. \$\endgroup\$
    – user34920
    Commented Jul 3, 2017 at 16:02

4 Answers 4

5
\$\begingroup\$

The 4N35 is too slow for MIDI.

With a current transfer ratio of 100 % (which is specified for 10 mA, so you get even less for MIDI's 5 mA), you cannot rely on getting more than 5 mA through the output. This means that to be able to drop the full 5 V, you need a pull-up resistor of at least 1 kΩ. And this means that you will not be able to switch at the MIDI baud rate of 31250 Hz (and a digital UART signal requires much more bandwidth than a sine wave):

4N35 frequency response

And with a resistor at pin 6, the CTR would become even worse:

4N35 RBE

If you really want to use the 4N35, then it is possible to speed it up by adding a transistor as an amplifer with a lower input impedance:

PC817 MIDI

But the simplest method to get the MIDI input to work would be to use a high-speed optocoupler like the H11L1 or 6N137.

\$\endgroup\$
3
\$\begingroup\$

I have used 4N35 OCs for MIDI. Fast enough transition from ON to OFF needed ridiculously low series resistor for the output transistor. The output voltage swing was about 0,5V. I added a comparator to make the proper logic output.

Why 4N35 and not some recommended type? Because I had a handful of 4N35's.

\$\endgroup\$
1
  • \$\begingroup\$ That's my motivation! \$\endgroup\$
    – user34920
    Commented Jul 3, 2017 at 15:53
1
\$\begingroup\$
  1. Check your input:

    • Replace U5 with a standard LED connecting the anode to 1 and cathode to 2. It should blink when MIDI data is sent.
    • Test again with the LED in series with R18 and U5. If it glows (probably much more dimly) it proves current is flowing. If not it might be just that there is not enough drive voltage.
    • Check your MIDI input signal polarity.
  2. Check your output:

    • Disconnect R? from the photo-transistor base. It's there to make sure the photo-transistor turns fully off but should work for test purposes without it.
    • Put an LED in series with R17. This should glow when data is being sent.

Failure with these tests may indicate that the opto-isolator is damaged.

\$\endgroup\$
1
\$\begingroup\$

Having the base of the opto transistor based to ground via a resistor is a double edged sword. On the one hand it can help the transistor to shut off a bit faster. But at the same time it makes it harder to turn on which is almost equivalent to lowering the current transfer ratio.

The small sized collector resistor is a huge challenge for a clunky old beast of an opto-coupler like a 4N35. Particularly with the poor current transfer ratio of parts like these.

So as you have already started to experiment and has been commented in other answers here the base resistor needs to be made much larger or eliminated. In addition the collector resistor needs to be made much larger as well.

People always select the 4N35 because it is cheap. But, as they say, you get what you pay for. There are better opto-couplers that offer way higher current transfer ration and have full logic output stages instead of just an uncommitted transistor.

There are some types of opto-couplers that will work better in a digital isolation scheme such as the 6N136/6N137. These offer an improvement over the cheap garbage but can still can present an challenge. In async serial applications I have experienced problems with 6N137's due to the problem of pulse shape distortion due to non-uniform on and off propagation delays through the part. A robust solution is to look for parts that have full output drivers built in to then specifically for digital applications. One example is the part number ACNT-H61L from Avago (now part of Broadcom). These offer performance up to 10MBd and source and sink 3.2mA and maintain good logic swing outputs.

\$\endgroup\$
6
  • 1
    \$\begingroup\$ MIDI runs at 0.03 MBd and can tolerate pulse width distortions of several microseconds; using the H11L1 with a 10 kΩ pullup would be no problem. \$\endgroup\$
    – CL.
    Commented Jul 3, 2017 at 6:50
  • \$\begingroup\$ @CL I assume MBd somehow refers to the baud rate? According the datasheet is does seem to me that with R17 approaching 1K I might be able to get an acceptable without a second transistor stage (going to try that soon). I can tolerate a drop in gain to some extent - this is a digital signal, with my 5V I need it under 0.4V to register low (if I remember correctly). \$\endgroup\$
    – user34920
    Commented Jul 3, 2017 at 15:53
  • \$\begingroup\$ @user34920 The frequency response measures analog signals (sine waves); for digital signals, you need frequencies higher than the nominal baud rate (five to ten times higher). Have a look at the response time; 20 µs is way too much. \$\endgroup\$
    – CL.
    Commented Jul 3, 2017 at 18:17
  • \$\begingroup\$ @CL The switching time (typical) is 10us according to the datasheet. It also says it is according to JEDEC registered values which means the rise & fall are 0.1 to 0.9 (or the other way around) in pulse response. I need it to make a bit better than 0.32us with pulse response and a larger collector resistor. \$\endgroup\$
    – user34920
    Commented Jul 3, 2017 at 18:34
  • 2
    \$\begingroup\$ @user34920 - MBd == Mega Baud \$\endgroup\$ Commented Jul 3, 2017 at 19:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.