# Is it possible to use a DPDT switch to swap 2 inputs and 2 outputs?

I want to create a passive device with two MIDI inputs and two MIDI outputs, with a switch that has two states. In the first state, input 1 is connected to output 1, and input 2 is connected to output 2. The other state swaps them, with input 1 connected to output 2 and input 2 connected to output 1.

Each input/output has a positive pin, a negative pin, and a ground/shield. I figure I can just wire the grounds together, but I'm trying to figure out if it's possible to shuffle the positive and negative inputs/outputs around with a DPDT switch and some diode trickery, or if I need something less common like a 4PDT switch (or something else entirely).

I would love to figure it out with just a DPDT switch if it's even theoretically possible, but I'm a newbie at electrical engineering, and I don't know very many of the seemingly common tricks to control flow with diodes and such.

You need 4PDT switch, because MIDI is a balanced current loop. So two pins must be switched from each connector, and you have two connectors.

• Just curious, but what do you mean by "balanced current loop"? As far as I know it is an unbalanced current limited drive to an LED in the receiving end. May 29 '19 at 18:21
• On MIDI out connector, there is a TX+ pin with 220 ohms to 5V, TX- pin with 220 ohms to e.g. open-drain UART TXD output, and ground. Wiring on cable is twisted pair and ground is only used for twisted pair shield. MIDI input connector is galvanically isolated with opto-isolator and 220 ohms so ground pin is unconnected. May 29 '19 at 18:28
• Your description matches the schematic on Wikipedia's MIDI. In Balanced line Wikipedia has the definition "In telecommunications and professional audio, a balanced line or balanced signal pair is a transmission line consisting of two conductors of the same type, each of which have equal impedances along their lengths and equal impedances to ground and to other circuits." Interesting. I wouldn't have considered MIDI balanced but by that definition then "maybe". May 29 '19 at 19:19
• Indeed, that is the definition, having balanced impedances. A balanced line like for professional audio does not require transmitting antiphase voltages, it is perfectly OK to drive a signal only to the +ve or -ve pin in a balanced audio connection, as long as the impedances are identical so any interference couples identically to both wires and gets cancelled out at the receiver. May 29 '19 at 21:17
• If one goes out of spec and omits the optoisolator, or otherwise configures optoisolator from dedicated/isolated 5V supply, only 1 wire is enough. May 30 '19 at 4:55

simulate this circuit – Schematic created using CircuitLab

Figure 1. Implementation using a 4-pole 2-way switch.

Figure 2. The 12-way rotary switches such as those made by Lorlin are available in 2-pole, 3-pole, 4-pole and 6-pole versions. A tabbed washer under the lock-nut limits the number of switch positions as required.

• Thanks for the diagram. Using a 4PDT switch was the most straightforward approach I could think of, but I couldn't help but wonder if something could be pulled off with a DPDT and some kind of clever network of diodes (partly because I already have some DPDT switches). But even figuring out if such an implementation was possible was over my head.
– DLH
May 29 '19 at 18:28

I think it can be done:

O1 I1 O2
O2 I2 O1
<--++-->


If this is a balanced line or similar and you need to switch 2 lines per channel, a 4PDT may be required. Or one can glue two DPDT sliding switches together.

From this page https://learn.sparkfun.com/tutorials/midi-tutorial/hardware--electronic-implementation it looks like MIDI is a 1 wire protocol, so the 5V wire may not always be required, depending on how you set it up.

• No MIDI is a current loop on wire. It can't be done with DPDT. May 29 '19 at 18:20
• Your little diagram is confusing. I don't understand what it is supposed to mean. Perhaps you should use a standard switch symbol and a proper schematic. May 29 '19 at 18:52

simulate this circuit – Schematic created using CircuitLab

• You might want to label your inputs and outputs. It looks as though you are only switching one wire - the positive? - from each device and assuming that passing the grounds through will be OK (but you don't show the ground pass-through so the circuit is incomplete). One of the design aspects of MIDI is that the devices are all opto-isolated to prevent ground loops so your answer should address why you think this won't be a problem. May 29 '19 at 17:59