It’s been a while since I built a MIDI module… actually, I need the “raw electronics” from a MIDI In/Out interface for a project I’m planning, and wanted it to support either 3.3V or 5V microcontrollers, so this little project was the result.
While I was at it, I thought I’d add in a low-pass filter for PWM style, microcontroller audio output filtering, but this is optional really.
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:
- Arduino Simple MIDI Controller
- Simple MIDI Monitor – part 2
- MIDI, MicroPython and the Raspberry Pi Pico
- MIDI In for 3.3V Microcontrollers
If you are new to Arduino, see the Getting Started pages.
- H11L1 optoisolator
- 2x 150Ω resistor (optional)
- 3x 220Ω resistor
- 1x 270Ω resistor (optional)
- 1x 1kΩ resistor
- 1x 1N914 diode
- 2x 5-pin 180 DIN sockets
- 1x 3.5mm stereo jack socket (optional)
- 1x 68nF capacitor (optional)
- 1x 100nF capacitor
- 1x 10uF non-polar capacitor (optional)
- 11 rows x 12 holes stripboard (7 rows if not adding the filter)
- 24 rows x 10 holes stripboard
The connections are as follows:
- Top left: to MIDI In connector
- Mid left: to MIDI Out connector
- Bottom left: to audio out connector (optional)
- Top right: to power and RX/TX of the microcontroller
- Bottom right: to PWM out and GND from the microcontroller (optional)
There are three distinct sections to this circuit:
- Top left: MIDI In
- Middle: MIDI Out
- Bottom: low-pass filter (optional)
The MIDI in circuit is essentially the same as all previous designs. I’m using the H11L1 once again for its support for either 3.3V or 5V operation. The “to RX” line is pulled high to the power rail with a 1k resistor so should always operate at the VCC power supplied to the module.
The MIDI out circuit is again the same as used many times before, but it includes jumpers to select a different set of resistors to support either 5V operation (horizontally – selecting two 220Ω resistors) or 3.3V operation (vertically – selecting 10Ω and 33Ω).
The bottom section is the optional filter circuit, again as now used many times before.
As the output level could either be 5V or 3.3V I wanted the potential divider to still output a useful line-level type voltage for both. My (typically simplistic, remember I’m not really an electronics person) calculations were as follows:
Vout = 5V x 75 / (75 + 270) = 1.09V
Vout = 3.3V x 150 / (150 + 270) = 1.18V
Note these are 0 to ~1.1V, which will become +/- 0.55V (or thereabouts) when the DC bias is removed by the 10uF capacitor. So ideally, I’d use a 150Ω resistor when used with 3.3V and a 75Ω resistor when used with 5V. But if you recall, two 150Ω resistors in parallel is the same as one 75Ω resistor, so in my circuit I used two 150Ω resistors, with one of them only linked into the circuit via a jumper.
In terms of the filter operation, I was basically building the Mozzi Output Circuit but revisited the frequency calculations with a few different capacitor values. In the end I opted for the following (again, a very hand-wavy) calculation:
Freq = 1 / 2πRC = 1 / (2π * 270 * 68nF) = approx 9kHz
Which is more than the 5.8kHz of the original filter, but possibly slightly better for higher audio frequencies.
Building the Circuit
One thing you can’t easily see in the circuit diagram are the track breaks. Essentially, they occur underneath the H11L1 and four MIDI out resistors, and “between” the three jumpers that are present in-line with the tracks. Here is a view of the board with no components.
Note: as is typical for these types of images, the first is the “looking through the board” version where you should imagine looking from the top (component side), through the board, to see the tracks on the other side. But to help spot where everything goes, I’ve included a reversed version, which is the actual view from the bottom/track side of the board.
Here are some photos from my build. Normally I’d take a “lowest components first” approach, but as I was putting this together I really needed those sockets and headers on for reference, so did those first!
Then I added the jumpers. Note the pattern of cuts in the tracks in the photo above, which should all be aligned underneath each pair of jumpers. Then I added the resistors and diode (the observant among you might notice the diode is in the wrong two holes and the wrong way round in these photos! I spotted afterwards while checking… the circuit diagram is the right way round).
Finally the capacitors and connecting links were added, including a solder bridge linking the bottom jumper/resistor to the next track in (the blue link in the circuit diagram), and two solder bridges to connect the pairs of MIDI out resistors together on the microcontroller side (the short red and ochre links in the diagram).
Note how the ground link (black) was made on the underside of the board.
Also note how the non-polar capacitor was bent over “back on itself”. It is still poked through holes in the second track in, either side of that track break, but the legs were extended to have it all fit on the board.
In the first diagram you can see the three jumpers set horizontally for 5V operation. In the last photo, with the optoisolator added, you can see the three jumpers in the vertical 3.3V operation.
Additional Breakout Board
This is also optional, but I needed a simple breakout board for the sockets to allow me to test everything. This is nothing more than a link to the three sockets – two MIDI and one audio – with header connections in the same order as the main board – mostly so I’m not trying to remember which pins to hook up on the MIDI connectors.
Here is what it looks like.
And here you can see it hooked up to the main board and then in use.
There is no code associated with this build, but I tested it with a range of other projects and microcontrollers.
As I say, I needed a MIDI In/Out module for a future project, but I’m quite pleased with how this one has turned out and am tempted to make a spare…