Electronic drum controller; should be a simple project…

Hi, I want to make my own electronic drum set. The goal is to make a simple set, not to make it into a project (famous last words…). Mechanically I'm making some test pads, that is close to sorted. I found an example project with good explanation:
https://www.youtube.com/watch?v=0MVZJtWbqsU

So I am simply going to buy an Arduino Uno, upload his code on there, done. Add a few pad, number them for the Midi to understand. Maybe design and 3D print a nice case. Next I buy a midi-USB interface, for a few bucks you have a decent one. That allows the signals to reach my laptop, on which I have a Midi drums program running. And I am done! Let’s go smack some pads, pretend I can play the drums!

Oh, wait. The Uno has six analog inputs.
1 Snare drum
2 Snare drum rim
3 Tom one
4 Tom two
5 Floor drum
6 Bass drum
7 Hi-hat
8 Hi-hat clamp
9 Crash cymbal
10 Crash cymbal choke
11 Ride cymbal
12 Ride cymbal choke
That makes twelve. Not six. Can I strike six? Nope. So, I need a different board. The Mega has a lot of pins, 16 analog ones. So, I go with that one. But then I find the 5V Leonardo, which has 12 analog input pins, and is 32 bit and fast, and can do Midi over USB. Hmmm… This is going to be a project, I fear.

So, now you know where I’m coming from and heading to, I have two questions:

  • Does it indeed make sense to use the 5V Leonardo? Or is there an even better option with the given plan?
  • Does changing to this board and adding Midi over USB require drastically changing the code?
    Any input / reference project link is appreciated,

Cheers,

Hugo

What shield will you plug into the Uno? (That's the reason for buying Uno/Mega/Leonardo: they are shield compatible.)

You don't need that if you choose a model of Arduino with "native USB" capability, such as Pro Micro (don't confuse with Pro Mini).

Why do you need analog inputs?

8 bit, same speed as Uno/Mega. But does have native USB.

Thanks for the quick reply. In order of your post:

  • I will make the shield myself. Conditioning the Piezo sensors is fairly simple. (1M trimpot and a 5V Zener to protect the Arduino port. The chokes and Hi-Hat clamp will be different, but still give a 0-5V signal.)
  • The choice of an external Midi to USB was to keep the project a direct copy. Which it's not going to be, now.
  • I want analog inputs as the midi drum software is dynamic and the Piezo can supply a higher signal when hit harder. So, you can play with dynamics (soft and loud). The chokes could be digital, but that's only two out of twelve.
  • Ah, OK, I thought I read 32 bit somewhere, my bad. But it has sufficient analog inputs, and the native USB to skip the separate Midi to USB converter.

Hugo

You are making it one hell of a project.

The thing is that you are trying to scale up a simple project into a much bigger one and that is always difficult no matter in what field you are.

Suppose you make your own bread every day, that is fine and simple. Then you want to open a bread shop, then you need an industrial mixing machine, scheduled flour delivery's , some one to serve in the shop. Premises to rent and so on. Scaling up is hard and requires a lot more things than you originally thought.

So back to you project. You want to measure the analogue peak signal from your sensor several times to track it and find the peak. While you are doing this all the other sensors you have are being neglected, and you could very easily miss a hit. The more sensors you have the more likely you are to miss some hits. This is because each analogue read takes about 100 uS, which might sound fast but is not as fast as you need for all your sensors.

See what I an about scaling up?

I would recommend an Arduino micro, same as a Leonardo but smaller form factor. Using this you can get the MIDI into the computer faster than the normal MIDI rate. But I do think you will have to scale back your expectations of this project or the number of pads you use.

Thanks! Your answer is exactly what I was hoping for. Well, not really in content, but this is the reason I post this here. I don’t know what I don’t know, when it comes to such projects. It does make sense. And it proposes a challenge, as I am not really the scaling-backy or or reducing expectationy-type…

So, back to the drawing board it is. I need to divide and conquer. I need to devise a way to read the sensors and wait for them to debounce while still be allowing other signals to come in. So, first thought, I need 12 small Arduinos each receiving one signal from one Piezo, and convert that to a PWM signal. Next I need a 13th Arduino collecting all 12 signals, convert them into midi signals and push it out the USB port. Hmmm… This sounds like a mammoth task, but there are plenty of really small Arduino compatible processors. Like the ATtiny85. I can make a board (shield) with 12 of them on there (pre-programmed), that do nothing but debounce and convert the sensor signal. If I am not mistaken, PWM signals can be read by any digital input. So I don’t need many analog ports.

OK, the above might take some work, but a two or three pad test set-up is not difficult to set up. But, no doubt, I have overlooked something else. Like latency. Or something else. So, feel free to shoot holes in the idea.

Cheers,

Hugo

Ah, I had it completely the wrong way around. I thought you wanted the drums to play themselves, under midi control!

You will need to prototype and thoroughly test the circuit before designing your own shield. You can get "prototype shields", but these have limited space for components. You may be better off using stripboard/protoboard/tri-pad board or similar for your prototype, and begin by using breadboard for the first attempts. Arduino Micro or Pro Micro will be better suited to breadboards, protoboards and even your final PCB.

Oh, of course anything will be thouroughly tested on a breadboard, first. And I've never had a 'first time right' PCB project, usually all bugs are worked out in version 3 or 4. But that's just me, probably.

The first thought should be 'how many sensors can I successfully use with an Arduino' Whan you have an answer to that you will know how many you need to use. One processor per sensor is a bit overkill.

As a general rule you should stick with one processor if possible, because using more than two makes communications with the 'master' processor difficult. You will have to invent a protocol so that only one 'slave' processor sends information when asked for.

Yes but you then run into the problem of reading a lot of PWM signals at the same time, which is harder to do and more taxing in time than reading analogue values.

Bang.

Again, I really appreciate the input. The reason for the overkill 12 ATtiny85 can do only 1 analog read and one PWM write.

Thinking out loud (well, proverbially): if I 'mechanically' convert the PWM of the ATtiny85 to an analog voltage and have the tiny keep the signal high for 47 ms, I can have the 'master' Arduino check each incoming signal for 2 ms, dealy 2 ms, and check the next. So each cycle of 12 signals takes 48 ms. Not enough to interfere with playing the drums (some dude on Youtube claims 900 bpm drum roll, still that is 67 ms per hit, and it is idiotic and probably untrue), and long enough not to read any signal twice. Can Arduino read so quickly (and process)?

[EDIT]Oh, I read an analog read can be very, very quick, like 100 microseconds (0.1 milliseconds). So analog read, delay 3 ms, and set the signal length of the tiny to 35 ms. Just need a mighty fast PWM to analog conversion, something like this:
https://www.analog.com/en/products/ltc2645.html#product-overview.[/EDIT]

Cheers,

Hugo

Not playing with one sensor it isn't. But you don't want to do that. you are looking at playing 12 sensors. Then add the fact that you do not just want to take one reading but multiple readings so you can track the signal from the sensor and find the size of the peak voltage, then you are stuffed.

Yes I told you that in post #4.

It can be even faster than that if you change the A/D counter pre-scale clock. But it is still not fast enough to do what you need to do.

You are not the first to want to do this and you are not the first to underestimate how difficult it is.

And I haven't even touched on the sensor conditioning you will need to use. That video has a very naive view of what you need to do.

Eh, no? That peak part is taken care of by the ATtiny85-per-signal. That sends out a clean and timed signal. The main processor only reads the clean signals, in a clear sequence, the length of the signal in combination with the qequence length avoids a double-read no-read.

BTW, I've made a proto-pad with a PSR, which gives a nice peak signal (over a voltage divider circuit) when hit and has hardly any ripple after the hit, unlike the piezo. Should help, but the sensor (home made) is too fragile, now. Needs more work.

Hugo

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.