Peak detector for piezo drum pad

Discussion in 'General Electronics Discussion' started by rle37, Jul 12, 2018.

  1. rle37

    rle37

    Joined:
    Jul 12, 2018
    Messages:
    22
    Likes Received:
    0
    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
     
    rle37, Jul 12, 2018
    #1
    1. Advertisements

  2. rle37

    Harald Kapp Moderator Moderator

    Joined:
    Nov 17, 2011
    Messages:
    8,451
    Likes Received:
    1,615
    Location:
    Germany-Europe-Earth-Sol System-Milky Way-Laniakea
    Try this site with a collection of circuits and explanations. I'm sure you can match the parameters to your needs.
     
    Harald Kapp, Jul 12, 2018
    #2
    1. Advertisements

  3. rle37

    rle37

    Joined:
    Jul 12, 2018
    Messages:
    22
    Likes Received:
    0
    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
     
    rle37, Jul 12, 2018
    #3
  4. rle37

    darren adcock

    Joined:
    Sep 26, 2016
    Messages:
    379
    Likes Received:
    28
    darren adcock, Jul 12, 2018
    #4
  5. rle37

    rle37

    Joined:
    Jul 12, 2018
    Messages:
    22
    Likes Received:
    0
    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
     
    rle37, Jul 12, 2018
    #5
  6. rle37

    WHONOES

    Joined:
    May 20, 2017
    Messages:
    554
    Likes Received:
    104
    Location:
    Oxfordshire
    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.
     
    WHONOES, Jul 12, 2018
    #6
  7. rle37

    (*steve*) ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd Moderator

    Joined:
    Jan 21, 2010
    Messages:
    24,463
    Likes Received:
    2,436
    Location:
    Mid way between Beijing and the Ronne Ice Shelf
    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.
     
    (*steve*), Jul 13, 2018
    #7
  8. rle37

    rle37

    Joined:
    Jul 12, 2018
    Messages:
    22
    Likes Received:
    0
    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?
     
    rle37, Jul 13, 2018
    #8
  9. rle37

    WHONOES

    Joined:
    May 20, 2017
    Messages:
    554
    Likes Received:
    104
    Location:
    Oxfordshire
    Can you measure the amplitude of the piezo pulse?
     
    WHONOES, Jul 13, 2018
    #9
  10. rle37

    (*steve*) ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd Moderator

    Joined:
    Jan 21, 2010
    Messages:
    24,463
    Likes Received:
    2,436
    Location:
    Mid way between Beijing and the Ronne Ice Shelf
    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.
     
    (*steve*), Jul 13, 2018
    #10
  11. rle37

    rle37

    Joined:
    Jul 12, 2018
    Messages:
    22
    Likes Received:
    0
    I only have a multimeter which reads about 2v max
     
    rle37, Jul 13, 2018
    #11
  12. rle37

    rle37

    Joined:
    Jul 12, 2018
    Messages:
    22
    Likes Received:
    0
    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?
     

    Attached Files:

    rle37, Jul 13, 2018
    #12
  13. rle37

    WHONOES

    Joined:
    May 20, 2017
    Messages:
    554
    Likes Received:
    104
    Location:
    Oxfordshire
    Reagards to loading the piezo with the Arduino input, a simple voltage follower opamp buffer may be all that is needed.
     
    WHONOES, Jul 13, 2018
    #13
  14. rle37

    rle37

    Joined:
    Jul 12, 2018
    Messages:
    22
    Likes Received:
    0
    can you show me an example , I don't know how to do this stuff
     
    rle37, Jul 13, 2018
    #14
  15. rle37

    WHONOES

    Joined:
    May 20, 2017
    Messages:
    554
    Likes Received:
    104
    Location:
    Oxfordshire
    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.
     

    Attached Files:

    WHONOES, Jul 13, 2018
    #15
  16. rle37

    rle37

    Joined:
    Jul 12, 2018
    Messages:
    22
    Likes Received:
    0
    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
     
    rle37, Jul 13, 2018
    #16
  17. rle37

    (*steve*) ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd Moderator

    Joined:
    Jan 21, 2010
    Messages:
    24,463
    Likes Received:
    2,436
    Location:
    Mid way between Beijing and the Ronne Ice Shelf
    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*), Jul 13, 2018
    #17
  18. rle37

    (*steve*) ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd Moderator

    Joined:
    Jan 21, 2010
    Messages:
    24,463
    Likes Received:
    2,436
    Location:
    Mid way between Beijing and the Ronne Ice Shelf
    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.
     
    (*steve*), Jul 14, 2018
    #18
    darren adcock likes this.
  19. rle37

    rle37

    Joined:
    Jul 12, 2018
    Messages:
    22
    Likes Received:
    0
    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: Jul 14, 2018
    rle37, Jul 14, 2018
    #19
  20. rle37

    (*steve*) ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd Moderator

    Joined:
    Jan 21, 2010
    Messages:
    24,463
    Likes Received:
    2,436
    Location:
    Mid way between Beijing and the Ronne Ice Shelf
    Interesting. The circuit works fine with an Arduino. The problem can be that it is too sensitive.
     
    (*steve*), Jul 14, 2018
    #20
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.