-
Piezo transducer signal conditioning
Posté le 6th juin 2009 23 commentairesPiezo transducer are very common, very cheap, and can be very useful as sensors : sound, knock, shock, whenever it « moves » or « makes noise », a piezo sensor can help.
However, the signal from those things is very unpleasant for the digital hacker : it’s roughly a sinewave that dampens over time. Also, the signal often goes negative which is pretty bad for mots digital chips out there. The ATmega168 (and most of the atmel 8 bit microcontrollers), for instance, indicates that voltage on any pin must be between -0.5V to VCC+0.5V. Piezo transducer easily go far beyond those bounds.
In the capture below, voltage from the piezo goes a down as -52V and goes up to 9.2V. This is more than 60V peak to peak. If you don’t do anything, your poor microcontroller might get sick rather quicly :
In this capture, the signal first drops to -20V, and then flies up to over 35V. Almost 60Vpp here too.
These are just examples, I didn’t tweak the piezo or smashed it with a hammer : just a hit with a fingernail, and you almost always end up having huge Vpp values. Also, the behaviour is not predictable (well piezos are, but the way we smack it isn’t), so it might go up first, then down, then up, who knows…
A close up shows the « dampening sine-like signal » that occurs after the first big spikes :

Piezo signal close up
So signal conditioning is a must with those pesky animals if you’re doing digital.
Let’s recap what has to be done :
- make that signal all positive : most of the time, piezos signals are read by ADC, so we want positive voltages
- restrict signal bounds to 0 – VCC so voltage doesn’t climb to scary values (scary at least for microcontrollers and ADCs),
- shape the signal so it doesn’t make bumps and stays clean and predictable
All these requirements are surprisingly easy to achieve. We will get to this goal in three steps, each spect taking care of one item above. Respectively :
- add a half-wave rectifier, in order to keep positive part of the waves
- add a zener diode, so signal doesn’t climb over zener’s breakdown voltage
- add a RC pair so ripples get filtered
Half bridge rectifier
First, we want to rectify the piezo signal, i.e. make it all positive. We’ll use Schottky diodes for that. Schottky are more interesting since they have a pretty low (compared to standard rectifier diodes) forward voltage drop (Vf), around 0.3V.
You might ask : why not use a complete Schottky-based bridge rectifier, and make the whole signal positive, instead of filtering negative voltages ?
Well, look back at the first scope shots of raw piezo signals. When signal changes sign, it makes it rather violently, and can even be higher on the new side than it was on the previous side. Now try to make the math abs() operation on the shape, mirroring the negative part of the shape on the other side of the time axis. You’ll end-up with an erratic plot : low, then high, then low. This means that, even with some filtering, you wont end-up with clean shape, but with a jittering thing that will look like the first signal, but all positive and less wild. This is not what we want, so we are sacrificing the negative part of the signal to get something nicer (the fine Agilent firmware bug is provided free of charge
.In fact, well do a bit more than a half wave rectifier. If we just put a Schottky diode in series with the positive we’ll end up with the kind of signal shape shown on the left. We can see there is a fair amount of signal that is still below 0v, and in our circuit, we’re not supposed to have negative voltages. Even if the ADC can stand it, it probably won’t do any interesting measures with a negative signal.
There is probably a good reason for this to happen, but I don’t have a clue right now. If you do, please leave a comment.
So we have to get rid of this negative leftover, by adding a second Schottky diode, between ground and signal lines. We’ll just keep the positive signal, but it will be much easier to filter this way.
Our piezo signal rectified by two Schottky looks like this (the wavefom has been moved to the bottom of the screen for cosmetic reasons). We still have negative voltable building up, but it’s pretty negligible now. I wonder if that -400mV is linked to the diode’s forward voltage.
Althought the scale isn’t the same, the small ripples seem to have disappeared. This might be due to the Schottky diode capacitance (14pF), which, while low, could impact the small ripples with higher frequency. I didn’t have time to check that though.
Now, we need to cap the maximum voltage in circuit, so we don’t fry our ADC.
Zener diodeAs seen above, voltage range is pretty high and can climb quickly to unappropriate values for digital purposes. So wee need to tame the voltage created by the piezo. Zeners have this ability, and can limit voltage to a fixed value. Whenever voltage is higher than the Zener’s rating, the Zeners lets current flow thru and as a side effect, help maintain voltage to a fixed value.
We usually have to add a resistor between the Zener and ground, so voltage builds up around it and current is limited thru the Zener. But this is not necessary with piezo, since involved currents are very very low.
After we add a 5.1v Zener in the circuit, the voltage read from a piezo looks like this.
You can smash the piezo as hard as you want, you’ll never exceed the Zener’s rated voltage.
If we just use this shape as is, we’ll have a hard time trying to guess if the piezo has been smashed or not. We have to filter those spikes to get a smoother shape.
Filtering the signal
This signal can be filtered by using a RC cell. Whe just need to know how long we want the shape to last. For my application (drum trigger), I want the signal to fade out in 10ms maximum. Since we know that the voltage drops to 10% of the initial voltage after Error: http://leucos.lstilde.org/wp/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more details, we can find the right resistor knowing the capacitor value, and vice-versa.
Let’s say we use a 1MΩ resistor, we’ll have to use aError: http://leucos.lstilde.org/wp/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more details capacitor.
So we end up with this simple little circuit :

And get this nice little shape :

Finaly, a clean, ADC friendly signal
Hope this can help you using those pesky beasts. Be warned that piezo are all differents, and that size matters… So experiment with that before engraving the above stuff in copper.
23 réponses à “Piezo transducer signal conditioning”

-
excellent ! thank you very much for this information. i found your post after looking on the v-usb forum:
http://forums.obdev.at/viewtopic.php?f=8&t=1352&start=30#p11080my question is about the second circuit mentioned in the post:
http://ispf.de/modules.php?name=News&file=article&sid=6&page=1C1 holds the voltage pretty long and gets deloaded after a succesfull measurement by pulling the appropriate pin to low.
is this really required for an electronic drum?
my other question (merci pour ton temps):
your RC is for 10ms, why did you choose 10ms and not let’s say 1ms?
pat
-
patrick 25th septembre 2009 à 19:02
Hi Leucos,
Again thank you! About the RC value, is there a reason for choosing 1M resistor? For my design, i used 10k resistor + 0.1uf capacitor and i am wondering if it\’s a \"smart combo\"? Maybe it\’s better to have bigger resistance and less capacitance?
pat
-
K-Duke 26th septembre 2009 à 22:59
Salut leucos,
I just wanted to get around to thank you for your in depth description of yours here.
When thinking about it. Leucos you did a mistake with your 10ms. 10^-3 = 0,001 which is 1ms not 10!
@patrick
If you have a piezo element which produces significant less voltage (like me) you have to have a high resistor to not let it suck almost the whole signal from the ADC. Therefor the cap becomes smaller (at a given time).greetings K-Duke
-
K-Duke 27th septembre 2009 à 17:12
Oops sorry. Actually I misread your formular. Thought you had 1 * 10^-3 there though you got 10 * 10^-3. Sorry for confusing you -.-
-
patrick 27th septembre 2009 à 18:29
I am using 44 mm diameter piezo. When using a 10k resistor + 0.1uf capacitor the maximum voltage when striking the piezo is around 3v. I was happy with this result, because i’m not using a 5.1v zener diode to limit the voltage. Instead, i am using a op-amp to boost / limit the voltage.
BUT, i think my RC is not well suited for an electronic drum, the fact that i’m using a bigger capacitor seem to cause a problem (not detecting all the hits). So i tried your 1M + 4n7 and it’s more sensible (soft hits are detected + all the hits are detected).
QUESTION, since your RC is much more sensible (the voltage can go up to 15v without a zener diode) would it be a good idea to use a voltage divider to bring the voltage down under 5v? using a potentiometer for the voltage divider, it will be possible to adjust the sensibility of the piezo?
/me trying to find _THE_ best solution
-
patrick 4th octobre 2009 à 21:13
hi,
here’s my final circuit:
http://imagebin.ca/view/VoCkp1.htmli am using a voltage divider before filtering the piezo. this bring the voltage to 0v – 5v (approx). to be sure not to exceed 5v, i am using a zener diode.
cheers!
-
patrick 9th octobre 2009 à 18:51
Hello Leucos,
I am not sure about the voltage divider. The idea was to scale down the voltage to 5 volts (without the voltage divider it was around 50 volts) instead of just omitting anything above 5 volts.
A new proposition:
http://imagebin.ca/view/6_-R02bH.htmlThis time with a trim pot to adjust the sensibility of the pad. Does it make any sense?
-
fernando 23rd octobre 2009 à 22:09
Hi.
I’m newbie in electrical material, and I don’t speak English as I speak Spanish, so please forgive me if I made a mistake writing this.
Well, I found your post and I think that it’s exactly what I need (I’m working with arduino + piezos), but if I go to the electronics store and I ask for « Two BAT85 Schottky Diodes », « 1 Zener Diode 5.1v » and « one 4n7 capacitor » probably salers will make some technical questions that I couldn’t answer.
So may I ask you to tell me please the exact specs for diodes (1 Zener diode,2 schottky diodes?) and the « 4n7″ (capacitor?), the other elements (piezo,resistor,etc.) aren’t problem.
I’ve tried software tricks (reading by count or elapsed time + signal thresholds) but I think that your solution should be better.Thanks in advance.
-
fernando 24th octobre 2009 à 03:51
Thanks for the fast answer Leucos.
And by the way, my world is the software and in the last time i have working hard on vst’s and midi software, sequencers, etc., and i’ve hacked a gamepad (wheel) to build a midi floorboard and the sustain pedal for my keyboard, and now i’m programming the arduino to get the piezo signals to finally build the drum and perform a vst like addictive drums. My next project will be to build a breath controller (maybe hacking a broken clarinet). In the music world i play guitar and keyboard, but we (almost a band) need the drum, so with your work we are closer to get it.
I know that i’m still a newbie in the hardware world but maybe i can help in some way to thank you, so any doubt just let me know.
Thanks again. -
Hello,
You say this circuit acts as an RC filter, but looking at http://en.wikipedia.org/wiki/Rc_circuit
isn’t the R and C suppose to be connected in Series ?
whereas in your schematic they are connected in parallel ? -
Hi,
I did scroll down to the wikipedia page …
There they mention the *Parallel* RC circuit that
you are using.It says : \"The parallel RC circuit is generally of less interest than the series circuit. This is largely because the output voltage Vout is equal to the input voltage Vin — as a result, this circuit does not act as a filter on the input signal unless fed by a current source.\"
Here, in all your scope captures, you talk of voltage, and not current, so I don\’t understand..
-
Philipp 10th mars 2010 à 10:51
Hi Leucos,
thanks for sharing your work!
I have a more general question regarding piezos, as I am currently starting work here and am mch more aware of soft- than of hardware.
So: Is it possible to distingish between pressing an d depressing the piezo? Will that give any different output using your circuit?
In the situation I am using the piezo in, it will be pressed and after a longer time, it will be depressed.Sadly I do not have an oscilloscaope available so it woud be nice if you could help
-
This is a very nice article, but i have done some playing with piezos and i have to say it is not that simple. I want to put a piezo in a box and hitting the box will trigger some event. The box is 16mm woods. SO, the voltage spiked from a hit is about 100-200mV only. But you hit it really hard then you’ll get around 10V. I need to detect both types of hits (not distinguish, just detect, they are all the same to me). The problem here is the diode. With only 200mV spike the diode will not let it through. So, i need to amplify it first! A simple NPN transistor might help, do you think? So, when the signal from the piezo will go to the base the output voltage with like 100x more (i’ll take a trans with gain of around 100) but not more than the Vcc. Fo example, 50mV from piezo will result in 5V output (Vcc). However, I, again, don’t know what to do with +10-20V on the base from the piezo? Allowed max Base-emitter voltage is usually around 6V. Put a zenner to the base? Then what will happen to it on negative voltage it? It will conduct and we’ll have a short cicuit. Any ideas?
Laisser une réponse







patrick 25th septembre 2009 à 06:23