
I'm not going to get into
the deep theory of piezo elements mainly cause I don't think you need it to
make use of these little gems. There are several different categories
and types of piezo elements but for the sake of simplicity I will describe a
few as follows.
Raw Piezo element
This type is only the
raw element. They consist of a small piezoceramic plate and
electrode. This type is of element is not much use to us as while it
can make noise, without an acoustical enclosure it wont be that loud.
Encased Piezo element
This is the type of
element that this paper is written for. It's the Raw piezo element but
it is encased in a small enclosure that is designed to resonate at the
operational frequencies of the element.
Encased Piezo buzzer
The last type is the
same as the Encased Piezo element but contains circuitry to generate a tone
so that only power is needed to drive this device. There are two disadvantages
to this type of Piezo.
Have you ever hooked a
piezo element up to a microcontroller and found that the sound it made while
pulsing the pins to be very inadequate? I have. After some
research I found that most piezo elements were to designed to resonate with
the acoustical chamber built into the case.
By varying the frequency
you can find the frequency or frequencies that a piezo was designed to operate.
The piezo that I'm using resonates at both 2.1KHz and 4KHz. This allows
it to be used to generate two tones which give us a bit more flexibility
for getting someone's attention.
This first program is very simple. We create two
functions to generate a couple of tones. The main routine just
cycles back and forth between the two frequencies.
Program 1
download it here
'Piezo Demo
func main()
output 13
loop:
highbeep 1000
lowbeep 1000
goto loop
endfunc
func lowbeep(dur)
dim x
for x = 1 to dur
toggle 13
pauseus 202
next
endfunc
func highbeep(dur)
dim x
for x = 1 to dur
toggle 13
pauseus 76
next
endfunc
This next program uses the
Dios TONE library to generate a series of tones. You can watch the
Dios cycle through the frequencies. Use your ears to see what the actual
frequencies the Piezo resonates at.
Program 2
download it here
'Piezo Demo
func main()
dim x
output 13
for x = 1000 to 5000 step 100
print "Freq=",x
TONE 13,1000,x
next
endfunc
include \lib\DiosTone.lib
Try placing a piece of
tape over the hole and running through the frequencies again. Put a
small pin hole in the tape. The tape
changes the resonating frequency. You can do various things to change
the resonating frequency of the cavity. I enlarged the hole to a 1/8"
and changed the main resonating frequency to 2600 Hz.
This program does things a
bit different. We use the built in PWM generator to make a 42Khz tone.
This tone will run in the back ground independent of your software
application. To turn off the tone just set port 13 to input.
Program 3
download it here
'Piezo Demo
func main()
dim x
'Set to input to turn tone off
output 13
'Sets up a 42KHz tone
PWMinit(1)
PWMperiod(148)
PWM1duty(75)
PWMcourse(2)
loop:
print "Do nothing"
pause 500
goto loop
endfunc
include \lib\DiosHWPWM.lib
Parts List
Piezo Element
6 Cell Battery
Holder
9v Battery Clip
7805
74HC165
DiosPro 40 Pin Chip
Dios Workboard
Deluxe
Easy RS232 Driver
DiosPro 28 Pin Chip
Dios 32 Pin Carrier
(Carrier #1)
9 Pin Cable
Breadboard Regulator