DIY drum triggers… reading the sensor scientifically

stevecooley | February 2, 2008 in news | Comments

I’ve learned so much about piezos, microcontrollers, serial data capture, graphing. All from people I’ve never even met in person. Tod E. Kurt’s work on the Arduino MIDI drum kit lead me to want to replicate the project for myself, and I’ve been running into some very tricky problems with the sensors triggering samples two or three times. I got a boost of confidence that I was detecting a real problem thanks to the fine work done by mschaff’s Ardrumo project. Now, thanks very much to Tom Igoe’s article on Sensor Graphing using a tiny arduino sketch, the terminal, and grapher.app, I can actually scientifically diagnose the reason why this is happening.

Using the DIY kick pedal that I’ve been working on…
Img 0218

I was able to capture and graph the data that the sensor is outputting. Here are a few screenshots of the highlights:

Grapherscreensnapz001

This first screenshot shows a good peak, right at the beginning of the strike. Then the ringing begins. If, for instance, I had the threshold set to 500, this would trigger not just one, but *three* midi notes. Ok, but what if I had set the threshold to closer to 750? a big problem with that is that I’m losing a lot of the dynamic quality of the kick pedal. I’d have to hammer on it just to register above the minimum value, and then there’s no way to play it quietly. Every kick would end up being 750 or higher.

But wait, there’s more! Here’s another reading:

Grapherscreensnapz002
Wow, so even if I had set the threshold to 750, I’d *STILL* get three notes off this one kick pedal strike! And then just to mix it up even more:

Grapherscreensnapz003
Here is yet another pattern of the data. a short hop at the beginning well under a reasonable threshold of 250, and then a reading over 500, and then an even higher reading on the “second wave”…

So, the question still remains… how to get a clean sensor reading? Here’s my current idea:

Drum Trigger Sensor Reading
Charting it out helps. Now I just need to try to write the code so it follows this to test it out. Comments and suggestions are welcome. :)

Technorati Tags: , , , , , , , ,

  • Share/Bookmark
  • As for me it's too complicated. You can make it much more easier, using platform that already exist.
  • As for me it's too complicated. You can use much more easier platforms
  • stevecooley
    This short answer is "No, I didn't solve this. :-\"

    Here's the longer answer:
    Scott, that's where I was when I picked up this project. "Shouldn't this be easier?" I kept thinking. Well, I never did get everything I wanted, but I have learned several things since this thread got started. I remembered that I bought a broken alesis drum machine at a garage sale, so figuring that it's junk anyway, I cracked it open and discovered that the triggers weren't piezo sensors. they were just straight digital switches, but there were piezo sensors near the triggers. So their solution was to grab the trigger digitally, and combine that trigger info with a velocity reading from the piezo. I thought that was pretty interesting.

    Second, I realized that I was trying to do waaaay too much at once with waaay not enough experience and understanding of the features I was trying to incorporate. I was trying to do ALL of these things:

    * 4 - 6 triggers
    * all with velocity
    * midi out port
    * hand built kick pedal
    * decent enclosure for the arduino
    * spend as little money as possible
    * battery powered

    And so what I've learned in the time since this post are these things:
    1. battery powered just adds a layer of complexity that doesn't pay off for me.
    2. I didn't go to school for this kind of thing, so the money I spend I think of as being instead of paying for classes.
    3. the enclosure is really the very very very last thing you should ever ever ever worry about.
    4. hand built kick pedals are cool. They're not as good as just buying a kick pedal at guitar center or whatever, but for a web engineer, solving physical engineering problems is fun. That's actually what I was referring to when I said that I'd solved my problem acceptably. I was having problems with one of the parts on my kick pedal because I'd made it out of a wood block, and I solved it be reinforcing that part with metal.
    5. Midi out is another layer of complexity that really doesn't pay off for me, like being battery powered. I don't have a drum sound midi box, so my efforts with are going to end up going from a usb connected device (arduino) to software... so why complicate it by putting a midi port on my box and add a USB midi interface? It's just not sensible in retrospect. The better solution is to do whatever you're going to do on the arduino, pass the data back as serial data, pick it up in processing or max/msp or puredata, and then transform it into midi data from there. We're doing that with our beatseqr project (http://beatseqr.com/blog/) and it's kicking ass all day long. If you're able to program in the arduino IDE, you're in the right ballpark to pick up processing. There's at least one great way to output midi data easily with an external library for processing, and tons of ways to pick up serial data from the arduino. That's really the way to go (for me anyway)...
    6. Regarding 6 analog triggers and velocity... I've become VERY fond of the arduino playground, and I did find a couple of methods that people have posted for smoothing analog values. I haven't tried them out specifically for this kick drum, and I am using one of the methods on my beatseqr project. Here are some links:

    http://www.arduino.cc/playground/Main/Smooth
    http://www.arduino.cc/playground/Main/DigitalSm... (paul badger is awesome)

    I really can't vouch for how this would work with 6 simultaneous triggers for analog values. It's probably doable, but I hit a wall and moved on. Now, don't let my complete lack of training and overcautious use of my money stop you from making progress. :) My inability to solve the problem should not be taken for a good sense of if this problem can be solved at all. It looks like it can. There may be some crafty things you can do using the potentiometer hardware abstraction library along with the debounce/smoothing code in the links above.

    http://www.arduino.cc/playground/Code/Potentiom...
    And I'd highly recommend using the hardware abstraction libraries pretty much all time. They're awesome.

    If things don't work out, and you decide this is something you want, and it's worth some money if not hundreds, check this out:

    http://tomscarff.110mb.com/midi_16drums/midi_16...
  • Scott
    Hey. Thanks for your reply!

    Fortunately my design doesn't have as many requirements as yours -- no hand built kick pedal, enclosure doesn't matter because I'm just going to put it inside the rock revolution chassis, and battery powered won't be an issue if I'm able to use this guy's design - http://shiftmore.blogspot.com/2009/12/calculato... , he hacked a usb-midi adapter for the midi output, and it also powers the arduino through usb! Nice!

    I'm looking at several alternate solutions as well though. I found a program called rb2midi which converts the signals from a rock band 2 controller into MIDI. I've emailed him and he's working with me to test see if the rock revolution controller sends the velocity info to the console (or computer). If that doesn't work, I found a good deal on just the PCB of a rock band 2 controller, which means I should theoretically be able to get that, solder the piezos from the rr controller onto the rb2 controller, and voila, PC thinks I am playing a rb2 controller, which means I can use the rb2midi application. All while spending a lot less than any arduino solution.

    If all that doesn't work, I am interested in this miduino link you posted. Do you know if his hardware has filters built into get rid of the retriggering problems? If you are not sure, I will email him.

    Peace, and thanks again for your valuable input.

    -Scott
  • Scott
    Hey man. I found your blog via the comments on http://todbot.com/blog/2006/10/29/spooky-arduin... and I wanted to ask you some questions about your electronic drum kit and if you were ever able to solve the problems you had.

    I was recently given a "rock revolution" drum kit as a gift. I don't even have a 360 to play the game on, it is just to hack to use as "real" electronic drums. So far I have gotten it working to trigger sounds at full volume by hooking it up to the PC as a 360 controller and using xpadder to map the keys to an audio workstation. Of course that is fun, but I need more flexibility. So I want to wire the piezo's up to an arduino so I can output velocity sensitive MIDI information, but I want to make sure there are no problems with it.

    At first I thought the thing was going to be easy, until I read pretty much the entire comments on todbot's blog and was disturbed by several of the comments, particularly yours -- mentioning you were having problems with multiple triggers. And someone mentioned that they couldn't get it to play more than one sound simultaneously -- obviously not optimal for playing drums.

    I saw Wyatt's post above about Drummaster. That is all well and good, except it adds about $150 additional, which is not something I can afford.

    My question is, were you ever able to tweak your setup using an arduino without the significant problems? You say in one of your comments above that you were looking at hardware solutions, and that you were able to "solve your problem acceptably", but it doesn't say specifically what you did. What did you do, and how much did it cost?

    Do you think it can even be done with just a plain arduino?
    I wonder if not, if I could just somehow simplify the drum master design and simply solder the filters together, not even on a PCB and have them connecting to the arduino?

    I don't know a whole lot about electronics or reading schematics, but I have done a couple of soldering projects in the past. I would like to keep this thing as simple/inexpensive as possible, while still retaining full functionality (i.e. no lag, no weird ghost/multiple triggers, and ability to hit at least 4 pads simultaneously)

    What do you think? Any info about your setup or any input at all would be greatly appreciated.

    Thanks
    -Scott
  • hi,

    found this topic very interesting. here's what i can share about it:
    http://probing.wikidot.com/piezo-analysis-oscil...

    also it really depends on the impact (surface, where on the piezo / pad).

    i am not sure how to implent it (pseudo-code) for an atmega. my goal is your goal: no lag with good velocity response. should i consider using a PIC18F and interrupts?

    pat
  • As a followup to my previous post, I have made a great deal of headway on this project, and currently have a working prototype, with PCBs on order. 8-) If anyone is interested in my approach, take a look at my web page http://drummaster.thecave.homeunix.org. My final solution the filtering problem above was to use a diode, a capacitor, a couple of resistors, and an op amp (for impedance matching) to filter out the ripples, and ensure a quick voltage dropoff after the hit. On the site are schematics as well as some graphs showing the effectiveness of the filter circuits.

    Cheers
  • Hey, all. Thanks very much for your comments! I just realized that there's been activity here because my spam filter has been overly aggressive.

    I think it's probably just time that I step up and just take a look at hardware solutions. The software solutions are good if you only want to have one sensor capturing data, but my current theory is that I'll want at least 4 concurrent sensors reading values and sending midi information (one for each of my appropriate appendages). So shutting down the arduino's ability to do anything while it's just waiting for N milliseconds to pass seems like it might introduce problems. Hardware seems to make a bit more sense, and will push me just a little further. I just need to maybe dig up the electronics learning kits I have and see if there's any baby steps I can make to figure out how to go from circuit board diagrams to actual circuits. I unfortunately don't do this enough for that to be an easy task.

    As far as the spring mechanism goes, I did prototype this and realized I had a recoil problem to solve for. I really didn't know what I was going to do. I figured there'd be a spring in there somewhere, but didn't really know what it was going to look like. I did make a trip to Guitar Center's drum area and looked at a few pedals. :) Why reinvent the wheel? I had plenty of fabrication issues to solve for outside of the overall design help that I ascertained from observation.

    Basically, if you do something like I did, I would recommend fabricating some of the parts out of metal. Specifically the spring block. It has a set screw that needs to really wedge down on the axel in order to create a good solid grip for the spring to counteract on. I tried several types of wood, all of which completely disintegrated along their grain lines. Using a hardwood, I ended up drilling two small holes along the entire height of the piece, perpendicular to the grain, and ran some 4/40 bolts through them to make sure the wood grain wouldn't fail. It works, but metal would probably be a higher build quality if you can get access to a milling machine.

    I do now, but.. I've already solved the problem acceptably, so .. :) why bother, I say.
  • waek
    Hmm. I think you could just pull off doing an envelope follower / detector in software in the Arduino itself. Low-pass filter the input signal to smooth out most of the ringing / ripple (a simple first order lowpass would do, should not chomp too many cpu cycles nor is hard to understand). After that, only allow a new note trigger when the low-passed signal has dropped below certain treshold (hysteresis). Or something like that.

    I'm sure I'll find a major flaw in the above thought after I think more about it, but it's still an idea. Obviously the lowpass filter would also make the first hit transient rise up slower, so there might be some additional delay in triggering - but that's one thing you have to tweak in env followers in any case. I guess I'll have to order Arduino, get some piezo triggers and put my money where my mouth is... I've been interested in the DIY trigger idea in any case and actually stumbled upon this while searching for information.
  • Hi there, i love your pedal, and this weekend i'm planning to build one, but i'm really intrigued by your spring mechanism to return the pedal. Did you take it from a real drum pedal?

    I've made a basic drum-trigger, but i solved this issue with some extra hardware: a peak-detector followed by an op-amp. Basically i took the idea from Paia's web:

    http://www.paia.com/ProdArticles/drumsens.htm

    You can use a greater capacitor and experiment with some resistor values. I also think it could be improved with some other RC and a transistor, but i'm not very deep in electronics. I've commented this out in tod's blog too.

    Good luck!
  • dshay
    I've seen a software fix for this. A simple set/reset variable that wouldn't allow a retrigger for an amount of time defined by user. I tried to look it up but I couldn't find it. Basically, if you look at your graph, you'd be set if you didn't allow double triggering for about six milliseconds or so. The code I saw allowed the person before dumping the code to enter in from 0 to 25 ms the amount of time before the particular pad can trigger again.
  • Hello there,

    I am trying something very similar (making a drum controller 'brain' using Arduino), and I am in search of a solution to this problem. How well does your flowchart algorithm work for this?

    I am currently thinking that a hardware buffering solution may be better for my needs, but that may depend on how well (and efficient) this sort of approach works...

    Cheers
blog comments powered by Disqus