NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Basic Electronics » Piezo over-voltage

February 15, 2010
by bretm
bretm's Avatar

I want to hook a piezoelectric drum trigger (a drum pad from an electronic drum) up to the microcontroller. I don't think I need the amplifier circuit used in the sound meter demo because the voltages that result from a strike of the drum are already quite high. In fact, a hard hit can generate dozens of volts from the piezo that I'm using.

And that's my concern. Can I hook that directly up to an A/D input pin (with a current-limiting resistor) without damaging the atmega? The voltage is high but the high voltage is very brief. The datasheet "I/O Pin Equivalent Schematic" shows diodes to protect against over and under-voltage. The "Absolute Maximum Ratings" says not to exceed Vcc+0.5V, but is that just a DC characteristic since it also lists that under Vih1 in the DC characteristics table, so that a transient AC over-voltage might be OK?

February 16, 2010
by Frozenlock
Frozenlock's Avatar

Were I you, I would add an op-amp. This way, the signal sent should never exceed Vcc (minus perhaps a volt, characteristic of your op-amp). If the high voltage ever proves to be damaging, the only piece to replace will be this cheap op-amp, and not the MCU.

In addition, the current limiting resistor might simply kill the biggest part of your signal. When I was making music with the MCU (see the tutorial ), whenever I put a resistor in series with the piezo, the sound was noticeably lower.

trigger

Frozenlock

February 16, 2010
by BobaMosfet
BobaMosfet's Avatar

Allowing too much voltage is a good way to fry your MCU. Us a resistor limit to 5 volts, keeping in mind the current rating for the pins on the ADCs. If you want a strong output elsewhere, then use a BJT transistor or an op-amp (like the humble 741).

BM

February 16, 2010
by BobaMosfet
BobaMosfet's Avatar

If you are receiving an AC signal, you MUST rectify it to DC, and use a capacitor to smooth out the ripple at the very least before you put it into the ADC. You'll still see a ripple. Use other methods after it's rectified if you need something without ripple.

February 16, 2010
by bretm
bretm's Avatar

It's AC. In that op-amp circuit, wouldn't it be a problem if the (-) input went well below GND or above +5V?

What does R2 do?

February 16, 2010
by bretm
bretm's Avatar

This shows limiting the voltage with a zener diode and a resistor. That seems like it would work, for both positive over-voltage and AC rectification (half-wave is fine for this). It doesn't have anything limiting the current through the diode, but the piezo doesn't seem to generate much current.

February 16, 2010
by Frozenlock
Frozenlock's Avatar

Well, depending on your op-amp, you can go at quite high voltage, but not very low below GND. For example, the lm358 can go from -0.3V to 32V.

Using op-amps, I've never fried one (yet) using a piezo. I can't guarantee it won't happen, but like I said, an op-amp is less expensive than a MCU.

The two resistors in the schematic is what determine the gain. You need to choose them in function of what you need.

Do you want a to use the MCU's input as analog or digital?

February 16, 2010
by bretm
bretm's Avatar

I want to use analog input. I was thinking a simple voltage-follower configuration would be fine. The piezo generates big voltages in both the negative and positive directions and I'm fine with clipping the negative out completely.

What's the gain equation for that op-amp configuration? I've seen plenty of examples with two resistors in the negative feedback path, but not that configuration with one resistor between + and GND. How does that influence the gain? Isn't the non-inverting input still always at 0V?

February 16, 2010
by bretm
bretm's Avatar

I bread-boarded the zener diode and 1M resistor in parallel and it seems to have very good characteristics, very close to what I want it to do. It even seems to be doing something like logarithmic output which is a really nice bonus. Is that possible? I don't have a signal generator so I'm just whacking the drum head really hard. :-) When I do that, I still get a legible signal, not clamped, just like when I do smaller hits, but a slightly larger magnitude. Does that make sense? In other words it's still very sensitive to small taps, but I still get a nice-looking wave-form with very hard hits.

There's probably nowhere near the correct amount of "Izt" current for the zener diode to be acting like a shunt voltage regular, so could I be getting a logarithmic response in that case? I've seen diodes used in op-amp negative feedback to get a logarithmic response, but there's no amplifier here.

The only downside that I can see on the scope is that it swings negative to about -0.6V, presumably the diode's forward voltage drop.

February 16, 2010
by bretm
bretm's Avatar

AH HA! I love when I feel like I'm learning stuff. The diode's V-I response is exponential, which means if you flip it around, the "I-V" response is logarithmic. Linear increases in input current result in logarithmic increases in voltage. This is exactly what I wanted and I just stumbled on it. Maybe some day I'll understand this stuff well enough that I can go straight from "what I want" to a circuit design without the serendipity part in the middle.

I verified this by making this circuit:

Diode test circuit

The transistor is just a common-collector voltage-follower to isolate the voltage divider from the rest of the circuit.

I incremented the voltage at V0 by 0.5V at a time and observed the voltage at V1. It came out like this:

V0      V1
0       0
0.499   0.455
1.000   0.883
1.503   1.207
2.007   1.402
2.497   1.522
3.007   1.607
3.505   1.671
3.994   1.721

From V1 you can get the current through R2, which should be the same as the current through D1. When you plot V vs I for D1, you see the exponential response, but what I care about is when you plot V0 vs V1 you see a logarithmic response.

So I think my final circuit is just this:

Piezo input buffer

The positive voltage is logarithmic in the normal range and capped to 5V by the zener behavior. The small negative voltage from the forward-bias voltage drop of the diode I'm using is -0.587V, which isn't far from the -0.5V the AVR specs say it can handle. Worth the risk?

Now my only problem is that my output impedance is very high. Is the input impedance of an ADC input pin going to be too low? I can't find it listed in the Atmega spec.

February 17, 2010
by Frozenlock
Frozenlock's Avatar

Hmm, it seems I wired my op-amp backward in the schematic, thanks for pointing it out. I'll check my breadboard later to see if I did the same mistake IRL. Hope I didn't!

For your project, did you check if the ADC is fast enough?

February 17, 2010
by bretm
bretm's Avatar

I wasn't saying it was backwards. It doesn't seem to be. At worst you'll be inverting an AC signal which doesn't matter in many cases. But the (-) on the piezo jumper is connected to (-) on the op-amp, so positive voltage from the piezo will generate a positive swing on the op-amp. So far so good.

No, what I don't get is how R2 affects gain. The input impedance for the op-amp is extremely large, like 10^13 ohms for the OPA344U, so how does adding a small resistor in series with that affect anything?

February 17, 2010
by Frozenlock
Frozenlock's Avatar

I have no idea :-p

That's why I told it was backward; usually R2 would be on the other side, connected with the piezo...

I've checked my breadboard and it's wired exactly like shown. I will re-install the NerdKit on it and check if everything works like it should. In the present configuration, I think the gain is determined in part by the wire's resistance. When I first tried it, I only required a big gain, not a precise one. This would explain why the R2 to GND didn't reveal itself in the results.

Anyway, let's return to your project. I've done a quick search and it seems the usual impedance for an Atmel's input is around 1M Ohm. My limited knowledge about this keeps me from saying if it's going to work with your circuit.

Looking around, I've found this and this. It's a way to obtain logarithmic results with an op-amp. (In case your circuit impedance is too high).

Another solution might be to isolate your circuit by using a follower.

February 17, 2010
by bretm
bretm's Avatar

I tried that op-amp logarithmic amplifier, but I didn't get good results. I've since determined it's because the LM741's that I have just aren't going to cut it. With a 5V single-supply configuration, I can't get the output to go below +2V. So I'm going to need an op-amp that will go all the way to V- on the down-swings. Digikey has a filter for "rail-to-rail" for the op-amp listings, which makes it easy.

Or I may be able to skip the op-amp stage and hook it up directly after diode conditioning. This article seems to imply that I can do that.

The only thing I found in the Atmega spec is that the ADC inputs are "optimized" for 10k or less, but that may just be to optimize the charging time of the internal capacitor. I may just get a slow 260us conversion time when using a high-impedance input. I'm just going to write some code and try it. The sample & hold capacitor is a tiny 14pF, so with the low frequencies I'm working with it's going to present a pretty high impedance.

February 18, 2010
by Rick_S
Rick_S's Avatar

I'm a bit late to jump in but I came across this and it reminded me of your project. This link describes the building of piezo drums interfaced to an arduino. (Essentially a nerdkit with a different bootloader). Maybe some of that info would be of help. It looks as though they just used resistors and diodes...

Rick

Post a Reply

Please log in to post a reply.

Did you know that multiple MOSFETs can be used in parallel to switch bigger currents on and off? Learn more...