Midi Moose. |
Midi Issues Everywhere
After finalizing the Acid Moose 303 clone build my midi usage increased significantly. So did my midi problems. Unfortunately I just couldn't get the Acid Moose midi interface working reliably. Sending too many messages made it freeze and the whole device had to be rebooted. I tried changing opto-isolators, crystals, pretty much everything around the pic microcontroller but nothing helped. Anything more than simple note on and note off messages would make it fail. Unfortunately that midi implementation is significant part of the sound because it mimics many 303 peculiarities so changing to another microcontroller implementation wasn't an option either. Needless to say the source code is not available. I finally gave up debugging it and decided to add a midi filter in front of it to throw out everything except the bare minumum of needed midi note messages.
Around the same time I also bought an Elektron Digitakt sequencer/sampler. It provides 8 tracks of midi sequencing power but only one midi out port. Unfortunately nearly all of my midi devices are missing the midi thru port so I couldn't connect more than one device to Digitakt.
Yet Another Moose to the Rescue!
I decided to sort out both of these midi problems at once. There's plenty of almost suitable midi boxes for sale but a DIY project is so much more fun! These midi issues offered me a perfect starting point for a project with some custom design. I would love to do some electronics design and programming for all of my projects but usually there's always some readymade kit that's done ten times better than I ever have time to do so I end up building projects designed by somebody else.
I used to do embedded software for a living but have now ended up writing mostly just javascript at work. To make sure I don't forget all the lovely low level C programming I've been fooling around with Arduino every now and then at my spare time. I also recently read a book about using Arduino for music applications: https://www.amazon.com/Arduino-Musicians-Complete-Teensy-Microcontrollers/dp/0199309329 It really wasn't targeted for me as I already know electronics and embedded programming but there's some interesting projects and plenty of essential information about Arduino, midi and audio circuits gathered in one book.
I needed midi thru box for sharing Midi from Digitakt to many devices and a filter to make Acid moose behave properly. Everything should be stuffed into one box for convenience. Midi thru is easy to do with an opto-isolator and buffers. Arduino can handle midi filtering.
I used to do embedded software for a living but have now ended up writing mostly just javascript at work. To make sure I don't forget all the lovely low level C programming I've been fooling around with Arduino every now and then at my spare time. I also recently read a book about using Arduino for music applications: https://www.amazon.com/Arduino-Musicians-Complete-Teensy-Microcontrollers/dp/0199309329 It really wasn't targeted for me as I already know electronics and embedded programming but there's some interesting projects and plenty of essential information about Arduino, midi and audio circuits gathered in one book.
I needed midi thru box for sharing Midi from Digitakt to many devices and a filter to make Acid moose behave properly. Everything should be stuffed into one box for convenience. Midi thru is easy to do with an opto-isolator and buffers. Arduino can handle midi filtering.
Midi Thru
I started experimenting with Midi thru. Most of the circuits seem to be implemented with a 6n137 or 6n138 opto-isolator acting as midi in and then some kind of buffer driving the outputs. I took this schematic from Papareil Synth Labs as a starting point and started adding components to a strip board: http://m.bareille.free.fr/midithrubox/midithrubox.htm
I happened to have some 6n138 optos around so I used one of those. There's a catch here that many (also the schematic above) seem to miss. 6n137 output contains a logic gate and pin 7 is left unconnected. 6n138 however has a darlington pair in the output and a resistor is needed from pin 7 to ground to make it work properly. It usually somewhat works also without but you may have issues in some cases. In general I would advice to use 6n137.
The number of midi thru outputs can be increased if needed. I ended up using 4 outputs because that was easily doable with the 6 schmitt triggers available in the 74hc14 IC. Adding more would have required adding another IC chip. I will probably never need more than 4 outputs anyway.
Unfortunately Arduino Uno has only one hardware UART. It's normally used for programming the chip and for debugging. As I needed to use it for midi I had to figure out a way to work around this limitation. I had to disconnect tx and rx cables every time I wrote a new binary to the chip. I also configured a software UART for printing debug messages to computer screen.
I used a library for the midi stuff so the software is trivial. Just some callbacks to handle incoming data and if clauses to throw away unrelated midi messages. I also decided to map the channels again as both my modular synth and Acid Moose are working on channels 1 and 2 and neither of them has an easy way to change it. Midi Moose software now listens on channels 15 and 16 and sends those messages to channels 1 and 2 so that Acid Moose receives them normally. See the code for details: https://github.com/tvainio/midimoose
After I got the software working I wanted to get rid of the arduino board. The atmega328 microcontroller in arduino uno doesn't require much additional circuitry to work so I added a 16mhz xtal, some resistors and capacitors and an IC socket to the board. After that I just removed the atmega chip from the Uno and placed it directly to my custom board. If I ever need to update the software I can move it back to the Uno for a new software. I learned this idea from the "Arduino for Musicians" book. Of course I ordered some new atmegas to keep the Uno working also after the original brain had been donated to this project.
I happened to have some 6n138 optos around so I used one of those. There's a catch here that many (also the schematic above) seem to miss. 6n137 output contains a logic gate and pin 7 is left unconnected. 6n138 however has a darlington pair in the output and a resistor is needed from pin 7 to ground to make it work properly. It usually somewhat works also without but you may have issues in some cases. In general I would advice to use 6n137.
The number of midi thru outputs can be increased if needed. I ended up using 4 outputs because that was easily doable with the 6 schmitt triggers available in the 74hc14 IC. Adding more would have required adding another IC chip. I will probably never need more than 4 outputs anyway.
Added a Midi in section with 6n138 opto and a 74hc14 hex schmitt trigger for the outputs. |
One port Midi thru working. Not very useful yet! |
Power Considerations
Some midi thru boxes do not require a power supply at all because a small amount of current can be drawn from the midi output. Originally all midi outputs were done with 5V power supplies but nowadays more and more devices are operating with 3.3V. This can cause issues with these boxes without a proper power supply. I also didn't have a clear idea what kind of circuitry I would end up adding to this box so I decided to play it safe and used an external power supply. I used the traditional 9V guitar pedal power supply convention because I might add some effects to the signal chain. Another option would have been to steal 5V from my modular synth but that would have meant extra trouble if I ever wanted to use this system outside my own desk.Adding the Arduino
After the pure hardware midi thru part was working I started experimenting with Arduino. I connected an Arduino Uno to the board. I first had a switch on the board for selecting between direct midi thru output and arduino output but eventually ended up removing the switch and driving one midi output directly from arduino and rest of them as direct midi thru.Arduino TX and RX connected to the board. |
I used a library for the midi stuff so the software is trivial. Just some callbacks to handle incoming data and if clauses to throw away unrelated midi messages. I also decided to map the channels again as both my modular synth and Acid Moose are working on channels 1 and 2 and neither of them has an easy way to change it. Midi Moose software now listens on channels 15 and 16 and sends those messages to channels 1 and 2 so that Acid Moose receives them normally. See the code for details: https://github.com/tvainio/midimoose
Debugging. |
After I got the software working I wanted to get rid of the arduino board. The atmega328 microcontroller in arduino uno doesn't require much additional circuitry to work so I added a 16mhz xtal, some resistors and capacitors and an IC socket to the board. After that I just removed the atmega chip from the Uno and placed it directly to my custom board. If I ever need to update the software I can move it back to the Uno for a new software. I learned this idea from the "Arduino for Musicians" book. Of course I ordered some new atmegas to keep the Uno working also after the original brain had been donated to this project.
I probably should have used some kind of buffering for the midi output but that would have required 2 schmitt triggers to invert the signal twice. I would have needed another 74hc14 ic to the board or to reduce midi thru outputs to just 2. After experimenting with directly driving the midi output from the microcontroller TX it seemed to work fine so I just left it like that.
More debugging with Acid Moose. |
Ready to move the microcontroller into it's new home. |
Atmega in place. Almost ready! |
Enclosure
I considered building a fancy wooden enclosure for the midi box but ended up using a cheap plastic box originally meant for electrical installations. It's ugly as hell but happened to be just the right size for the pcb and midi connectors. In the end it turned out to match really nicely with the acid moose!
Big moose! Little moose! |
Where's the Schematic? Show me the Schematic!
I usually don't bother designing the schematic beforehand. I only have a vague idea and start soldering components and work out the details while I go. This is not the best way to do things but I kind of like it. One problem with this is that after the enclosure is closed I forget what I actually did. It's also impossible for anybody else to follow my footsteps because all the details are missing.
This time I decided to draw the schematic with a proper tool. After some googling I settled on Kicad and learned the basics of the software. Here's the result as pdf: https://github.com/tvainio/midimoose/blob/master/hardware/midimoose_schematic.pdf Kicad files can be found in the same directory if anyone is willing to do something with them. Please note that I drew the schematic afterwards so it might contain errors.
I have a long term goal to learn to design my own PCBs in a professional way so that they can be ordered from a factory. This schematic exercise served as a good intermediate step towards the goal. I'll probably try designing a PCB as well when a suitable project pops up.
Conclusion
I'm really happy with this little problem solver box. I'm now able to sequence my modular synth, Waldorf Blofeld and Acid moose at the same time with Digitakt. I'm also really happy with this project because it is so unique. I made lots of design choices and wrote custom software to suit my own needs and also learned several of new skills: How to write arduino midi software, how to draw schematics with Kicad and how to use opto-isolators properly.
Comments
Post a Comment