Tuesday, August 6, 2013

Building a Pseudo Theremin

Here's how I built a simple musical instrument with Sharp IR Rangers to demo my A2D boards.

It was the night before the big robot expo at Wings Over the Rockies museum and I needed another exhibit. In the wee hours I breadboarded a Theremin. Wait. Theremin? What is it? How does it work?

It generates a tone with variable pitch. It's a digital slide whistle. One Sharp GP2D12 controls pitch, and a GP2D120X turns the sound on/off. The sensors point up from the table and you position your hands over the rangers for control.

The original version averaged 10-bit analog to digital conversions. The converted signal was still too noisy and it wasn't very responsive.

Months later I'm revisiting the pseudo-theremine to see if these A2D boards are any good. The new version uses...
  • Sharp IR Rangers with A2D boards to lower the noise floor and raise resolution,
  • An mbed with simple I2C master API (any MCU that can talk I2C works), and
  • A simple BJT amplifier driving a standard speaker with some filtering caps.
On the down side, the supply noise off the Sharp rangers still makes it hum when it's off but not as bad as before. The good news is that the A2D's oversampling and filtering reduces uncorrelated noise and increases resolution (just like AN121.pdf says) so the ranger signals are steadier and more precise. This version does 64x oversampling (13 bits) but the instrument responds to my hand movements with only a little lag compared to simple ADC averaging.

Here's a demo video to show what I mean.


The source code for the project is here on mbed.org excerpted below. The A2D code is here on Google Code.

The heart of the mbed code simply reads 16-bit values from each A2D board and uses that to turn the tone on or off and set its pitch (pwm frequency).

Notice how simple the protocol is? Read two bytes. That's it. Do that over and over again. Configuring the A2D only requires sending a register and its value.


Here's how I wired up the hardware on a breadboard. I'm running the I2C pullups to 3.3V to protect the mbed, while the A2D and ranger are powered from 5V.

Schematic as follows:

The A2D board's Eagle files are on the Google Code repository linked above.

Your Turn

So if you had an A2D board you could whip up this pseudo-theremin in no time. Or build something else cool. Keep an eye out for them to appear for sale on Tindie.

1 comment:

  1. Michael,

    I'm really looking forward to getting my hands on a couple of these, I have a project that they will be perfect for them.

    Keep up the good work!



Note: Only a member of this blog may post a comment.