Loud Piezo Tones

hippy

Technical Support
Staff member
Using HPWM gives extra-loud piezo tones by pushing an out of phase signal through the piezo, equivalent to changing from a 0V/5V signal to 0V/10V signal.

Any of the out of phase HPWM pin pairs can be used ( AB, AD, BC, CD ), adjust the %1111 and %1010 as appropriate; this example should work with any of the pin pair combinations.

Be aware that this mechanism can generate high volume sound so suitable safety precautions to protect hearing must be taken before running the example program. Those who suffer from audiogenic seizures (AGS), other sound-induced epileptic responses or similar should not use this program.

' Generates 4kHz for a PICAXE at 4MHz

For b0 = 1 To 5
HPwm pwmSingle, pwmLHLH, %1010, 255, 513 ' Normal
Pause 500
HPwm pwmSingle, pwmLHLH, %1111, 255, 513 ' Louder
Pause 500
Next

I don't know what the maximum voltage allowed across a piezo is but even greater volumes could be achieved by using a MAX232 or similar which will push the equivalent of 0V/24V through the piezo. If a higher supply voltage is available a transistor or FET can probably be used with just a single PWM signal. The advantage of HPWM is that it allows two volume levels to be set, more could likely be achieved by using various R's on the HPWM outputs.
 

inglewoodpete

Senior Member
The maximum voltage recommended across a piezo transducer will vary from model to model. This standard 30mm version available is Australia can take 30v. Note that this is larger than to one typically supplied with PICAXE kits.

I have used 27 volts to drive a piezo (3 x 9v battery) and it is VERY loud: enough to make my eardrums touch in the middle :)
 

westaust55

Moderator
MicroZed in AUstralia also have a 90mm diameter piezo speaker.
http://www.microzed.com.au/beepers.html

Even with direct drive at 5V from a PICAXE chip or taking speech from an SPE030 module it is sufficiently loud that it can be heard some distance away (eg in an adjoining room). Unfortunately MicroZed have no specs on these but certainly louder at a nominal 4.5 to 5V than the flat disk types.
 
Last edited:

cactusface

Senior Member
HPWM and Piezo sounds...

Hi Hippy,
Talking of HPWM as we were in a very different post! this post seems to imply that HPWM's outputs are out of phase voltage wise that is. Do we get -5v and +5v, not sure where the 10v come from.
I have an assortment of Piezo sounders (OK 3 or 4) but can't get much sound from them at all, even using a transistor, etc.

It's a bit late in the day now, but I will have to try your code tomorrow...

Regards
Mel
 

hippy

Technical Support
Staff member
No the signals are both 0V and 5V. In this usage one signal is the inverse of the other.

If you have a piezo on a single output and connected to 0V you will get +current flow when the output is high, zero current when not.

If you connect a piezo between two signal lines, one inverted, when one signal is high the other is low so you get the same +current, when the first signal goes goes low the other goes high ( as opposed to staying at 0V ) so current then flows the other way, -current.

If you plot current on a graph you'll get a + phase then a - phase. If you had used a single output but doubled the voltage, you'd see exactly the same sized plot. Thus a piezo between two inverse signal lines ( 0V/5V ) is the same as between a single signal line of 10V with the other to 0V -

Code:
              _   _   _   _
+5V / 0V  ___| |_| |_| |_| |
              _   _   _   _
+current  ___| | | | | | | |
-current       |_| |_| |_|
              _   _   _   _
             | | | | | | | |
+10V / 0V ___| |_| |_| |_| |
 
Last edited:

westaust55

Moderator
Louder Piezo Tones

As a further basic description of what hippy is describing,

The piezo device physical surface moves (slightly) in proportion to the magnitude of the current.

If you make the current positive (+ve) then the piezo crystal surface moves a certain amount.

When you return to zero volts, the piezo crystal surface returns to the orginal/netural position, so in effect ithe surface moves x micro/nano metres

If however instead of just returning to 0 volts, you reverse the polarity then the current flow is negative (-ve) relative to the initial current flow, and now the surface of the piezo crystal will move nominally the same distance in the opposite direction past the orginal/netural position.

Thus by reversing the polarity, the piezo crystal surface moves (roughly) double the distance which will result in greater air movement and a louder sound pressure = greater voluume.
 

hippy

Technical Support
Staff member
Thanks, westaust55. That's a much clearer explanation than I perhaps had.
 
Top