Confused Beginner: Piezo Knock sensor /w Arduino - Page 1
Forum section: electronics / beginners

author: DC Jack
author_rank: Contributor
timestamp: December 23, 2016, 05:07:56 am
content: I'm just getting into electronics by challenging myself to build a 'smart' target for target shooting. Right now I am planning on using a piezo buzzer as a sensor to detect bullet strikes against the metal it is attached to.As I understand, from internet reading, piezo buzzers when subjected to deformation cause a voltage to be generated and that voltage can very easily reach high levels, levels that are unsafe for the Arduino's 5v max input. In order to protect the Arduino I put a reverse biased 4.7v zener diode in parallel with the buzzer and into A0 of the arduino along with a 1 mOhm resistor in parallel as shown in the Arduino.cc Knock tutorial.Here is where I get confused. The output range on the A0 pin in 0 to 1023 and I am assuming 1023 would be the equivalent of 5v. When I flick the buzzer I get readings in the 400-500 range which should be the equivalent of 1.9v to 2.5v. When I remove the zener diode the readings jump to 1000+.How is the zener causing this massive change in the readings?

author: BradC
author_rank: Super Contributor
timestamp: December 23, 2016, 05:29:05 am
content: Have a look at the knee in the curve of the zener on the data sheet.They start to leak very early in the curve and this ramps up until they hit the knee and really switch on. I got burned by that years ago using 5.6v zeners to protect PIC ADC inputs.There are plenty here that can tell you (better than I) how to protect your inputs, but the zener is conducting well below its rated voltage and you have a relatively high impedance source driving it.

author: alsetalokin4017
author_rank: Super Contributor
timestamp: December 23, 2016, 10:37:55 am
content: You can use the map() statement to scale your 0-400 range raw A0 values to full-range 0-1023 if you need it.

author: Dave
author_rank: Super Contributor
timestamp: December 23, 2016, 10:46:13 am
content: My guess would be that the additional capacitance of the Zener is the limiting factor. The pins of an ATMega have an input capacitance around 10pF, while a 4.7V Zener diode can be several tens of picofarads.

author: max_torque
author_rank: Super Contributor
timestamp: December 23, 2016, 11:39:31 am
content: Does it matter? I mean, a hit is hit right? As long as the "Hit" ADC value is high enough above any background (noise) reading on the ADC you can spot the hit? Depending on how fast you are sampling the ADC, and what the actual impact voltage pulse looks like, then you will probably need some analogue low pass filtering to capture it reliably anyway!(assuming the impact results in the target ringing at some frequency that is mass dependent, and hence producing a sine wave voltage output, if you take a single sample at the wrong moment your code may miss the event!)

author: AustinTxBob
author_rank: Contributor
timestamp: December 23, 2016, 02:38:43 pm
content: What about using an interrupt instead?

author: Rick Law
author_rank: Super Contributor
timestamp: December 23, 2016, 06:28:00 pm
content: Quote from: alsetalokin4017 on December 23, 2016, 10:37:55 amScaling 400 to 1023 is something so simple I think using the map() will just make the code harder to maintain. It also adds unnecessary dependence on the library which is not desirable.Quote from: max_torque on December 23, 2016, 11:39:31 amBesides, max_torque is right. It really shouldn't matter.Just test for input > X and that makes it a hit.

author: JimRemington
author_rank: Regular Contributor
timestamp: December 23, 2016, 06:47:52 pm
content: The input protection and body diodes will conduct if the input voltage is higher than Vcc+0.5 V or less than -0.5V, so the Zener is unnecessary.The only other problem would be if the input current to the substrate or power supply would be high enough to damage the input, but I doubt very much that the piezo can provide enough current to do that. It would be microamperes at most.Most people just use a 1 Meg parallel resistor. I've certainly never heard of a problem.

author: Seekonk
author_rank: Super Contributor
timestamp: December 23, 2016, 07:02:42 pm
content: It could be any value depending on when you sample, even could be missed entirely.