{"items": [{"author": "Scott", "source_link": "https://www.facebook.com/jefftk/posts/631752271262?comment_id=631758074632", "anchor": "fb-631758074632", "service": "fb", "text": "Are you trying to make a linear amplifier or just an event detector?  If you're using an opamp and an ADC it sounds like you want a linear circuit.<br><br>One typically does not use an opamp open-loop like that.  A feedback network is required to make the opamp into a linear amplifier with the gain of your choosing.  The LM124 has a unity gain bandwidth of 1 MHz, so with a 100:1 feedback network, you could maintain 100x gain over 10kHz of bandwidth, which is sufficient for audio.<br><br>The other problem is DC operating point.  I'm not sure if an opamp operating from a single supply will be able to work the the piezo element unless some kind of DC biasing network is applied to the signal.  The JFET buffer amps I see for use with piezos on the 'net use the MPF102 which is a depletion-mode JFET, so it works even when the DC input is at ground and the circuit is operating from a single supply.", "timestamp": "1381873887"}, {"author": "Jeff&nbsp;Kaufman", "source_link": "https://www.facebook.com/jefftk/posts/631752271262?comment_id=631761013742", "anchor": "fb-631761013742", "service": "fb", "text": "@Scott: \"it sounds like you want a linear circuit\"<br><br>Yup.  Making an event detector would be ok if as output I could also determine how loud the event was, but I think that's hard.  So I'm just trying to get a rough audio signal into the computer so I can process it.<br><br>\"One typically does not use an opamp open-loop like that\"<br><br>A bit of reading sounds like my configuration would give maximum gain, which is probably not what I want because then I would lose the distinction between the piezo detecting a moderately strong thump and a very strong thump.  Unless it happens that the gain is exactly right.  (It's ok if the gain is a bit too weak, because the ADC has several more bits of resolution than I really need.)<br><br>Intuitively I should be able to fix this by putting a variable resistor between each piezo and its opamp, but its probably not the right way to do it.  Maybe good enough for just detecting how hard the piezo was hit, though?<br><br>Reading more about opamps (http://zebu.uoregon.edu/~rayfrey/431/notes9.pdf) it looks like people usually put an additional resistor in parallel with the opamp to make a negative feedback network, and I don't understand how it works.  But I could experiment with variable resistors until I got something that worked well.  Or I could measure the output of the piezo and do some math.  Which is probably the right way to do it.<br><br>\"I'm not sure if an opamp operating from a single supply will be able to work the the piezo element\"<br><br>I thought the reason people used buffer amps was because piezos provide accurate signals only when attached to something with a very high impedance input?  But I don't care about frequency distortions: I only want something very rough.  I only need to get the computer to be able to ask \"did they just hit it?\" and \"if so, how hard\"?", "timestamp": "1381875614"}, {"author": "Scott", "source_link": "https://www.facebook.com/jefftk/posts/631752271262?comment_id=631767615512", "anchor": "fb-631767615512", "service": "fb", "text": "\"A bit of reading sounds like my configuration would give maximum gain\"<br><br>It would, but it also probably would not work.  The gain of an opamp is generally assumed to be some huge number that can't be relied upon to be exact.  The datasheet for the LM124 specifies the DC gain as 100 dB or also 100 V / mV = 100,000.  Every opamp also has a random offset (1-3 mV in the datasheet depending on variant).  3e-3*100e3 = 300 V!  If the power supply is only 5 V, this means that the output of the opamp will very likely be pinned at one supply rail or the other, unless the input is large enough to overcome this offset.  If it does, then, due to the huge gain, the output will likely slew to the opposite rail.<br><br>The purpose of the feedback network is to design the unreliable huge opamp gain out of the circuit and replace it with a value easily controlled by passives.  For example, in the non-inverting opamp config, a resistor divider network feeds back some of the output to the input (eg http://www.radio-electronics.com/.../op-amp_basic_non_inv....  note this non-inverting configuration also preserves the high input impedance of the opamp, which the inverting opamp does not.)  From some simple analysis, A_v = A/(1+A*f).  A_v is the closed-loop gain, A is the open-loop gain (eg 100,000) and f is the feedback ratio, say 0.01 (f = R1/(R1+R2), R1 = 1k, R2 = 99k).  A_v becomes very nearly 1/0.01 = 100 if A is large.<br><br>\"I thought the reason people used buffer amps was because piezos provide accurate signals only when attached to something with a very high impedance input?\"<br><br>That is true.  Opamps and JFETS have high impedance inputs.  But I'm talking about the DC operating point.   The MCP3004 input voltage range is 2.7 to 5.5V.  So if we run the MCP at 5V, then we should run the opamp at 5V as well.  I'm not sure exactly how the piezo works at DC, but I think in the absence of any biasing, its output is centered at 0V.  That means we'd like the opamp to run at +/- 5V to center the piezo output to the opamp's input.  Otherwise we'll get half-wave rectified signals.  Maybe that's fine since you'll still be getting intensity information.  The depletion mode JFET buffer works though with its input signal centered on ground, even with a single supply, because of the physics of the device, and because the JFET buffer output can also be set at a different DC voltage from its input which the designer chooses through a combination of drain and source resistors.", "timestamp": "1381878894"}, {"author": "Michael", "source_link": "https://www.facebook.com/jefftk/posts/631752271262?comment_id=631768124492", "anchor": "fb-631768124492", "service": "fb", "text": "It sounds like you may have no reason to use MIDI, which will introduce small but human-detectable delays into your drum machine.  Most commercial drum machines don't use MIDI as the primary interface between triggers and synth for that reason, though many of them also output to MIDI for a variety of purposes, including driving a sample library from some outboard source.  I don't know whether the delays added by MIDI would be particularly noticeable at the tempi common in contra dance music; this may be an issue that doesn't matter for this purpose.<br><br>There's an interesting design out there for an Arduino-based drum controller that uses a laptop (or other portable computer) for the actual synthesis, using the Arduino just for detection.  http://drummaster.digitalcave.ca/drummaster/<br><br>It seems more complex than you need, but should be possible to scale back and still have room for future enhancement (what about a hand-controller as well? I'd like an electronic bodhran myself!)", "timestamp": "1381879191"}, {"author": "Eric", "source_link": "https://plus.google.com/113202109784097860410", "anchor": "gp-1381907901177", "service": "gp", "text": "A practical thing about piezos is that while the normal output voltage is very small, if you hit them with a hammer you can get thousands of volts, with very low amperage. This will fry most chips. \u00a0Adding zener diodes across the piezo and using an op-amp that is rated for at least a few kV of ESD, should cut down on the odds of this dying on you. \u00a0", "timestamp": 1381907901}, {"author": "Jeff&nbsp;Kaufman", "source_link": "https://www.facebook.com/jefftk/posts/631752271262?comment_id=631828368762", "anchor": "fb-631828368762", "service": "fb", "text": "@Scott: That makes a lot of sense!  I'll set it up as a standard non-inverting opamp.<br><br>\"Maybe that's fine since you'll still be getting intensity information.\"<br><br>I think so.  I wonder if I need to run it through a diode to avoid giving the MCP -5V and hurting it.", "timestamp": "1381928331"}, {"author": "Jeff&nbsp;Kaufman", "source_link": "https://www.facebook.com/jefftk/posts/631752271262?comment_id=631829197102", "anchor": "fb-631829197102", "service": "fb", "text": "@Michael: \"MIDI, which will introduce small but human-detectable delays into your drum machine\"<br><br>Really?  When I've used midi with keyboards I have been able to set it up in ways that don't have perceptible latency.  Are we more sensitive to latency with drums?<br><br>But you're right; if I'm doing synthesis on the PI I probably won't need to go via midi.<br><br>\"It seems more complex than you need\"<br><br>Possibly not.  It depends on what sample rate I can get.  Looking at http://drummaster.digitalcave.ca/drummaster/design.jsp it looks like my current design requires a very high sample rate in order to reliably detect the height of the first peak.  I'm not sure that would work, so their filtering is probably the right way to go.  And this looks like nearly exactly what I want: http://drummaster.digitalcave.ca/.../schematic_4_channel.png<br><br>Thanks for finding this!", "timestamp": "1381929083"}, {"author": "Scott", "source_link": "https://www.facebook.com/jefftk/posts/631752271262?comment_id=631863697962", "anchor": "fb-631863697962", "service": "fb", "text": "The \"Drum Master\" link from Michael is informative.  I think if you just want sound envelope information, feeding the piezo output into an opamp circuit running off a single 5V supply (thus no way to produce -5V) would probably produce something very similar to the piezo strike waveform in the \"Drum Master.\" Notice it's clipped on the bottom, but the envelope is still detectable.  You can of course, if desired, implement the envelope detector in software.  The MCP can handle 200kS/s, so you will see no aliasing effects at that rate, but then the R-Pi has to handle all that information at that speed.<br><br>One thing I'm curious about is the voltage signal level.  In your original diagram, you suggested the piezo signal would be a few mV, but according to the \"drum master\" the signal will be hundreds of mV!  He uses a diode-R-C envelope detector circuit, which implies that the piezo signal is strong enough to not require amplification at all, since it can break through a diode drop.  I think some investigation is needed to find out how much signal you are really going to get.  Maybe the \"drum master\" only works if you're pounding it hard with drumsticks?", "timestamp": "1381944262"}, {"author": "Jeff&nbsp;Kaufman", "source_link": "https://www.facebook.com/jefftk/posts/631752271262?comment_id=631864152052", "anchor": "fb-631864152052", "service": "fb", "text": "@Scott: \"you suggested the piezo signal would be a few mV, but according to the \"drum master\" the signal will be hundreds of mV!\"<br><br>The real issue is that I don't really know.  The piezos don't make it clear in their packaging.  I need to get one and measure it.", "timestamp": "1381944594"}]}