PDA

View Full Version : Driving a piezo with the sound function



Christopher4187
- 25th June 2009, 18:51
I'd like to use a piezo buzzer for my application. I've ordered abotu 10 of them, all different sizes, and connected it to a 16F870 just like the PBP manual states (in the "sound" portion). It says to use a 10uF cap and that it will work.

Well, it works but the volume is really low. How can I increase this volume on the piezo? Perhaps something easy with one or two components?

I am using a 9V battery with a 5V regulator.

Thanks!

Melanie
- 25th June 2009, 19:33
There are three kinds of Piezo things that make a noise...

1. Piezo Transducer
2. Piezo Buzzer
3. Piezo Loudspeaker

The first, Piezo Transducer makes a hell of a noise if you hit it at it's RESONANT FREQUENCY (eg 4kHz). The further away from it's preferred comfort zone, the crappier the sound. If you just connect a DC voltage to it, it usually just goes 'click'.

The second is a Piezo Buzzer. You simply connect a DC voltage to it, and it makes a noise... it doesn't need any kind of external drive as it has an oscillator built-in (if you apply external drive you will usually get a horrible mess of a sound).

Finally is the Piezo Speaker... much harder to find (and more expensive) than types 1 or 2. If you need one badly for your PIC, rip apart your friends most expensive prized LCD monitor.

Sounds to me like you've got option 1 - unless it's not a Piezo...

If you have got Option 1, then coupling it with 100nF is more than sufficient... find the correct Resonant Frequency (Datasheet) and it'll fill your world with noise...

Christopher4187
- 25th June 2009, 19:55
Thanks for the reply. As an example, I've got two types. One is a self drive and the other is an external drive but both are piezo buzzers. The part numbers (Digi-key) are 102-1146-ND and 102-1135-ND respectively.

If I understand correctly, I can use a 100nF cap in series with the buzzer and hit the resonant frequency (which appears to be 8, 16 or 20 KHz) and it will be loud? If I read the PBP manual correctly, the highest it will be is 20 Khz, correct?

So, with a 100nF cap, one side of the buzzer connected to ground and with this line of code:

SOUND PORTB.7,[250,10]

This should get my ear drums bleeding? :0)

Melanie
- 25th June 2009, 21:41
I tend to find the Piezo Transducers need a little experimenting to hit it just right... and in typical Melanie fashion I don't use the in-built PBP Commands and tend to roll my own...

Here's what works for me...





BeepToneHi var Byte ' Variable for Beep High-Period
BeepToneLo var Byte ' Variable for Beep Low-Period
BeepLength var Word ' Number of Repitition Cycles to execute


'
' Subroutine Produces Standard Beep for 2 Seconds
' -----------------------------------------------
BeepTwoSeconds:
BeepLength=8800 ' For Two Seconds
Goto BeepRAW
'
' Subroutine Produces Standard Beep for 100mS
' -------------------------------------------
BeepShort:
BeepLength=435 ' For 100mS
Goto BeepRAW
'
' Subroutine Produces Standard Beep for 250mS
' -------------------------------------------
Beep:
BeepLength=1100 ' For 250mS
BeepRaw:
BeepToneHi=111
BeepToneLo=BeepToneHi-49
For CounterC=0 to BeepLength
High Beeper
PauseUS BeepToneHi
Low Beeper
PauseUS BeepToneLo
Next CounterC
Return

Let me tell you how sharply the roll-off is for a Piezo... for me BeepTone=111 is just right... 113 or higher gives about 12dB less Sound Output, 109 or lower similarly.

I literally sat there with a Scope and a For-Next Loop giving me a two-second burst of every value from 50 to 200 to finally decide what value was loudest!

rsocor01
- 26th June 2009, 00:18
Hi,

I also bought me a piezo buzzer from mouser (see link below) and using it with the commands SOUND and FREQOUT at the resonance frequency 4MHz didn't help too much. The sound was very low. It was even worst when I installed the PCB board with the buzzer attached to it inside a plastic enclosure. Inside the enclosure you can barely hear the buzzer.

I will give it a try to Melany suggestion of using a square wave for the buzzer.

Robert

http://www.mouser.com/Search/ProductDetail.aspx?qs=d7g9p1yFhWaOLjub80XcMw%3d%3d

falingtrea
- 26th June 2009, 19:19
At the end of the data sheet is a suggested driver circuit. You may also want to try it. The data does not show any current requirements for thsi part so maybe the PIC can't drive it hard enough?

wjsmarine
- 27th June 2009, 10:49
Hi Folks,

I use the piezo transducer types (need to be frequency driven) and find a small coil across the transducer works well as these sensors (yes they make good vibration detectors too!!) are capacitive. Some experimentation is required for the value of the coil inductance but these can easily be made.

Note a current limiting resistor is now needed in series to safeguard the PIC pin as the coil basically makes the output a short circuit.

HTH,
Bill

Jerson
- 27th June 2009, 12:25
This is how my piezo speaker is driven. The speaker connects between BUZZ and the ground.

Ioannis
- 27th June 2009, 12:43
Risky Jerson!

Does anyone know the relation between the numbers and the freq. in the SOUND command?

Ioannis