28129 Parallax Inc, 28129 Datasheet - Page 110

TEXT BASIC ANALOG & DIGITAL

28129

Manufacturer Part Number
28129
Description
TEXT BASIC ANALOG & DIGITAL
Manufacturer
Parallax Inc
Type
Programmingr
Datasheet

Specifications of 28129

Style
Book
Title
Basic Analog and Digital
Contents
Basic Analog and Digital Text
Product
Microcontroller Accessories
Lead Free Status / RoHS Status
Not applicable / Not applicable
Page 100 · Basic Analog and Digital
First, run the program as shown. The piezoelectric speaker should tick about every half-
second indicating the transitions between the high and low signal.
Next, change the value of
from 500 to 100, and note that the ticking is much quicker.
m
Also try the values of 50, 20, 10, 5, and 1. Experiment a bit.
The value of
should cause the piezoelectric speaker to emit a fairly clear tone.
m = 1
Next, let's change the value of the amplitude by varying the value of
First, try the
n.
value of
. The tone should be the same, just much quieter. Next try the value of
n = 1
n
. The tone is still the same pitch, just louder. For values of
and
, the
=5
n = 10
n = 15
volume should increase two more notches.
In this application, we caused the piezoelectric speaker to make sound by applying pulses
using the BASIC Stamp. We steadily increased the frequency by decreasing the amount
of time the signal paused in its high and low state, effectively decreasing the signal’s
period. Since frequency is the inverse of period, decreasing the period increased the
frequency. When the frequency was increased the pitch of the tone also increased. Next
we changed the amplitude of the pulse train by changing the output value for the high
signal. This changed the volume of the sound made by the piezoelectric speaker.
Causing variations in air pressure creates sound. Any sound can be represented by some
sort of time-varying waveform. To cause the piezoelectric speaker to make sound, we
sent a time varying periodic voltage signal to its input. The speaker converted the signal
into motion of a membrane inside the plastic case. As the membrane vibrated, it caused
air pressure variations. Our eardrum (another membrane) senses these pressure variations,
and we, in turn, heard the tones.
The pulse train we sent to the piezoelectric speaker represented variations in air pressure.
We varied the amplitude of the signal to increase the amplitude of the air pressure
variations, which in turn increased the volume of the tone. The frequency of the pulse
train was varied to change the frequency of the pressure variations. This in turn changed
the pitch of the tone.
The Sine Wave and Pulse Width Modulation (PWM)
The BASIC Stamp has a built in function to generate tones similar to those you hear
when you strike a tuning fork. Disconnect the terminal of the 100
resistor connected to
the buffer output (LM358 pin 1), and connect it to P10 on the Board of Education as

Related parts for 28129