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 microcontroller 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 used in Rev 1 hardware is to use a rectifier plus a low pass filter to smooth the waveform in hardware, and rely on software only to smooth out exceptional situations.

The hardware filter for Rev 1 that 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

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.

However, this approach is not perfect. The biggest problem is the sensing of very light strikes (ghost hits on the snare, for instance). Due to the voltage drop across the diode, there was a hard lower limit in the value which could be read. Furthermore, the digital trigger was configured in hardware to prevent any strike lower than 0.3v from being read. Another issue is that the falloff time is reliant on hardware - e.g. the time that it takes for the signal to fall to zero. This gives an absolute lower limit on the speed of detection. Reliably reading drum rolls was difficult.

The Rev 2 approach is to use a peak voltage detection circuit to hold the voltage at the peak when the microcontroller is sampling; then, once the value has been read the microcontroller can trigger a drain to reset the circuit.

A simplified example of how this works can be seen below, and at the Falstad circuit simulator:

circuit simulator screenshot showing simple peak detection circuit