Go Down

Topic: piezo as knock sensor : building preamp (Read 3530 times) previous topic - next topic

kro

Feb 04, 2011, 09:05 pm Last Edit: Feb 05, 2011, 09:05 am by kro Reason: 1
following these conversations
http://arduino.cc/forum/index.php/topic,26791.msg199278.html
(and in french) http://arduino.cc/forum/index.php/topic,33598.msg245621.html

i laboriously (as i was not much into electronics at first) built a preamp to get a nice sensitivity and velocity response to knocks using piezos
i m really not sure about the english words but it amplify, then redress (positivise?) and then smooth the electric signal so it can be nicely received by the arduino


here is the scheme :

you need to adapt resistors 1 and 2 depending on the desired sensitivity

here is an arduino shield for 2 piezos (piezi ?)
beware cause it's reverse mounted : with components underneath the board (so i gain space) near the arduino components
this is the component face :


code should looks like this
this is not the code i use but a simpler one, working for one captor
Code: [Select]
const int piezo_0 = 0; // analog input 0

const int trigger_threshold_0 = 2;  // difference with last value so it start to trig
const int delay_0 = 30; // pause to avoid multitriggers for one knock during 30ms

unsigned long now = 0;
unsigned long pause_0 = 0;

int triggerValue_0 = 0;
int previousValue_0 = 0;
int peakValue_0 = 0;
int maxValue_0 = 0;

void setup() {
 Serial.begin(9600);
}

void loop() {
 now = millis();
 
 if (pause_0 < now - delay_0){ // pause off
   triggerValue_0 = analogRead(piezo_0);
   if (triggerValue_0 >= previousValue_0 + trigger_threshold_0) {
     delayMicroseconds(230); // wait 0.23 ms for peak
     peakValue_0 = analogRead(piezo_0);
     if (peakValue_0 > triggerValue_0){ // be sure peak value is higher
       maxValue_0 = peakValue_0;
     }
     else {
       maxValue_0 = triggerValue_0;
     }
     Serial.print("/piezo_0 ");
     Serial.println(maxValue_0); // send osc message
     previousValue_0 = maxValue_0;
     pause_0 = millis();
   }
   else {
     previousValue_0 = triggerValue_0;
   }
 }
}

Hi,

Is the circuit working properly ?
What was your input voltage before amplification?

I'm having a sensor which gives output in mV and now I'm
trying to increase it to V using a amplifier.

Will it be advisable if I try your circuit?

MarkT

You probably don't need to amplify it - just don't load it with that 10k resistor (R1) - that's reducing the sensitivity a lot.  Piezos are very high impedance output so placing a "low" resistance of 10k across it will attenuate its output.  Try 1M instead.
[ I won't respond to messages, use the forum please ]

@MarkT :

I'm having different sensor : Geophone which is giving output in 10mV (minimum) and
1 Volt (maximum) on DSO with healthy noise.

So I'm trying if this circuit works for me or else I need to make it on own which I'm not
aware much in details.

What would you suggest?

OutOfLine

#4
Jan 30, 2012, 07:00 pm Last Edit: Jan 31, 2012, 03:55 am by OutOfLine Reason: 1
If I connect a piezzo directly to Arduino A0, (sorry no input protection at all, just for a short experiment), *gently* press a bit on the piezzo and let my homemade software breadboard display analog reads on A0 I see:

Code: [Select]

Follow pin 0 tolerance 1
values +/- set tolerance (any other byte to stop)

120 ********
122 ********
124 ********
126 ********
131 *********
138 *********
147 **********
161 ***********
178 ************
202 *************
231 ***************
264 *****************
296 *******************
322 *********************
355 ***********************
424 ***************************
561 ************************************
596 **************************************
678 *******************************************
814 ***************************************************
972 *************************************************************
1023 ****************************************************************|
1021 ****************************************************************
997 ***************************************************************
833 *****************************************************
615 ***************************************
422 ***************************
255 ****************
127 ********
39 ***
0 0


This means you easily go over 5 Volts and below zero (when you release the piezzo).
Maybe a 5.1V zener diode parallel the input would be good if you want to *knock* on a piezzo ;)



This means you easily go over 5 Volts and below zero (when you release the piezzo).
Maybe a 5.1V zener diode parallel the input would be good if you want to *knock* on a piezzo ;)



Important : I'm not having piezzo, I'm using Geophone.

Now as you have written and showed that it easily goes above 5 volts then please tell me one thing
why it didn't harm ADC of your Arduino as recommended should be max 5 volts.

dc42


Now as you have written and showed that it easily goes above 5 volts then please tell me one thing
why it didn't harm ADC of your Arduino as recommended should be max 5 volts.


The Arduino has input diodes that protect the inputs from more than +5v and less than 0v, provided the current flowing into the diode is low enough. The current provided by a piezo knock sensor is tiny, unless you hit it with a hammer.
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

OutOfLine

#7
Feb 01, 2012, 10:22 am Last Edit: Feb 02, 2012, 02:02 pm by OutOfLine Reason: 1

The Arduino has input diodes that protect the inputs from more than +5v and less than 0v, provided the current flowing into the diode is low enough. The current provided by a piezo knock sensor is tiny, unless you hit it with a hammer.


Yes, probably I was over cautious suggesting a zener to protect the input, or maybe not?

Edit:
I could not reproduce my multimeter current readings, so I assume stupid user error.
I short circuit a piezzo disk by a cheap multimeter in the 200mA range to get some readings
[ meaningless multimeter readings deleted ]

dc42

If you're sure that you're reading mA not uA, then 20mA is certainly more than you should subject the Arduino input protection diodes to, and you should use external Schottky protection diodes.
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

OutOfLine

I could not reproduce my first findings. Checking again gave readings that look save for arduino inputs.


If you're sure that you're reading mA not uA


so I assume I was not,
how embarrassing ;)


mynde

hello,

thanks for great information.
I have a question - what should I change in preamp circuit if I'm going to conect it to 3.3v arduino?

Go Up