I'm trying to build a knock sensor, something like this:
Everything is generally working, but sometimes my threshhold (the knock) is randomly triggered, and it appears to be caused by some sort of electrical interference. I posted a video of the problem here:
The LED should only be lighting when a knock is detected.
As far as the circuit, I'm connecting the piezo's negative to ground, and the positive to analog pin 1, and I have a 1 megohm resistor between ground and analog pin 1. This is the piezo I'm using: http://www.radioshack.com/product/index.jsp?productId=2062397
And to describe the problem a bit more, usually everything works well, but seemingly randomly it stops working and the threshhold (the knock) is detected. It usually remains like this until I touch the ground wire, or even put my hand near the ground wire.
Eventually I'd like to have 6 different piezos detecting different "knocks", if possible.
The main problem is that with a 1M input impedance the input of the A/D is effectively floating.
While the circuit you have is good for a demo that is about all, it is not a very robust circuit. I would expect it to give the problems you are seeing. I doubt if shielding is going to do anything for you, in fact it will probably make it worse.
You need an op-amp to convert your high input impedance into a lower one.
The cause of the interference is probably you! If your near some mains wiring you can pick up dozens of volts or so at very high impedance and this is then inducing a fraction of a volt in your circuit because its relatively high impedance too. You can reduce sensitivity to this AC pickup by sampling the piezo element at exactly the mains frequency...
Well that's not the sort of thing I had in mind. All this does is provide a DC bias to the sensors to allow negative voltages to be measured. It still has the same problem of having a 1M input impedance and that is what is causing you the problem.
Look at this thread and the links off it:- http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1239839000
The sort of thing I was thinking about was a voltage follower:-
You can reduce sensitivity to this AC pickup by sampling the piezo element at exactly the mains frequency
That is just twaddle, have you ever tried this? A simple minded look at the theory says it could be static if the interference is mains. But the size will depend on the phase relationship between sample point and mains pickup. The mains pickup phase will change with a persons position so even if you could synchronise it exactly it will not work.