Go Down

Topic: reading piezo sensor (Read 1 time) previous topic - next topic

Daniel

fyi

i was using a one-ince diameter piezo... or 2.67cm or something like that!

If you have a giant piezo that could well damage the Atmega inputs.
Now that I htink of it, the diode should be OK, it's probably the resistor... any luck yet?

D

garthpaine

Thanks Daniel

Yes I am just using the smaller Piezo as well - I changed the resistor and took the Zener out - the responce is much better but still not all that great - I not the highest output is around 800, and it does not seem to output very consistent figures - multiple taps of similar strength output quite different responces, so perhaps it is still not seeing the envelop of the sensor properly?

I am interested in using several to form a trigger matrix for samples with some velocity sensativity that I will smooth in Max/MSP as there seems to be no way of smoothing in Arduino?

I'll look at it a bit more tonigh and get back to you - the main problem is consistency of responce - perhaps I need better quality Piezos?  Any suggestions on that front?

Cheers

Garth

Daniel

what value resistor did you try? Try putting a 100K pot across the piezo terminals, and turning it to a smaller and smaller resistance while monitoring the values...

garthpaine

yes thats a good idea - I have just such a pot with connector pins soldered on for the Arduino.  I have a 100K resistor in there at the moment.  I just got 10 smaller Piezos off eBay which actually seem to respond better than the larger one I have.  The larger one is about 28mm across, the smaller one is about 22mm.

I'll try the pot idea tomorrow.

Thanks again.

PS.  I got the Arduino2Max running today - SWEET :-) http://www.arduino.cc/yabbfiles/Templates/Forum/default/grin.gif

Cheers

Garth

todbot

The charge generated by the piezo when it is whacked is very tiny.  You'll likely find that adding a resistor smaller than 1M will result in lower values read from analogRead().  This is because the smaller the resistor is, the faster the piezo's charge will be dissipated.  Trying to accurately capture the tiny voltage peak generated by the piezo is tough.  Ideally I think you'd have no resistor at all and then use Arduino itself to discharge the built-up charge once it has been read.  Something like this might work (note, not tested at all):
 pinMode(piezoPin,INPUT);
 val = analogRead(piezoPin);  // read piezo
 pinMode(piezoPin,OUPUT);
 digitalWrite(piezoPin,LOW);   // discharge piezo

This assumes the input resistance of the Arduino is very high, >10M at least.  I think this is the case, but I've not checked. And it runs the risk that you'll miss the whack on the piezo when you're spending time draining the charge.  This is the reason for the 1M resistor in the original circuit: it acts as a constant charge drain so you don't need to worry about doing it yourself, at the expense of accuracy because you're never sure of getting an accurate reading.

I solved this quite accurately before by sticking an op-amp configured as a comparator between the piezo and microcontroller. The op-amp amplified the signal and turned it into a digital value where the HIGH time measured the intensity of the hit on the piezo.

And you'll still probably want the zener though. Piezos can generate kilovolts, more than enough to fry the input pins of your Arduino.


Go Up