Drum Master

DIY Electronic Drum Brain


Design and Theory

The core problem which Drum Master addresses is that of sensing when you hit a drum pad, and passing that information to the computer so that it can do something about it (i.e., play a sound). The generally accepted method for doing this is through the use of Piezo Electric transducers.

Piezo Theory (and the Problems Encountered When Reading Them)

Disclaimer: IANAPTG (I Am Not A Piezo Theory Guy). If you see something here which is inaccurate, please let me know and I will change it. This information has been mostly assembled from reading various web pages, and combined with empirical data I collected from experimentation.

When a piezo electric sensor is struck, it generates a voltage pulse, depending on the velocity of the strike. See Wikipedia for more details on why this happens. The signal generated by this looks like a diminishing sine wave, over a period of about 200 ms (at least for the piezos I am using). Here is a graph of a sample strike:

Graph showing the waveform of an unfiltered Piezo strike

The problem with trying to read this is that it is difficult to get consistent readings. Depending on the exact time at which a reading is taken, you may get wildly different results. For instance, if you take the reading at the 2 ms mark, you will read value 611; at 6 ms you will read 0; at 10 ms you will read 541, etc. Since there is no guarantee that the arduino will read the value at a peak, we must somehow address this and debounce the signal.

One possible method to approach this is using software. If you do repeated analog reads over a period of time (say, 25 ms), you can take the maximum reading, weighted average, etc, and use that value. I did some experiments with this method, and while it works better than using no software debouncing at all, it still is not as reliable as I would like - some hits are missed completely, and others are not reading a consistent velocity value for similar strength hits.

The solution I finally decided on is to do the filtering in hardware, and rely on software only to smooth out exceptional situations. This appraoch seems to work very well, and gives consistent results all the time.

The hardware filter I came up with consists of two resistors, a capacitor, and a signal diode. (Check out the schematics page for details on how this is laid out.) When using this filter, you can get a waveform as follows:

Graph showing the waveform of a filtered Piezo strike

(Note that I modified the values of the data set for this graph slightly, to adjust the velocity of the strike to be closer to the first one. Also note that the slope of the graph as the voltage drops will depend on the value of resistor RR6. When generating this particular graph, I used different resistor values from what I finally ended up using. The final design has a steeper drop-off; it gets to zero after about 10ms, instead of the 20ms as seen here. The general shape of the graph is accurate, though.)

As you can see, the 'ringing' of the sine wave is removed, and the signal falls off quickly so as to avoid any double triggers. Note that we ignore values under about 0.3 volts (the voltage drop of a schottkey diode), due to the way we set up the op amp trigger, on the trigger board - as you can see from the graph, the signal falls below this value at about 20ms. Compare that to about 150 ms on the unfiltered version.