BASIC stamp manual v2.2

FREQOUT – BASIC Stamp Command Reference
Page 200 BASIC Stamp Syntax and Reference Manual 2.2 www.parallax.com
On the BS2, this command generates a 2500 Hz tone for 1 second (1000 ms)
on I/O pin 2. See Table 5.26 for timing data on other BASIC Stamp
models.
To play two tones on the same I/O pin at once:
FREQOUT 2, 1000, 2500, 3000
This will generate a 2500 Hz and 3000 Hz tone for 1 second. The
frequencies will mix together for a chord- or bell-like sound. To generate a
silent pause, specify frequency value(s) of 0.
from I/O pin
1k
0.1
µ
F0.01
µ
F
1k
Driving an Audio Amplifier
Amplifier
(e
.g., Radio Shack
277-1008C)
Vss Vss Vss
10
µ
F (both)
+
+
40
Speaker
(or 8
in series
with 33
resistor)
from I/O pin
C1 C2
Notes:
C1 may be omitted for piezo speakers
C2 is optional, but reduces high-frequency noise
Driving a Speaker
Vss Vss
Figure 5.6: Example RC filter
circuits for driving an audio
amplifier(top) or a speaker (bottom).
The circuits in Figure 5.6 work by filtering out the high-frequency PWM
used to generate the sine waves. FREQOUT works over a very wide range
of frequencies (as shown in Table 5.26) so at the upper end of its range,
those PWM filters will also filter out most of the desired frequency. You
may find it necessary to reduce values of the parallel capacitors shown in
the circuit, or to devise a custom active filter for your application.
FREQUENCY CONSIDERATIONS.
G
ENERATING TWO TONES AT ONCE.