Hi Everyone !
I'm trying to make a reliable and repeatible shock measurement (not just detection) using arduino Leonardo and a 20mm Piezo transducer (the ones used as a pickup for guitars) And i'm puzzled by its inconsistency. The final application should be a skill based "Hammer Game" where you should apply a given force to reach a selected goal
Yes, I understand "hitting the surface where it is mounted" is not a scientific measure, as each hit may fall on different spots, with different forces and I cannot expect a particular degree of reliability, So I'm broadly asking, what you think is the best approach: multiple piezos and get an average / capacitors to "slow down" the voltage peak, and measure it more reliably, or even, a whole different kind of sensor.
I also tried with load cells, but they are not fast enough to detect and measure an impact.
In my code, not that you may need it, I just measure the peak value, and return it to the game, as soon as the piezo returns ~0 again
Hi, thanks for your reply jhaine,
is the accelerometer in rest position, reliably "still" ? or should I also account for noisy readings ?
Anyway, I'll try that road also, thanks !
There is I believe standard software to correct for zero drift. Actually in the vertical direction the "rest" acceleration is 9.81m/s/s but it's constant.
Your phone will have a 3-axis accelerometer + gyro built in.
the measurement is the analog value plotted, the impact, as I stated, it is not scientifically generated or accurate: I knock 10 times hard, and I don't get 10 consistent values, but rather, about 8/10 return a reading "consistent" with my hit
Yes, as I stated I'm not attempting to measure the actual force in Newtons, of the impact, I'm more focused on obtaining a consistent measure of the force being applied.
I think now I do, I'm using a 50v 1u capacitor in parallel with a 1K resistor with the piezo, and the peaks i plot, are way smoother, so I assume the sampling rate gets slowed down acceptably.
But i'm open to suggestion on improving / changing the circuit
Thank you for your feedback, just to be more clear about my application and what is the issue, here are a few clarifications.
I'm well aware that tapping with my finger ten times on a disc, is by no means scientifically accurate. Not even dropping a pen repeatedly from the "same" distance is. Or sticking the piezo on a surface, and hitting that surface around the same area.
I know, and since I've been reading a good amount of topics on this forum, about piezo being used as a sensor, the complexity of the forces at work during an impact, isn't something i expect to magically "measure".
Not with a .30$ sensor, and a trivial max peak detection sketch.
It may be so fast, that it could happen between two clock cycles of he MCU, and not being recorded at all: like blinking your eyes exactly when a very fast car passes by. This is why i tried using a capacitor to "slow" it down. And it seems that i'm not missing reads, but please elaborate if you think it messes the reads in other ways.
But taken all of this into account, I'm trying to settle for a fair degree of precision: after all we have 1024 values, and it should be normal to expect that hitting the piezo hard 10 times, should yield 10 times 1023, but it doesn't. Let's not get into hitting it softly and expecting ~200 all the times, because I understand is way more complex generating a consistent input.
What I'm really asking, besides suggestions out of the box, is if is there any limitation on the hardware, both Arduino and piezo/piezo and capacitor, rather than only on the mechanical input side.
Thank you for your time
That would be my guess... You are only reading/sampling for one "instant" every time through the loop. Most of the time it's NOT reading!
There is an op-amp circuit called a Peak Detector. It charges a capacitor to the peak voltage quickly and the capacitor discharges more slowly.
I use peak detectors "all the time" with audio to get the "loudness". I can read at about 10 times per second instead of thousands of times per second, freeing-up the processor to do other things between reads.
Like most analog op-amp circuits it works best with positive & negative power supplies so it can do all the way down to zero, but a "rail-to-rail" op amp with a single supply will probably work fine in your application.
Or if you have enough signal voltage you can simply put a diode in front of your R-C circuit. Again it will charge faster than it discharges so you can have more time to read the voltage. But there is a ~0.7V drop across the diode so you need at-least about 1V before you get any useful readings.
I would run a significant number of experiments and from the results, form an opinion about the "typical" result and variations from typical, then proceed with that information.