Piezo Differential Drive: Via Software or Hardware? - Page 1
Forum section: electronics / projects

author: Joshsstuff
author_rank: Contributor
timestamp: October 22, 2017, 12:50:23 am
content: My Arduino project is a level indicator that uses a Piezo transducer.I've used the "tone" function to manipulate the sound to raise the pitch when the desired level is reached.With the 'tone' function I can very precisely control the pitch and speed of the speaker.However, the project runs from a Lipo battery, and even with 5 volts, the transducers i've tried don't get very loud.I wish to limit my projects size and complexity as much as possible.This is why I'd rather not use a boost converter simply for the piezo part of the circuit.Differential drive:?I found a solution online where you could use 2 MCU pins (instead of 1 pin & ground) to effectively double the output!This works!As long as you turn on one pin and the other off simultaneously the effect is a doubling of the piezo voltage.(I think that the 2nd pin in the (LOW) state is also able to source some current, however it does not work if I try to replace the ground with an MCU GPIO pin)This is very simple to do, I used boolean logic in my demo sketch:digitalWrite(Pin_1, ringState);digitalWrite(Pin_2, !ringState);The problem with software differential drive: the tone() function compatibility.The Tone function makes the frequency voicings I require possible (and simplifies the sketch considerably from direct control)The Tone function takes control of a MCU timer, and I'm pretty certain you cannot have 2 'tone' functions running at once(i.e. a "tone()" and one "!Tone()" to drive the other pin)I would have to litter my sketch with" digitalWrite(Pin_2, !ringState); calls to try to switch the differential pin in time, but I don't think that even this would work.I'm open to code suggestions if you have an idea that might work.Hardware:?What type of inverting logic would I need that would provide Vcc to the other side of the Piezo when the MCU driver pin was LOW?I know that you can create simple NOT logic from a single NPN transistor:I can't just replace the MCU pin for the push button and the Piezo for the LED, but is there a way to change this around to make it work?Or, should I use a different inverting component?

author: Rerouter
author_rank: Super Contributor
timestamp: October 22, 2017, 08:37:43 am
content: Instead why not use an inductive boost, piezo's have a quite high impedance, so you can use an inductor to flyback pulses in to it, by limiting how much current can flow through the inductor, and by having a resistance in parrellel with the piezo you can ensure it decays in a way that will give clean transistion.

author: Zero999
author_rank: Super Contributor
timestamp: October 22, 2017, 09:26:01 am
content: The transistor inverter has a relatively high impedance, when the output is high, which might cancel out the benefits differential drive.There are plenty of inverter ICs available such as the 74HC04. Unfortunately, it's a relatively large IC, with 14 pins. If space is an issue, then it's available in single, dual and three gate versions.https://assets.nexperia.com/documents/data-sheet/74HC_HCT1G04.pdfhttps://assets.nexperia.com/documents/data-sheet/74HC_HCT2G04.pdfhttps://assets.nexperia.com/documents/data-sheet/74HC_HCT3G04.pdfIt can be done with one gate but it will be more reliable with three, since a gate can be used as a buffer, so there's no loading on the MCU output pin.If you need any more volume, then there are ICs available with built-in charge pumps.https://www.diodes.com/assets/Datasheets/PAM8904Q.pdfhttps://www.njr.com/semicon/PDF/NJU72501_E.pdf

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: October 22, 2017, 09:44:16 am
content: This is the problem with Arduino. Instead of writing some simple code, or taking the source for the Arduino code and modifying it, people resort to unnecessary hardware solutions.Just take the source for "tone" and modify it to twiddle two pins to produce the differential waveform.If you need it even louder, then the simplest way is to use an external NPN transistor or MOSFET (rated at least 30V) driven by the tone pin, with an inductor of 10-100mH (Yes, Millihenries) from the collector/drain to the positive supply, and put the transducer across the inductor.Select inductor type for best volume - there is a tradeoff between inductance and series resistance, but it's not too critical - it will mostly alyter the frequency response doe to resonance of the inductor with the transducer's capacitance.Just make sure you don't energise it with the transducer disconnected as the voltage produced may be high enough to kill the transistor.Another method is to use a high frequency PWM to drive a simple boost converter and drive the sounder with an external H-bridge powered from the boosted voltage. An advantage of this is you can use a much smaller inductor.

author: SeanB
author_rank: Super Contributor
timestamp: October 22, 2017, 10:11:59 am
content: I will add as well if you are using the 2 inverter rive method, include a series 100n-1uF ceramic capacitor in series with the drive to the piezo disk. The disks themselves often do not like a DC bias applied for long periods, and can either corrode if there is any adsorbed moisture, or gain a permanent set on them. They then either have the wire to the middle fall off, or the metal on the disk erodes away leaving a green crud layer, or it goes short circuit or low volume.Agree with Mike though, use the one transistor driver and inductor, with a bonus of needing only a very narrow drive pulse to excite the piezo, which can be a good power saving. Use a local decoupling capacitor near the driver though, the current pulses in the circuit can be suprisingly high and have nasty unintended effects elsewhere.

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: October 22, 2017, 10:49:18 am
content: Quote from: SeanB on October 22, 2017, 10:11:59 amYou can use pulse width to control the volume - up to 50% duty cycle - any more just wastes power

author: Zero999
author_rank: Super Contributor
timestamp: October 22, 2017, 12:16:47 pm
content: Quote from: SeanB on October 22, 2017, 10:11:59 amI have heard about that before.A capacitor on its own might not be good enough, since piezo transducers have a high DC impedance and the leakage current is probably similar to the capacitor. A high value resistor, 100k to 1M, in parallel with the transducer will reduce the DC voltage to a negligible level.