measure press force and length of press

Hi Guys
I want to know how hard a button was pressed and for how long.
Currently I am gluing piezo transducers onto tactile switches so that when the button is pressed a reading for how hard it was pressed is also measured. However I want a key for every letter of the alphabet - i.e 26, and it is a nightmare to make.
So then I thought, smd button, smd piezo transducer, soldered next to each other and a bit of plastic that goes over both, so when you press the plastic, both are pressed.
But smd piezo transducers are really expensive - like a quid each!!!! anyone know of cheap ones?

OR can anyone think of another way to do this, I dont really want to be spending more than 50 pence a button in electronic parts - normal piezo transducers are like 10pence, this is the first time the smd version has turned out to be MUCH more expensive.
Or have I over looked something and there is some other way of doing this. I have a midi keyboard with pressure sensitive pads that can also measure how long it is pressed for aswell.
Another option I thought of, was to have two buttons, and the same bit of plastic over both, but not quite touching the second button when it is not pressed, then measure the time between the first and second being turned on and relate that in some way to how quickly the button was pressed.

Anyone got any good ideas???
Thanks

Maybe you can do/buy something like this Procrastineering - Project blog for Johnny Chung Lee: Pressure Sensitive Keyboard

Does a piezo transducer give you the information you need (about speed/pressure/whatever)? Is it practical to scale that up to the number of buttons you need? I mean, is the Arduino capable of handling that number of buttons?

Can you think of any way to physically insert the piezo sensor between the key top and the key switch? Or even glued on top of the key top? That would avoid awkward schemes involving plastic bridging multiple devices. Is there any chance of scrounging a broken midi keyboard that has the type of key sensors you need and reusing them?

Im using a mega2560. THe piezos are connected to multiplexer's so I can handle this many switches/piezos yes.
Yes currently I can measure how hard a button is pressed and for how long using this method.

I want to do this professionally as possible, and I am having the final circuit made properly because I dont want to solder and glue piezos everywhere, so if there is a better option I want to go with it.

Does anyone know where to get strips of those collapsing rubber domes, because I did take apart a cheap keyboard and thats how they do it. Aparently the life of those domes isnt the best but its probably really cheap.

Otherwise I could use something like
http://www.cherrycorp.com/english/switches/pdf/mx_cat.pdf
which is what keyboards use, and a surface mount piezo but think this option is really bad...

a.mlw.walker:
I want to do this professionally as possible, and I am having the final circuit made properly because I dont want to solder and glue piezos everywhere, so if there is a better option I want to go with it.

I had envisaged this as a DIY project running to a tight budget. Are you actually looking for something to make a commercial quality product from new parts? How many are you making?

Anyone got any good ideas???

There are two separate questions: 1) do the piezo sensors do the job? and 2) if there are other alternatives. If you are using piezo, it makes no sense to use a separate button. So that cuts down your number of devices by half.

As to other alternatives, think about resistive rubber, capacitive pressure sensor, or mechanism light sensors, etc.

a.mlw.walker:
I dont really want to be spending more than 50 pence a button in electronic parts - normal piezo transducers are like 10pence, this is the first time the smd version has turned out to be MUCH more expensive.
Or have I over looked something and there is some other way of doing this. I have a midi keyboard with pressure sensitive pads that can also measure how long it is pressed for aswell.

Since you mention MIDI keyboards - consider that:

  • there are typically not many pads - 4, 8, maybe 12
  • the keyboard is also probably pressure sensitive (aftertouch) but only has one value for all the keys (channel aftertouch).

Because the manufacturers face the same issue: a few transducers are okay, but lots gets very expensive. This is also why fully polyphonic aftertouch is possible, but you only get it on very expensive keyboards.

a.mlw.walker:
Another option I thought of, was to have two buttons, and the same bit of plastic over both, but not quite touching the second button when it is not pressed, then measure the time between the first and second being turned on and relate that in some way to how quickly the button was pressed

Yes, that is how MIDI keyboards detect (per-key) the velocity.

If you are using piezo, it makes no sense to use a separate button.

Exactly. Piezo discs make good touch sensors. You can wire one to tell not only touch characteristics but those of the release if you use 2 digital pins. But the more detailed the data, the more attention (cycles) the AVR must pay.

You want the keys to move, put the discs on movable surfaces or under, etc. You want real piano key movement, that takes a good bit of lever mechanics.

I'm waiting on an order to get here from HK with 100 18mm piezos for US$10.40.
http://dx.com/s/piezo

Hi guys
Thanks for all your replies.
So yeah this project started out as a one off project, but it was really successfuly, and a couple of my friends who run a music production course for young offenders asked if I would make a couple for them. I decided to take the opportunity to learn to do it properly - i.e profesionally.
I have a 3d printer that I am using to print all the mechanical parts, I just want to get the button presses right so that they dont cost a bomb.
Yeah I noticed around that the keyboards with pressure pads generally dont have many of them, and I also noticed that pressure pads are expensive (sparkfun etc)
I have all of my piezos hooked up to multiplexers and I am continually polling the multiplexers for analog readings - that is how I currently get the impact.
I didnt know however if "you use two digital pins" you can also get the release. how do you do that!? Can it still be done with multiplexers?
That would save me all of the buttons, and might make piezo's feasible. Would still want surface mount ones though...

Im thinking of using the two button method also, but that would make my button matrix quite large then (52 buttons) and Im not sure I would have enough connections for that.

Conductive rubber sounds very interesting? I assume the more you squeeze it the greater the voltage? Can you buy it in sheets or rolls?

This method reads digital. How hard the tap is reads as how long a pin is HIGH. You can adjust the circuit to read faster than analog (analog read is little over 100 micros) and unlike analog you can read the next pin without having to read twice and throw the first out.

Using 1 piezo I have 2 leads. Press the piezo and one lead goes + while the other goes -. Release and each lead reverses polarity. A piezo disc is like a capacitor that charges when you stress it.

Put a diode from ground to each lead 'pointing to' the lead. It lets current flow from ground to when the lead is - at any moment.

Put another diode to each lead 'pointing away'. This is your signal when the lead is +. I run these to 1 NPN transistor that gets limited current through the collector to control how much power goes to the pin I read. 5V through 1200 (or was it 2200?) ohms works fine for me but can be tuned for read time. In experiment, even a very light touch gave me over 10 micros pin HIGH.

Going through a transistor may or may not suit your needs. Hit a piezo hard enough and you can get much more than 5V and I only have 1 UNO. I bet the hardware members here can do better than I did as far as protecting the pins.

I read the pins digital. A hard finger tap might read HIGH for 200-300+ micros. The release usually reads less depending on how long I keep pressure on the disc. Laying the disc with one edge on the table and the other on a coin to allow the disc to flex better gets much higher reads than the same disc flat on the table.

You may not need the release data, but if you hook that to the same pin then each tap will read twice. Best you just ground that lead -after- the diode if you don't want to read it.

For feel though... the difference between a grand piano and a cheap electric organ is wide. If you can come up with a balanced levers movement that smacks a hammer on the disc then the disc becomes your string and you have that certain resistance to press that does make a difference. Your sensor won't need it and either movement can be played but experienced fingers know. Remember the musician is part of the system too.

Sorry if Im being ignorant, but that sounds like you cant detect how hard it was hit, just when it was hit and released? I think this because you are using digital pins.
I thought I would be able to do it with multiplexers and analog pins? Otherwise, why use a piezo?

You can read analog with your 9 analog pins. Analog read takes over 100 microseconds.
I read digital and with tuning can get less precise data (0-50 rather than 0-1023) in half the time or less.

To be fair about it though, analog circuit actually precise to 1023 parts requires noise cancelling circuit and fast analog read (0-255) is quicker that 100 micros -- but you still have 9 analog pins.

Add to that, when quickly switching from analog pin to analog pin you can't always get a good read -according to Atmel-. I believe that our compiler takes care of this:

Note that the conversion starts on the following rising ADC clock edge after
ADSC is written. The user is thus advised not to write new channel or reference selection values
to ADMUX until one ADC clock cycle after ADSC is written.

But there's a cost, it is when the conversion starts. You can't jump from pin to pin and get back to back 105 microsecond reads but rather read (105 micros), change channel (105 micros), read...

You can read the same circuit I described with analog and your code will wait or you can read digital and do other tasks before reading that pin again. The digital circuit can use an RC circuit to stretch the read time out allowing many pins to be read without losing much % data on when any 1 pin switches HIGH to LOW or LOW to HIGH.

Digital reads are very very fast, analog reads crawl by comparison.

So I am thinking of using two tactile switches per button and measuring the time between presses. It seems easiest to just make a larger button matrix.
Does anyone know of any tactile switches with quite a bit more travel than normal ones so it will be possible to create this effect?

Thanks
Alex

What makes the note is the hammer striking the wire but good feel gives incredible control on the timing and strength of the note. You can still play a cheap organ, or post on the internet on a cheap keyboard, it's just better with the right stuff.

So you can make your keys come down however feels best and let the key tapping/smacking bottom give you your press data. IIRC the keys should feel a bit like one end of a teeter-totter (different than a spring-arm), you should be able to bounce a key with one finger, right?

Get your data at the hammer or bottom of the key strike and be sure the strike hits felt. ;^)