Shop OBEX P1 Docs P2 Docs Learn Events
Combination MIDI In and Out jack — Parallax Forums

Combination MIDI In and Out jack

Mag748Mag748 Posts: 266
edited 2014-03-12 17:02 in General Discussion
Hello,
I am interested in learning about ways I could design a single MIDI jack (5-pin DIN) that could be used for both MIDI In and Out (although not simultaneously). The reason for this is I am designing a small portable midi device that has the ability to "learn" a midi command from a controller, and then play back that command later. Because I want the device to be samall, ideally a single 5-pin DIN jack that could act as the input while "learning" and then switch to an output when transmitting would be perfect. I could not find any resources on this being done before.

I do realize this goes against the MIDI specification as it states there is to be a separate Input and Output, but I think this would be cool anyway. I was thinking about having an analog switch act as a type of relay to switch between the input and output circuits. But if anyone has any input on this, I would greatly appreciate it.

Thanks,
Marcus

Comments

  • kwinnkwinn Posts: 8,697
    edited 2014-02-12 16:01
    Shouldn't be a problem, and an analog switch should not be required. MIDI is transmitted serially at 31.25 kbaud, and switching from output to input should be as simple as disabling the output driver when you want to "learn" a command from another controller.
  • CircuitsoftCircuitsoft Posts: 1,166
    edited 2014-02-12 16:14
    Would this device be battery powered and have no other connections? That would make it much simpler.
  • CircuitsoftCircuitsoft Posts: 1,166
    edited 2014-02-12 16:15
    kwinn - not quite that simple, as MIDI is a current-loop, and receivers should be put in series not parallel.
  • Mag748Mag748 Posts: 266
    edited 2014-02-12 16:47
    Circuitsoft,

    The unit will be battery powered. Which also requires the solution to use little power. The analog switch solution only adds a small quiescent current drain. I haven't looked at how much current the optocoupler would consume as part of the input circuit, but hopefully not much. Getting them to work with the same jack may make that more complicated.
  • kwinnkwinn Posts: 8,697
    edited 2014-02-12 19:54
    kwinn - not quite that simple, as MIDI is a current-loop, and receivers should be put in series not parallel.

    True, not quite as simple as some other communications protocols, but not all that difficult either. For MIDI (that typically runs at +5V) you might be able to put 3 receivers in series but that is about the limit. The attached diagram has the typical MIDI in and out circuits on the left and a combined in/out circuit on the right. As long as the base of the PNP transistor is held at +5V (idle state) it will draw no power and have no effect on the receive circuitry. When sending data pulling the base low will send current through the leds of the internal optoisolator and the connected MIDI receiver. The base of the PNP needs an inverted signal which could be done by the uP or an NPN transistor.

    I have not tested this circuit for MIDI so the resistor values may need to be changed a bit.
  • kwinnkwinn Posts: 8,697
    edited 2014-02-12 19:57
    BTW, it needs to be powered by batteries or an isolated power supply.
  • lanternfishlanternfish Posts: 366
    edited 2014-02-12 22:54
    I may have missed something with kwinn's circuit but wouldn't it be more effective to put an NPN between the pin 5 220R resistor and ground than an NPN trying to transmit data up the pin 4 (Vcc)?
  • Mag748Mag748 Posts: 266
    edited 2014-02-13 10:23
    Kwinn,

    I tested your design in LTSpice (with the change to an NPN transistor to ground as lanternfish pointed out) and it seems to work well. I will go ahead with this circuit in my project.

    MIDI Transceiver.JPG


    Thanks,
    Marcus
    612 x 383 - 43K
  • MMAMMA Posts: 1
    edited 2014-03-12 17:02
    Just FYI, from the perspective of commercial MIDI hardware makers,
    there are some issues with this design that people should be aware
    of.

    First, because 3.3V is connected directly to pin 4 of the combined
    MIDI In/Out jack without a current limiting resistor, a defective
    MIDI cable could short the power supply directly to ground (pin 2).
    Also, if two MIDI devices incorporating this circuit are connected
    together, that would short those power supplies together. A 33 ohm
    1/2 watt current limiting resistor could be added between V1 and
    Pin 4 of the MIDI jack, and R3 could be changed to 10 ohms, but one
    shouldn't assume that circuit to work well under all circumstances
    without further study.

    Second, MIDI outs are supposed to have pin 2 grounded, and MIDI ins
    are supposed to have them unconnected, to prevent ground loops. What
    should this circuit do? One might connect pin 2 to ground via a small
    capacitor (0.1 uF typical) to block DC when used as a MIDI in yet
    provide a low impedance return path for high frequencies when used as
    a MIDI out. But again, that isn't guaranteed to work well under all
    circumstances without further study.

    Respectfully submitted,

    The MIDI Manufacturers Assoc
    www.midi.org
Sign In or Register to comment.