1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

MIDI In/Thru using a 6N138 and a 74HC14

Discussion in 'Microcontrollers' started by Jon Wilder, Feb 25, 2011.

  1. Jon Wilder

    Jon Wilder Active Member

    Joined:
    Oct 22, 2010
    Messages:
    868
    Likes:
    84
    Location:
    Fresno, CA
    As I had questions about this myself I thought I'd post a helpful diagram for anyone who might happen to wonder how to properly hook up a 6N138 optoisolator as a MIDI Input. This diagram shows both the MIDI In and the MIDI Thru. A MIDI Out is identical to a MIDI Thru, however the input to the first Schmitt Trigger inverter is tied to the UART TX rather than the UART RX. This allows you to send the same OR different data from the UART TX to the MIDI Out rather than just mirroring the incoming data from the MIDI In like the MIDI Thru does.

    The 1K resistor from pin 7 to ground is required for the quickest rise/fall time of the output transistor as you only have 32uS per byte. It can be 1K or higher. Some have used values as high as 22K here.

    Hope this helps anyone who has this question -

    [​IMG]
     
    • Like Like x 1
  2. Mr RB

    Mr RB Well-Known Member

    Joined:
    Jul 22, 2008
    Messages:
    4,716
    Likes:
    195
    Location:
    Out there
    Nice work Jon. :)

    If that schematic is your work (I assume it is) then you may want to put your name and date on it, both for your own credit and to also help others who may need to ask questions about it etc, it is nice to know who the author was.
     
  3. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,354
    Likes:
    650
    Location:
    Ex Yorks' Hants UK
  4. dave miyares

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    2
    Likes:
    -10


     
  5. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,615
    Likes:
    697
    Location:
    Derbyshire, UK
    It looks like a standard 1080's circuit for MIDI, and very similar to the one I had published back then (in the Amiga User Group Magazine, and Computer Shopper Magazine). I can't remember what IC I used? (or even if I used transistors?), but mine had one in, one through, and three out - and it used the same 6N138, it was a very popular opto-coupler for MIDI.
     
  6. Jon Wilder

    Jon Wilder Active Member

    Joined:
    Oct 22, 2010
    Messages:
    868
    Likes:
    84
    Location:
    Fresno, CA
    The circuit itself isn't mine although the artwork itself is as I drew these schematics up myself in Express PCB. The circuit came out of a Marshall JMP-1 valve MIDI preamp, and from what research I've found it appears to be a pretty standard hook up for the 6N138 optoisolator for MIDI In.

    What I was hoping to do was have this thread made as a sticky for guys who were wondering how to properly implement a 6N138 optoisolator into a MIDI In circuit. The ones I was finding had pin 7 disconnected and a resistor from pin 8 to the positive rail. However, I had found others who tried that configuration who observed receive errors and such, only to find on a scope that the rising edge of the "1" bits all had a "curve" in them. Tying pin 8 straight to the + rail while installing a resistor to ground on pin 7 seemed to drop the rise time of the output transistor, which sharpened up the rising edge on the "1" bits, which cured the receive errors.
     
    Last edited: Feb 26, 2011
  7. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,615
    Likes:
    697
    Location:
    Derbyshire, UK
    The resistor on pin 7 is pretty important, as you say it speeds things up.

    Bizarrely enough, today I found a MIDI interface I'd built in my bag at work, I'd forgotten it was there :D
     
  8. dave miyares

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    2
    Likes:
    -10


     
  9. Tarahall

    Tarahall New Member

    Joined:
    Mar 8, 2018
    Messages:
    2
    Likes:
    0
    Back in September 1986 (last century :) ETI published a MIDI 4x4 matrix circuit (4 IN - 4 OUT switch selectable) which had pin 7 of the 6n138 unconnected. The PDF from VISHAY for the 6n138 chip also shows pin 7 unconnected in the test circuits. this circuit only uses a single 74LS04 buffer for each MIDI IN . Did you find the addition of the 1k - 4k7 resistor to GND made a discernable difference and did you discover this option from your own experimentation. just curious as I'm resurrecting one of the ETI projects that had been made by a hobbyist (albeit wired incorrectly). regards Gavan.
     
  10. Jon Wilder

    Jon Wilder Active Member

    Joined:
    Oct 22, 2010
    Messages:
    868
    Likes:
    84
    Location:
    Fresno, CA
    It's been quite a few years since I tested this circuit so I may have to redo my tests to confirm. But as I recall, allowing pin 7 to float negatively affected the slew rate of the output, causing a delayed and curved rising edge. Adding a pull down to pin 7 fixed the issue. I always used a 1K pull down.

    I'll throw one together in the next couple of days and retest to confirm my findings.
     
  11. Tarahall

    Tarahall New Member

    Joined:
    Mar 8, 2018
    Messages:
    2
    Likes:
    0
    Just to clarify, the LS04 also provided the buffers for MIDI OUTs. The switch matrix was used to route the MIDI IN buffers to the MIDI OUT buffers as can be seen (hopefully) in the circuit diagram Sorry about the quality of the JPEG but the only copy I could get was from the State Library on microfiche, so I had to scan it into Photoshop and reverse image it.
    regards Gavan.
     

    Attached Files:

  12. Jon Wilder

    Jon Wilder Active Member

    Joined:
    Oct 22, 2010
    Messages:
    868
    Likes:
    84
    Location:
    Fresno, CA
    My thing is...its proven to work and it's one resistor costing less than $0.10. Is this really even worth a discussion?
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice