Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Piezo Differential Drive: Via Software or Hardware?

Status
Not open for further replies.

joshsstuff

New Member
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?
 
See my replies in the thread below from about 13 years ago ... https://forums.parallax.com/discussion/62310/amplifying-piezo-speaker
Thank You, I fetched your post and explanation.

If you can't provide a solution in software by sacrificing two pins that you can drive 180 Deg out of phase
to supply a piezo, then the below circuit may be of some use to you. It is basically a two transistor inverter
designed to be able to handle a floating input. At rest (INPUT) mode each B-E transistor junction "sees"
approximately 0.45 volts thus ensuring that both transistors are OFF. When the signal goes to +5V or GND,
the appropriate transistor is turned ON while the opposing transistor remains OFF. The voltages in the
schematic next to each resistor reflect the actual measured value, as opposed to a calculated value.
While only consuming about 3mA, the overall design provides a significant volume improvement particularly
noticeable at non-resonate frequencies.

inverter.gif

So we are using an NPN and PNP transistor to handle the inversion of the Piezo.
Is the 3mA while in operation only? (because my project will be on battery power)
Do you know what the quiescent current of this circuit would be?

I'm off to get some parts together to try it out:)
 
I found a solution online where you could use 2 MCU pins (instead of 1 pin & ground) to effectively double the output!
This works!

We know, it's a common technique called 'bridging' - I had a letter published years back in Practical Electronics for a modification to one of their published designs, where I used a second I/O pin to 'bridge' the output, greatly increasing the volume of the piezo.

However, it doesn't 'double' the output, it quadruples it :D - even better!!.

Your problem, obviously, is wanting to use the Tone instruction on the Arduino - I would suggest you copy and modify the Arduino Tone code (the source is freely available) to add bridging to it (perhaps calling it BTone?). It would then be just as easy to use from within the Arduino IDE
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top