Maker Pro
Maker Pro

Peak detector for piezo drum pad

I could use a little help trying to make a circuit that will improve the peak detection of a piezo strike. I have piezos connected to analog inputs of a micro controller and they are velocity sensitive. This works but when I play fast some of the notes don't play accurately. I tried this circuit but the signal drops too low
Can anyone tell me what circuit and components would be best to use? Peak-detector-circuit.png
 
I have to build 22 circuits so I'd like to keep it as simple as possible. Can you tell me if this circuit will work, and if so which op amp and which components to use? I don't know much about electronics, I would really appreciate it.classicpeakdetector.png
 
I'm interested in this discussion as I use piezo's quite a lot. Can't help too much as this circuit is new to me. The same circuit seems to be a little way down on this article from DIGIKEY with component spec's. https://www.digikey.lu/en/articles/...e-vs-software-tradeoffs-part-2-peak-detectors
Thanks for responding, I read the article and will try to build this circuit. I have some NE5532 op amps, I,m not sure if they will work as I've tried to build a similar circuit and could not get any thing from the output. I am not experienced with this and do not have an oscilloscope. I was hoping someone could tell me exactly which components I need to use or which circuit would be best. article-2017october-hardware-vs-software-fig4.jpg
 
Strictly speaking, the circuit you have included on #5 is a rectifier but can be use as a peak / pulse detector. You just have to make C and Rl large enough to hold up for a significant period. Also, it will only reflect the peak value of the input signal. If that is not high enough to trigger your circuit that follows it, some further conditioning will be necessary.
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
I could use a little help trying to make a circuit that will improve the peak detection of a piezo strike. I have piezos connected to analog inputs of a micro controller and they are velocity sensitive. This works but when I play fast some of the notes don't play accurately. I tried this circuit but the signal drops too low

That circuit has 2 main problems. The first one of that the amplitude of the signal is strongly influenced by the value of the capacitor. The second is (frequently) is that you can end up with voltages that are way too high.

BTW, my experience comes from helping a person get the electronics right for a multi channel percussion input to a synthesiser.

The common solution to the first problem (running for sensitivity) is to place a high value (say 1M) trimpot across the piezoelectric element. This acts as a variable load that can be adjusted to give an appropriate voltage pulse when struck.

The second problem is solved with a Schottky diode from the top of the capacitor to +5V.

The next problem comes when you connect this to something. The problem is that it is very easy to drain off the charge on the capacitor. My recommendation is twofold. Firstly, you leave it electrically disconnected when you're not taking a measurement, and secondly that you measure it frequently.

Three method we used was to connect the series of piezoelectric elements via analogue multiplexers. This allowed us to leave them effectively disconnected until we wanted to read them. It also allowed us to reset the peak detector by changing the input to an output, setting it to low.

One thing we found that we had to be very careful of when using CMOS analogue muxes is that as you switch from input to input the is a very short period of time when both inputs are connected together (or both to the output -- which amounts to the same thing). This caused charge to get distributed from one capacitor to another. We found that disabling the mux while switching channels, and resetting each one as we read it minimised this problem.

I'm pretty sure the mux we were using was 16 channel, but I can't remember the part number. I recall that it wasn't anything exotic.
 
That circuit has 2 main problems. The first one of that the amplitude of the signal is strongly influenced by the value of the capacitor. The second is (frequently) is that you can end up with voltages that are way too high.

BTW, my experience comes from helping a person get the electronics right for a multi channel percussion input to a synthesiser.

The common solution to the first problem (running for sensitivity) is to place a high value (say 1M) trimpot across the piezoelectric element. This acts as a variable load that can be adjusted to give an appropriate voltage pulse when struck.

The second problem is solved with a Schottky diode from the top of the capacitor to +5V.

The next problem comes when you connect this to something. The problem is that it is very easy to drain off the charge on the capacitor. My recommendation is twofold. Firstly, you leave it electrically disconnected when you're not taking a measurement, and secondly that you measure it frequently.

Three method we used was to connect the series of piezoelectric elements via analogue multiplexers. This allowed us to leave them effectively disconnected until we wanted to read them. It also allowed us to reset the peak detector by changing the input to an output, setting it to low.

One thing we found that we had to be very careful of when using CMOS analogue muxes is that as you switch from input to input the is a very short period of time when both inputs are connected together (or both to the output -- which amounts to the same thing). This caused charge to get distributed from one capacitor to another. We found that disabling the mux while switching channels, and resetting each one as we read it minimised this problem.

I'm pretty sure the mux we were using was 16 channel, but I can't remember the part number. I recall that it wasn't anything exotic.
which circuit are you referring to? I'm using a Teensy 3.6 board with 24 piezos connected to the analog ins. with a 10k resistor in parallel The board can only take up to 3.3v. is there a circuit you think may work?
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
which circuit are you referring to?

The one in your first post (the one I replied to)

I'm sing a Teensy 3.6 board with 24 piezos connected to the analog ins.

There is a possibility that you are suffering from an issue which causes problems when the analogue inputs are used from high impedance sources. See this.

with a 10k resistor in parallel

Note is your turn to show a circuit diagram. If that is truely in parallel it meet be sufficiently low to load the piezo down too far.

The board can only take up to 3.3v. is there a circuit you think may work?

Yeah, the one you showed in your first post, but with a Schottky diode from the output to your 3.3V supply to protect the microcontroller input. If this is too sensitive (and it's likely to be) then a resistor in parallel with the piezo may be needed.
 
The one in your first post (the one I replied to)



There is a possibility that you are suffering from an issue which causes problems when the analogue inputs are used from high impedance sources. See this.



Note is your turn to show a circuit diagram. If that is truely in parallel it meet be sufficiently low to load the piezo down too far.



Yeah, the one you showed in your first post, but with a Schottky diode from the output to your 3.3V supply to protect the microcontroller input. If this is too sensitive (and it's likely to be) then a resistor in parallel with the piezo may be needed.

I don't have the pinMode in the code. It works now but only when I play fast is there a problem. Can you show me a circuit I can put into spice and try it?
 

Attachments

  • schemat podłączenia.jpg
    schemat podłączenia.jpg
    29.3 KB · Views: 41
Reagards to loading the piezo with the Arduino input, a simple voltage follower opamp buffer may be all that is needed.
 
See my attachment. It shows a very simple voltage follower / buffer that will present a low impedance to the Arduino input.
The opamp shown is a Texas (Ti) part and is intended for low voltage use. It's output goes to within 100mV of 0V.
V2 on the input is you Piezo element.
D1 may not be absolutely necessary but is advisable. You could probably use a 1N4148 instead.
R2 on the output is just there for my simulation to check that the amp will drive a low impedance, don't include it in your circuit.
The value of R1 at the input can be played with to get the best response.
You don't have to use the Ti part. Something similar will most likely do. I have always used the CA3140 or CA3130 for single supply stuff.
 

Attachments

  • Buffer Voltage follower..pdf
    9.5 KB · Views: 35
See my attachment. It shows a very simple voltage follower / buffer that will present a low impedance to the Arduino input.
The opamp shown is a Texas (Ti) part and is intended for low voltage use. It's output goes to within 100mV of 0V.
V2 on the input is you Piezo element.
D1 may not be absolutely necessary but is advisable. You could probably use a 1N4148 instead.
R2 on the output is just there for my simulation to check that the amp will drive a low impedance, don't include it in your circuit.
The value of R1 at the input can be played with to get the best response.
You don't have to use the Ti part. Something similar will most likely do. I have always used the CA3140 or CA3130 for single supply stuff.
Thanks, I'll have to buy the components, I have some NE5532 op amps but I can't get anything from the outputs with any of the circuits, I just tried this circuit below and nothing. Maybe there bad. I just ordered some TI LM358s Will they work? If the circuit will detect the peak more accurately and maintain the original signal voltage then that sounds like what I need.
Thanks for your help I've been struggling with this for a while.Power-source-with-high-input-impedance.png
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
What are you trying to do?

The voltage on the piezo is going to be a rapidly decaying AC signal. Unloaded, it can be several 10s of volts -- easily enough to fry the inputs of sensitive circuits (your microcontroller and many op amps will count as sensitive).

I presumed you were using the piezo elements to detect when they are struck. Or are you doing something else?

A problem with using a circuit to convert the impedance is that you lose the ability to easily reset the circuit.

Your comment about having to play quickly seems to suggest that you want some sort of sustain after the input is doing detected. I recommend you do that in software.
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
This is the circuit I would recommend:

Piezi_input.png

C1 is the piezo element. The drawing tool I use for simple stuff I post here doesn't have a crystal symbol :-(

R1 is used to limit the amplitude of the pulse. This has effects in both the positive and negative cycles from the piezo. For a positive output it can limit the voltage which appears on C2 by loading down the element. This value needs to be chosen experimentally, a value between 10k and 1M will probably be required. The value also depends on the size of C2. For negative swings, this resistor limits the voltage from the crystal, protecting D1 from avalanche breakdown, and loss of voltage on C2, or even damage to other parts of the circuit.

D1 is a diode, preferably a small signal type. 1N4148 or 1N914 are ideal.

C2 is the capacitor used to hold the peak positive voltage. It should be between 1nF and 100nF depending on the impedance of your input, the time delay in reading the voltage, and the desired sensitivity of the circuit.

D2 is a shottky diode which bleeds off any voltage higher than the supply to prevent damage to the microcontroller.

Sensitivity is controlled by the element, R1 (higher = more sensitive), and C2 (lower = more sensitive).

The output of this will typically be a fast rising edge and a slow decay. you need to read the voltage often enough that the decay has not markedly changed the voltage (so maybe a hundred times per second is the minimum)

This circuit allows you to reset the voltage on the capacitor by changing your input pin to an output and forcing it low. This allows you to detect a small tap soon after a large bash on the element.

This circuit will tell you when the piezo has been hit, and how hard (use an analog input) but if you want to implement sustain, do it in software.
 
This is the circuit I would recommend:

View attachment 41995

C1 is the piezo element. The drawing tool I use for simple stuff I post here doesn't have a crystal symbol :-(

R1 is used to limit the amplitude of the pulse. This has effects in both the positive and negative cycles from the piezo. For a positive output it can limit the voltage which appears on C2 by loading down the element. This value needs to be chosen experimentally, a value between 10k and 1M will probably be required. The value also depends on the size of C2. For negative swings, this resistor limits the voltage from the crystal, protecting D1 from avalanche breakdown, and loss of voltage on C2, or even damage to other parts of the circuit.

D1 is a diode, preferably a small signal type. 1N4148 or 1N914 are ideal.

C2 is the capacitor used to hold the peak positive voltage. It should be between 1nF and 100nF depending on the impedance of your input, the time delay in reading the voltage, and the desired sensitivity of the circuit.

D2 is a shottky diode which bleeds off any voltage higher than the supply to prevent damage to the microcontroller.

Sensitivity is controlled by the element, R1 (higher = more sensitive), and C2 (lower = more sensitive).

The output of this will typically be a fast rising edge and a slow decay. you need to read the voltage often enough that the decay has not markedly changed the voltage (so maybe a hundred times per second is the minimum)

This circuit allows you to reset the voltage on the capacitor by changing your input pin to an output and forcing it low. This allows you to detect a small tap soon after a large bash on the element.

This circuit will tell you when the piezo has been hit, and how hard (use an analog input) but if you want to implement sustain, do it in software.
I appreciate the response but I tried several circuits similar to that and unless I amplify the piezo signal it won't be strong enough, that's why I'm trying using an op amp.
 
Last edited:

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
I appreciate the response but I tried several circuits similar to that and unless I amplify the piezo signal it won't be strong enough, that's why I'm trying using an op amp.

Interesting. The circuit works fine with an Arduino. The problem can be that it is too sensitive.
 
Top