Arduino MIDI Drum .002

After several iterations I’ve come up with the basis for a functional trigger circuit.

The piezo element (across a resistor) runs into Arduino’s Analog 0 pin, and also feeds a comparator whose reference is supplied by a variable resistor (which is fed to Arduino’s A5 for monitoring). The output of the comparator drives an interrupt routine attached to Arduino’s Digital pin 2 (interrupt 0). That interrupt routine polls the piezo’s value at A0 then returns to the main loop- which does nothing right now, but is where MIDI and other processing will go.

The comparator is to provide trigger thresholding in the analog domain, relieving the Arduino of the overhead necessary to do it in software.

It turns out that the acquisition of the piezo value is fast enough that I can grab a significant series of data points into an array and print the array out to see how the thing actually responds to various events. My first discovery is that its first sample isn’t its peak and that it really does ‘ring’. This confirms my thought that a likely peak detection algorithm is to run the samples until I see a falling value, in which case the prior sample is the peak.

I tried printing the array of sampled values to Processing for graphing but am having port reading problems in Processing.

The other thing I saw is that, across a 1 megohm resistor, the piezo maxes out the Arduino’s input very fast under very small impacts, and that reducing to a 100k resistor brings the response to within a more reasonable range. This suggests that replacing this fixed resistor with a variable will allow me to adjust the overall sensitivity of the final instrument. But I don’t want to have a pot control for every piezo element, so I’ll use a set of digital potentiometers under control of a single rotary encoder. The comparators for each element can all use the same voltage reference, so only a single pot is still required for that function.

So, next steps: set up my first multiplexed piezo array, implement what I now think is the appropriate peak sensing algorithm, and collect the components necessary for my ganged sensitivity controller.

Thanks are due for my work so far to the following sources on Arduino drumkit building and basic comparator use:

http://www.electronicdrums.com/pads/pads2.htm
http://spikenzielabs.com/SpikenzieLabs/DrumKitKit.html
http://todbot.com/blog/2006/10/29/spooky-arduino-projects-4-and-musical-arduino/
http://www.facstaff.bucknell.edu/mastascu/elessonshtml/Interfaces/ConvComp.html
http://home.cogeco.ca/~rpaisley4/Comparators.html

2 Comments

  1. Cool project.

    Does that processor have a PWM timer output? If so you could feed that into a cap to make a reference voltage for the comparator, to have it under control of the processor.

    I’ve used a UART output fed into a cap, picking appropriate characters too, to make a cheap’n’cheerful DAC before too.

  2. In fact it does have a PWM output. Great idea. I’ll implement that for .003 or .004 (I still want the rotary encoder for control) and see how it works. It’ll save me a bunch of ICs.

    Edit: It occurs to me that the voltage from the output of an RC-filtered PWM signal will ripple. I’ll have to see how much and if I care. I’m not sure at this point just how stable my threshold reference really needs to be.

Leave a Comment.