Driving a piezo with the sound function


Closed Thread
Results 1 to 9 of 9

Hybrid View

  1. #1
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    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...

  2. #2
    Join Date
    Oct 2005
    Location
    New Jersey
    Posts
    425


    Did you find this post helpful? Yes | No

    Default

    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)

  3. #3
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    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...

    Code:
    
    	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!

Similar Threads

  1. Delayed output 10 secs
    By lilimike in forum mel PIC BASIC Pro
    Replies: 37
    Last Post: - 14th October 2011, 06:28
  2. Wanted: Sound chip interfaced with pic
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 34
    Last Post: - 8th September 2008, 13:38
  3. Help with sound command in 2 programs
    By hyperboarder in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 5th July 2007, 20:36
  4. Sound and sound control with minimal parts
    By bartman in forum General
    Replies: 23
    Last Post: - 18th January 2005, 14:08
  5. Re: quick fix for sound command?
    By Melanie in forum Code Examples
    Replies: 0
    Last Post: - 9th July 2004, 01:44

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts