EEVblog Electronics Community Forum
Electronics => Beginners => Topic started by: DC Jack on December 23, 2016, 05:07:56 am
-
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?
-
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.
-
You can use the map() statement to scale your 0-400 range raw A0 values to full-range 0-1023 if you need it.
-
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.
-
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!)
-
What about using an interrupt instead?
-
You can use the map() statement to scale your 0-400 range raw A0 values to full-range 0-1023 if you need it.
Scaling 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.
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!)
Besides, max_torque is right. It really shouldn't matter.
Just test for input > X and that makes it a hit.
-
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.
-
It could be any value depending on when you sample, even could be missed entirely.