Watching 25 piezo sensors -- Or: How I want to make a Xylophone

I am looking to make an Arduino powered Xylophone with 25 keys for a friend with some mobility issues.

I plan on using piezo sensors to watch for hammer action, with (eventually) up to two hammers used at once.

I've looked at the Mega board, and I can get 25 analog inputs by chaining the boards together, but I wasn't sure if that was the best approach in this case.

My questions are:

  • Are piezo sensors sensitive enough to be velocity sensitive, or will I simply receive (value > threshhold == stroke)?
  • For a one-off design by someone better at software than hardware, is using two Megas the best approach? Using analog shift-registered seemed like over-design, but I'm open to ideas
  • If I do use two Arduinos, what is the best way to have them message? I can pass a binary (strike == true) through digital pins, but I'd rather carry velocity information if I can. Would I2C cause me to miss incoming strikes by delays?
  • In the next gen of the design (yes, I'm thinking ahead already), I'd like LEDs under the keys so someone can play 'follow the lights to learn the tune. With a known limit of 3 LEDs being on a time, is multiplexing the best option?

A piezo element is a little velocity/force sensitive, but it is very inaccurate.
How are you using the piezo element ? Glued to the bottom of some wood ?

FSR (Force Senstive Resistors) are better for this, but they are expensive.

Do you know the soft-pots ? They are also on the Sparkfun page. There are also larger versions of those, they can be played like a piano.

Arduino Mega 2560 has 16 analog inputs. http://arduino.cc/en/Main/arduinoBoardMega2560

Arduino Leonardo has 12 analog inputs.
Arduino Pro Mini has 8 analog inputs (but no usb connector, you need extra hardware to upload a sketch).

They can be connected to each other with a serial port, but also with SPI or I2C or just digital lines parallel. The easiest is a few small Arduino boards to detect the piezo with a single central unit (a Mega board) and connect all of them with a serial ports at 115k baud. That would be almost as if the small Arduino boards are sending midi commands to the central unit.
That would make it easier to add leds and make it modular. You can make 4 the same modules for 32 piezo elements.

Using more than one board slows it down. A mux is a faster.
This is a very interesting page by Nick Gammon : Gammon Forum : Electronics : Microprocessors : 74HC4051 multiplexer / demultiplexer
The '4051' can select one of 8 pins and connect that to the common pin. Three digital signals (A,B,C) are used to select the one of the 8 pins.
So you can use any Arduino, use 4 of those mux, and 4 analog inputs. You could connect 3 digital pins to all the A,B,C of the four mux.
Or perhaps you could use just a single analog input when the INH/Enable pin is also used.

Thank you for the information!

The first version of the Xylophone will use the peizo attached to the bottom of a piece of plexiglass. (Weight is a major concern in this project.)

Sounds like I'm going to have to give up the velocity, at least for the first round. Let me limit the scope of this project to something I can handle.

Never heard of the FSRs before. Those sound like a great choice, but yea, a little pricey. I'll save that for Rev2.

I'm reading up on the MUX info linked to as well. That's adding thought-fodder.

Hi, can I suggest you try just one piezo unit, get it working then goto as many peizo as you have inputs, to prove the concept, and get sounds, then proceed to the multiplexing the input.
One stage a time, keeping backups by saving frequently and modifying sketch names, ie XY_Ver1.0, then XY_Ver1.1.
Do this often so if you stuff up bigtime, and it can happen, you can back track.
Even subtle changes gets a new filename.

We only have so much hair to pull out.

Tom.... :slight_smile:

I can see this as a great project and not just for piezo inputs.

Thanks for the advice, Tom.

I've got about 30 years of software development under my belt -- everything from writing writing raw 6502 machine language to front-end dev stuff.

I've got the software side of this process down, I think. I've got my own SVN repo set up, every working state gets commited.

I'm just trying to prove the old adage that there is nothing in the world more dangerous than a computer programmer with a screwdriver.

Hi, no problems, this sort of thing can be adapted for all sorts of inputs, for all sorts of applications, interactive art, in your project various disabilities.
Force, switch or optical inputs.

Tom.... :slight_smile: