Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Which MCU for translating usb-midi to control LED lighting?

phrenetik

New Member
Hi, I hope this is the correct forum for this question. I've searched for days, not finding specific answers yet.

My project is to send midi notes & velocity data from my electronic drum kit's sound module, via USB, into a MCU, that will then translate those notes/velocity into on/off/brightness for UV LEDs I have installed in the drum shells. I need latency as low as possible, and I need to control 10 different LED units (1 for each drum), 4 of which are UV spotlights that don't have a data input (so I plan to use a relay for on/off signal from the MCU). This means I need at least 5 data pins outgoing, possibly as many as 10.

My limited experience in MCU has been using ESP32's to run LED effects (WLED) in my studio lighting. So I am hoping to use some of the ESP32s-wroom units I have lying about. But i've seen mentions that only S2 or S3 boards can run usb/midi, and i believe these wrooms are S1...not sure.

So, is there a way to do this, perhaps thru a ESP32-s3 with hairless midi or ?
Or should I ditch the ESPs and use a Teensy 3.6 or Arduino Nano33 BLE/Micro/Due or Pi Pico? Trying to keep costs down, but I can upgrade if it means a quality result.

Thanks for any tech advice, and if there's a better forum I should move this to, please lmk.
- another noob-in-need
 
If I buy expensive UV strip that can be segmented, then I need 5 pins: 4 pins for UV spotlights on cymbals, and 1 pin for the segmented led strip that runs through the other 6 drums.
If I use a cheaper 2-pin strip then I need 10 pins out.
 
Easily done with fairly simple cheap PIC's or AVR's, it's all pretty basic stuff and there are plenty of midi examples out there. However, as danadak has asked, how many PWM channels you need is really the deciding factor, as it's best to use all hardware PWM channels if possible.

The MicroChip DMX library uses a device with 4 PWM channels, and one of the demo examples essentially creates a DMX controlled light with four channels, red, green, blue and white. This could easily be changed to use midi instead of DMX,
 
PSOC Midi :


The board to use (CY8CKIT-059) -
1723488898353.png


Regards, Dana.
 
Last edited:
Since you will be sending MIDI notes, Teensy 3.6 will be useful. https://www.pjrc.com/teensy/td_libs_MIDI.html
Only my drum kit's brain will be sending midi notes, the MCU only needs to listen for incoming midi notes and then send out corresponding on/off/brightness signals. But yes, Teensy is on my radar, I just wanted to confirm that I can't/shouldn't try this with my ESP32s-WROOMs I have on my bench (I have 5 left over from previous project). Once I hear a consensus of which MCU is the better path to choose, then I can spend $ (and time learning) on that unit.
Thx!
 
It might be interesting doing a test case ESP32 over wifi, by running the
server on one core, rest of CPU work on the other, and doing a keep alive
function going on the connection. This is tricky in that ESP32 COM is sensitive
to what channel it uses versus other stuff on the network as config by router.

Of course one can think of using a dedicated wireless radio solution.

Not an expert here, maybe there is more info out there on this topic.
 
Any device with an integrated USB-Serial interface should work fine for MIDI with a PC, as long as the USB parameters can be set correctly so it is recognised as a MIDI device.

I've made interfaces with a Seeed Xiao (ARM M0 version).

If you are trying to connect to a USB slave device, things get more complex as you need something with USB OTG capability, as well as the rest of the configuration and enumeration stuff.
A slave device can only connect to one master.

Doesn't the drum kit have real MIDI? That's infinitely easier to work with than the USB so-called MIDI stuff? Any MCU with a serial port will work for that.

(The whole point of real MIDI was that any number of instruments and sound sources could be directly connected together. To me, anyone selling USB devices other than PC adapters as MIDI ought to be locked up, it defeats the entire any-to-any purpose). /rant :woot:
 
Any device with an integrated USB-Serial interface should work fine for MIDI with a PC, as long as the USB parameters can be set correctly so it is recognised as a MIDI device.

I've made interfaces with a Seeed Xiao (ARM M0 version).

If you are trying to connect to a USB slave device, things get more complex as you need something with USB OTG capability, as well as the rest of the configuration and enumeration stuff.
A slave device can only connect to one master.

Doesn't the drum kit have real MIDI? That's infinitely easier to work with than the USB so-called MIDI stuff? Any MCU with a serial port will work for that.

(The whole point of real MIDI was that any number of instruments and sound sources could be directly connected together. To me, anyone selling USB devices other than PC adapters as MIDI ought to be locked up, it defeats the entire any-to-any purpose). /rant :woot:
1. There's no PC involved, just the roland drum kit's sound module sending midi notes to the MCU, which needs to then send on/off/brightness signals to the uv LEDs.
2. Yes, the drum module has the normal midi DIN output port. But I don't see any way to connect the midi cable to the esp32. I don't have enough experience in this arena to proceed without some kind of tutorial, so I am considering reverting to plan B, which is following this guide on a Raspberry Pi/Arduino setup , which I was avoiding because if I need 10 PWM pins, that would require 2-3 Pi's, which becomes too expensive....

Here's the guide:
Pi 3 led drum kit

Since I am a bit overwhelmed with all the jargon and coding, should I try this guy's method? Or stick with the esp32 path and try using hairless-midi and the DIN midi output?
 
Midi is just RS232 type serial data, far simpler to use than USB - you just need to level shift it to feed one of the ESP32 serial ports, or any other microcontrollers - as I mentioned above, multiple hardware PWM channels would be a good idea.

Inputs are normally opto-isolated (to avoid earth loops), you might (or might not) need to do that for your application.

Here are details about midi:

 
These are the conventional MIDI I/O circuits - dead simple! All you need for the MIDI in to the MCU is the H11L1, a resistor and diode.

Edit - ps. It is a current loop system, it must have the opto isolator.

Schematic_MIDI-I-O-Circuits.png
 
Sorry, I should have better explained my limited skillset at the start.
I am ok at basic soldering, and I can cut n paste or flash code packages if I have a tutorial, but every other term in these replies (which are trying to be helpful, and I appreciate) requires 15-45 minutes research for me to grasp, I now have 73 tabs open and I just don't have time to learn the suggested terminology, devices, code, and electrical pathways.
If this was my only project, I'd love to devote a few months to mastering all this, but my brain is scattered with a dozen projects (3 LED lighting projects, home studio remodel, crypto trading, creating 3d avatars for real-time livestreaming, solar system install, and now my wife wants 4-channel dashcams in both cars. lol)

I greatly appreciate the shared info, and I will save this thread for future reference, but I am going with the Pi 3 segmented LED/midi-usb solution from the guide I linked above. That's about the limit of my skills and time, for now.

Thanks!
 
This is an example of a circuit that would do what I think you want, using an STM32 Blue Pill, in this case.
(For an article on MIDI I'm doing for my YT channel).

Most of it is just links from the MCU module to the LEDs.

The MIDI input stuff is at the left - a socket mounted on an offcut of stripboard so it fits the plug-in board, and the optocoupler below. It's not really the ideal opto so it needs a couple more resistors than in the circuit I posted above.

IMG_3373.jpg


The demo program in it lights one of the twelve LEDs depending on the note (from any octave, on any MIDI channel) and velocity. Allocating one specific note on channel 10 only to a LED is far easier.
 
Ok, after crossing some things of my to-do list, I've circled back around to this. I hate feeling like I gave up, lol.
So, I watched some Notes and Volts vids, and Lady Ada's tutorials, and I am ready to try again. But I realize the parts to make the midi input will cost more than just buying one, like below, but I wanted to verify this will work with my Esp32 S3 coming 2moro.

Amazon-com-MIDI-Board-for-R3-AVI-Digital-Interface-Adapter-MIDI-IN-MIDI-OUT-MIDI-THRU-Ports-RU...png


Midi board for R3 AVI
I see the pins for 5v, GND, and Tx/Rx, so this should work, yes?
 
As long as its appropriately connected, it should be fine.

You will likely find that the circuits are similar if not identical to the ones I posted earlier, with the addition of the "through" socket.
 
Just as an ancient anecdote, long ago I wrote an article for the Amiga User Group Magazine, in which I described two simple Midi Interfaces for the Amiga computers. One was one in, three out - the other (VERY!) simple one was just one out, using one or two resistors (I can't remember exactly now) fitted inside a DIN plug.

The article was published, and the single output one was also published in Computer Shopper Magazine, credited to me, even though I wasn't aware of it until someone spotted it and told me.
 
As long as its appropriately connected, it should be fine.

You will likely find that the circuits are similar if not identical to the ones I posted earlier, with the addition of the "through" socket.
Looks like yours has a 6-pin opto, this one has the same 6N138 that Notes n Volts uses (I'm sure they work the same, but it makes me feel better seeing them match, ahaha. )
Your breadboard pic is what drew me back in, this stuff just looks like its fun to learn! Thanks again, I will likely be back in 72 hours crying about some software issue, :arghh:
 

Latest threads

New Articles From Microcontroller Tips

Back
Top