Sunday, September 11, 2011

Little Drummer Boy: a drum machine with real drums

 
"Little Drummer Boy" was my final class project for an embedded microcontroller class. Two Futaba S3004 servos with drumsticks, controlled by a PIC18F4550, play a set of bongos. The frame was built by a teammate from scrap aluminum.

Videos and more info after the jump.


The user interface is based on the classic Roland x0x drum machines like the 909 and 808.


Each "x" is a hit, each "o" is a rest, and the capital letter shows the location of the cursor, which is controlled with the yellow knob. Pressing the button at lower left changes a hit to a rest or vice versa. Each drum has its own programmable pattern with 32 16th notes or rests, and the tempo can be varied from 45 to 220 bpm in real time (though the actual drum hits get weird at the upper end due to servo response time).

I spent quite a while trying to come up with a good way to map linear knob values to logarithmic tempo values. Asking the PIC to calculate natural logs on the fly was too slow. I wrote a short C program to generate a lookup table, but it woudn't fit in RAM and I couldn't figure out the right stream of qualifiers to actually get it into flash ROM (const far char rom come on Microchip!).

Alas, my beautiful lookup table.

For shame, I ended up handcoding it as a long series of if statements. Source code is here if you really care to look.

Little Drummer Boy worked well enough and was fun to play with. I programmed a mellow beat for our team presentation, and we were asked to start with our demo instead of our description. I started up the beat and let it play while we showed off the interface. After a few minutes the half-dozen engineering faculty were all nodding along, then everyone sort of stopped talking (but kept nodding)... after about 30 seconds someone said, "Oh! Guess we better have you explain it now."

I briefly thought about trying to make Little Drummer Boy more physically robust, or adding MIDI and a more playable interface with drum pads. Eventually the frame just took up too much room and I dismantled it.

Here are some videos of the lil' guy in action... I'd forgotten how squeaky those servos were!

A few seconds of a basic beat:   

 

And a longer video that shows the interface in action:






No comments:

Post a Comment