Author Topic: Confused Beginner: Piezo Knock sensor /w Arduino  (Read 1966 times)

0 Members and 1 Guest are viewing this topic.

Offline DC Jack

  • Newbie
  • Posts: 2
  • Country: ca
  • Country: ca
Confused Beginner: Piezo Knock sensor /w Arduino
« 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?
« Last Edit: December 23, 2016, 05:11:10 am by DC Jack »
 

Offline BradC

  • Super Contributor
  • ***
  • Posts: 1596
  • Country: au
  • Country: au
Re: Confused Beginner: Piezo Knock sensor /w Arduino
« Reply #1 on: December 23, 2016, 05:29:05 am »
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.
 

Offline alsetalokin4017

  • Super Contributor
  • ***
  • Posts: 1873
  • Country: us
  • Country: us
Re: Confused Beginner: Piezo Knock sensor /w Arduino
« Reply #2 on: December 23, 2016, 10:37:55 am »
You can use the map() statement to scale your 0-400 range raw A0 values to full-range 0-1023 if you need it.
The easiest person to fool is yourself. -- Richard Feynman
 

Online Dave

  • Super Contributor
  • ***
  • Posts: 1193
  • Country: si
  • Country: si
  • I like to measure things.
Re: Confused Beginner: Piezo Knock sensor /w Arduino
« Reply #3 on: December 23, 2016, 10:46:13 am »
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.
<fellbuendel> it's arduino, you're not supposed to know anything about what you're doing
<fellbuendel> if you knew, you wouldn't be using it
 

Online max_torque

  • Super Contributor
  • ***
  • Posts: 1021
  • Country: gb
  • Country: gb
    • bitdynamics
Re: Confused Beginner: Piezo Knock sensor /w Arduino
« Reply #4 on: December 23, 2016, 11:39:31 am »
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!)
 

Offline AustinTxBob

  • Contributor
  • Posts: 40
  • Country: us
  • Country: us
Re: Confused Beginner: Piezo Knock sensor /w Arduino
« Reply #5 on: December 23, 2016, 02:38:43 pm »
What about using an interrupt instead?
 

Offline Rick Law

  • Super Contributor
  • ***
  • Posts: 2649
  • Country: us
  • Country: us
Re: Confused Beginner: Piezo Knock sensor /w Arduino
« Reply #6 on: December 23, 2016, 06:28:00 pm »
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.

« Last Edit: December 23, 2016, 06:30:19 pm by Rick Law »
 

Offline JimRemington

  • Regular Contributor
  • *
  • Posts: 167
  • Country: us
  • Country: us
Re: Confused Beginner: Piezo Knock sensor /w Arduino
« Reply #7 on: December 23, 2016, 06:47:52 pm »
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.
 

Offline Seekonk

  • Super Contributor
  • ***
  • Posts: 1813
  • Country: us
  • Country: us
Re: Confused Beginner: Piezo Knock sensor /w Arduino
« Reply #8 on: December 23, 2016, 07:02:42 pm »
It could be any value depending on when you sample, even could be missed entirely.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf