Maker Pro
Maker Pro

Piezo Differential Drive: Via Software or Hardware?

joshzstuff

Jul 4, 2010
49
Joined
Jul 4, 2010
Messages
49
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:
NOT_transistor.JPG


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?
 

Attachments

  • NOT_transistor.JPG
    NOT_transistor.JPG
    45.4 KB · Views: 95

Harald Kapp

Moderator
Moderator
Nov 17, 2011
12,890
Joined
Nov 17, 2011
Messages
12,890
You can use e.g. a 74vhc14 inverter chip:
upload_2017-10-22_19-10-38.png

Note that within one 75VHC14 there are 6 inverters. You can use them in parallel to increase drive strength as shown:
upload_2017-10-22_19-12-42.png
If you don't want to use the other 5 inverters, tie their inputs to either Vcc or ground, do not leave them unconnected!

Ignore the unconnected bubble on the lower left corner of the gates in my schematic. These are artefacts from the program I used to draw the circuit. These are not available as either inputs or outputs on the real chip.

You could also build a full inverter from discrete transistors, but that's going to be much more expensive.
 
Top