USB MIDI to DMX
Needed to make a DMX controller that would be able to map incoming MIDI data to DMX data. I have built DMX controllers using Arduino UNO boards together with DFRobot DMX shield. This is first time I needed to include a serial interface in the form of USB MIDI.
Most Arduino DMX libraries use serial port for outputting DMX data. As we need serial port for incoming MIDI, this is not an option. DmxSimple-library is doing DMX signal in using timer interrupts which leaves serial port free for serial communication.
Flashing Arduino USB controller with dualmoco firmware will turn the arduino board into a true USB MIDI device, which means you can plug it into any computer and start sending MIDI data into it.
The plan was simple, flash Arduino UNO with dualMoco and make simple Arduino patch that will process incoming MIDI CC-message data into DMX data and jam it into DmxSimple-library that would do the rest.
I managed to get the basic setup work quite easily, but noticed weird behaviour when sending larger portions of MIDI messages in. This included random data sent to DMX channels not used, and some DMX channel values not changing always. Not fully sure where the problem was, ended up modifying and optimizing all parts of the system.
As I first thought that running DMX generating code and serial communication on Arduino was too much, optimized code on DmxSimple library a bit. Thought that it does not make sense to fully check the data everytime DmxSimple.write is called. And also added a methods for starting and stopping DMX signal generation. And a method for debugging that is fetching the buffer containing DMX values sent out. These changes improve (mho) the usage of the library, but turned out that did not help with the actual problem.
Turned out that the actual problem was in dualmoco firmware. Basically if the MIDI data was arriving faster from USB than the serial connection could send out, outgoing byte buffer was wrote over, which caused messages to drop and Frankenstein messages to appear.
While inspecting dualmoco firmware I also noticed that there are issues in the code handling serial to USB MIDI conversion as well. But as I did not need that part, those bits remain unfixed. The firmware works well if there is not too much data to be processed and it is correct. And I don’t think running status is implemented either.
Here are links for updated dualmoco, DmxSimple and the actual Arduino patch. You should be able to use stock DmxSimple as well, but have to remove couple lines from setup()-function. Arduino patch uses Arduino MIDI library.