Raspberry Pi Pico Multi MIDI Router – Part 2

One thing I’ve wanted to do since building my Raspberry Pi Pico Multi MIDI Router is build a board a bit like ones DeftAudio produces for the Teensy.  This posts describes a DIY version of a 4+2 IN, 4+2 OUT MIDI board for the Raspberry Pi Pico.

IMG_5747

Warning! I strongly recommend using old or second hand equipment for your experiments.  I am not responsible for any damage to expensive instruments!

These are the key tutorials for the main concepts used in this project:

If you are new to microcontrollers, see the Getting Started pages.

Parts list

  • Raspberry Pi Pico
  • 30×46 Protoboard
  • 8x 5-pin MIDI DIN sockets
  • 4x 6N138 opto-isolators
  • 4x 10Ω resistors
  • 4x 33Ω resistors
  • 4x 220Ω resistors
  • 4x 470Ω resistors
  • 4x 4.7kΩ resistors
  • 4x 1n914 diodes
  • 4x 100uF capacitors
  • Headers and jumper wires

The Circuit

PiPicoMultiMIDIv2_bb

The Raspberry Pi Pico has two UARTs and eight PIO state-machines, and in my previous project, I used these to create six MIDI IN and OUT ports.  In this circuit, I’ve built four MIDI IN and MIDI OUT circuits connected to 5-pin MIDI DIN sockets, and broken out the two UART channels to headers.

With appropriate re-routing you could add MIDI circuits to the two UART channels too if you wanted, but I thought it might be useful to have some basic UART/TTL (albeit 3V3) signals too.

It isn’t easy to see in the diagram, but each MIDI IN circuit at the top is a version of the expanded MIDI IN circuit on the far left of the diagram.

Note that I’m powering the 6N138 from 5V but pulling the output signal to 3V3.  This is the approached I’ve used before and seems to work for me, but you might want to consider using a more natively 3V3 compatible optoisolator.  I just happened to have some extra 6N138s lying around that I couldn’t use for anything else – I ordered SMT versions by mistake so thought I could solder them in here instead!

The MIDI OUT side is just a standard 3V3 compatible MIDI OUT circuit.

In terms of construction, I soldered my Pico directly onto the protoboard, with the majority of the headers poking upwards.  This means that all IO pins are available for connection to other circuits if required.

Here are a few build photos.  The basic order for construction for me was as follows:

  • Solder on the Pico.
  • For each MIDI “channel”:
    • Solder on the 6N138 (temporarily using the MIDI sockets to get the right placement).
    • Solder on the MIDI IN socket.
    • Solder the MIDI IN discrete components.
    • Solder on the MIDI OUT socket.
    • Solder the MIDI OUT resistors.
    • Solder up the GND and 5V to the 6n138.
    • Solder up the 3V3 link to the resistors.
    • Solder up the GND to the MIDI OUT.
    • Solder the PIO/IO pin link to the 6n138 (for RX).
    • Solder the PIO/IO Pin link to the MIDI OUT (for TX).
    • At this point, I checked for shorts, then plugged in the Pico and tested the completed IN/OUT channel before starting on the next one.
  • Add the UART breakout headers.

Note that I’ve left the plastic header supports on most of the header pins.  I’m not using them in the final thing, but leaving them on stops the pins moving when soldering connections to them on the underside during construction.

Finally the breakout headers for the UARTs are added.

I’ve used coloured header pins: white: TX; blue: RX; red: 5V and 3V3; black: GND.

The Code

To test the system as I was building it, I used the same code as before (find it here) running on MicroPython.  At each stage I used a routing table that redirected all messages from the IN port over to the OUT port.  Recall that the UARTs are ports 0 and 1, so the first 5-pin DIN MIDI channel is “port 2”.

MIDIRT = [
   [-1, -1, 2, 2], # Anything on port 2 to port 2
]

The two ports on test were connected via my Roland UM-ONE to my PC. On the PC, I had two instances of MIDIOx running:

  • MIDIOx1: MIDI IN = Roland UM-ONE; MIDI OUT = Microsoft built-in synth.
  • MIDIOx2: MIDI IN = disabled; MIDI OUT = Roland UM-ONE.

Once this was ok, and when each new channel had been shown to work, then the routing itself could be double checked, e.g. with the following:

MIDIRT = [
  [-1, -1, 2, 3], # Anything on port 2 to port 3
  [-1, -1, 3, 2], # Anything on port 3 to port 2
  [-1, -1, 4, 5], # Anything on port 4 to port 5
  [-1, -1, 5, 4], # Anything on port 5 to port 4
]

Finally I repeated the tests with the UART connections, temporarily hooking them up to a 3.3V DIY MIDI Interface.

Find the existing code on GitHub here alongside the required SimpleMIDIDecoder.

Closing Thoughts

This is pretty much there now.  There are a couple of things I’d now like to do software wise to tidy things up:

  • Refactor out the PIO MIDI code into a more reusable “object”.
  • Create a CircuitPython version (although I’ll need to work out how to do PIO on CP first).
  • Add in USB MIDI support too (which will probably require CircuitPython).

From a hardware point of view, I’d really like to see this as a proper PCB at some point in the future, but that might have to be left to someone who knows a bit more about PCB design than me…

Update (Aug 2022): There is now a design for a custom PCB, see: Raspberry Pi Pico Multi MIDI Router – Part 4

If I did do that though, it might be interesting to produce a 2-way and 6-way version and possibly even a version with MIDI TRS connectors too.

Kevin

IMG_5750

One thought on “Raspberry Pi Pico Multi MIDI Router – Part 2

Leave a comment