***************************************************************************************************************************************
I'm not working on RaspiDrums anymore, please check out my new project eXaDrums, it's much better!
***************************************************************************************************************************************
Introduction
As it was mentioned on my website in my previous article, using accelerometers as drum triggers is deadly easy. So why not pushing it further, and try to develop a full drum kit? A few months have passed since I first had the idea of turning my Raspberry Pi into a drum kit, and because I wanted to do something great, I had to learn how to use C++11. That was really helpful, and I think that the project wouldn't be that good if I had used C. In that project, the software part is clearly the heart of the drum module. It's ensuring the communication between an ADC, connected to an accelerometer, and the Raspberry Pi. Then, the data is processed and sent to the soundcard. It sounds simple, and that's the whole point! It is simple. And it's also entirely reconfigurable, which means that you can change the drums sounds, and all sort of parameters to personalise your drum kit. But before I go into more details, I will describe you the hardware, and show you what you need to make your own RaspiDrums.
Presentation of the hardware
General overview
The following figure shows how the thing works.
As you hit the drums, an analogue accelerometer transforms the vibrations of the drum head into an electric signal. This signal is then converted by the ADC in a sequence of bits that depends of the acceleration measured by the accelerometer. The Raspberry Pi reads those bits, and converts them into a value that is proportional to the drum head's acceleration. Thus, the stronger you hit the drum, the higher this number is. This value is used to set the volume of the drum sound, which is sent to the soundcard, and ultimately to your headphones.
Hardware required
So, according to what we just said, here is what you need:
- A Raspberry Pi (tested on B, B+, and 2B)
- An ADC -- I use an ADC click
- An accelerometer -- I use an ADXL377
- An external soundcard (if you want to have a good sound quality)
Attention: the choice of the accelerometer is important, please read next section to understand why! The external soundcard isn't really necessary, but the audio output of the raspi is really bad, so that's up to you. Anyway, if you choose an external soundcard, don't forget to make sure that it is compatible with your Raspberry Pi.
Accelerometer + ADC
As you should know if you read my previous project, the Rhythm coach, accelerometers have a lot of advantages to be used as drum triggers. The most important one is that they don't need any signal conditioning, the output is always very well controlled. Another advantage is that they often come soldered to a breakout board, which makes things a lot easier. Since the Raspberry Pi has only one Spi bus, I decided to use ananalogue accelerometer connected to an analogue to digital converter(ADC). The MCP3204 that I used has 4 inputs, so we can connect up to four drums to the Pi. It is very important to make sure that the accelerometer can take a really high acceleration, as the drummer can reach ±200g very easily.
Usb soundcard
Whether you want to use an external soundcard or not is up to you. It will definitely add some latency, but the integrated soundcard of the raspberry pi is really, really bad... That's unfortunate, but at least, it has a soundcard. I use an Aureon Dual Usb from Terratec, which is compatible with the Pi and has a good audio quality. Further information will be given later, especially about the alsa configuration.
Wiring the whole thing
Here we are, if you've got all the components, you can now start to wire your RaspiDrums. The only tricky part is to wire the ADC to the Pi, so if you need some help, feel free to use the following...
Read more »
Ahh, so this is what you are doing. Very interesting idea, I had not thought to use an accelerometer as a drum sensor. That will definitely get rid of most of the hardware I have designed for piezo conditioning, and probably give a much larger dynamic range that I am getting with piezos.
I wonder what the upper limit of the number of drums that you can support is? I suppose that would depend on the accelerometer + interface... if you are using an external ADC like you show above, you could use multiple ADCs with 4 channels each for more drums (you just need to dedicate a pin for CS on each SPI interface). I2C accelerometers would be easier for low numbers, but would probably be difficult on more than 8 drums (most devices that I see don't give you more than 3 address bits, if that). Plus I2C is much slower than SPI.
It's hard to tell from the video, but I do not see any noticeable latency.
Anyway, very nice work, I will definitely be watching your progress.