FREQOUT - BASIC Stamp Command Reference
Page 124
•
BASIC Stamp Programming Manual 2.0b
•
www.parallaxinc.com
FREQOUT 2, 1000, 2500, 3000
This will generate a 2500 Hz and 3000 Hz tone (on the BS2) 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.
The circuits in Figure 5.4 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.12) 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.
Demo Program (FREQOUT.bs2)
' This program plays "Mary Had a Little Lamb" by reading the notes from a LOOKUP table.
' It was designed to sound good on the piezo speaker that comes with the BASIC Stamp
' Activity Board. To demonstrate the effect of mixing sine waves, the first frequency
' is the musical note itself, while the second is 8 Hz lower. The difference creates a
' quiver (vibrato) on each note. Subtracting 8 from the note frequency poses a problem
' when the frequency is 0, because the BASIC Stamp's positive-integer math wraps around
' to 65528. FREQOUT would ignore the highest bit of this value and generate a frequency
' of 32760 Hz rather than a truly silent pause. Although humans can't hear 32762 Hz,
' slight imperfections in filtering will cause an audible noise in the speaker. To clean
' this up, we use the expression "(f-8) max 32768," which changes 65528 to 32768.
FREQOUT
' discards the highest bit of 32768, which results in 0, the desired silent pause.
2
e
2
sx
2
p
2
NOTE: This is written for the BS2
but can be used for the BS2e,
BS2sx and BS2p also. Locate the
proper source code file or modify
the STAMP directive before
downloading to the BS2e, BS2sx or
BS2p.
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
from I/O pin
Driving a Speaker
1k
0.1
µ
F
0.01
µ
F
1k
Driving an Audio Amplifier
Amplifier
(e
.g., Radio Shack
277-1008C)
Vss
Vss
Vss
Vss
Vss
Figure 5.4: Example RC filter
circuits for driving an audio amplifier
or a speaker.
F
REQUENCY
C
ONSIDERATIONS
.
Содержание BASIC Stamp 1
Страница 1: ...BASIC Stamp Programming Manual Version 2 0c...
Страница 30: ...Introduction to the BASIC Stamps Page 28 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 34: ...Quick Start Guide Page 32 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 90: ...BUTTON BASIC Stamp Command Reference Page 88 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 118: ...END BASIC Stamp Command Reference Page 116 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 128: ...FREQOUT BASIC Stamp Command Reference Page 126 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 196: ...NAP BASIC Stamp Command Reference Page 194 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 206: ...OWIN BASIC Stamp Command Reference Page 204 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 214: ...OWOUT BASIC Stamp Command Reference Page 212 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 216: ...PAUSE BASIC Stamp Command Reference Page 214 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 226: ...POLLMODE BASIC Stamp Command Reference Page 224 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 232: ...POLLOUT BASIC Stamp Command Reference Page 230 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 236: ...POLLRUN BASIC Stamp Command Reference Page 234 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 240: ...POLLWAIT BASIC Stamp Command Reference Page 238 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 262: ...RCTIME BASIC Stamp Command Reference Page 260 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 274: ...RUN BASIC Stamp Command Reference Page 272 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 310: ...SEROUT BASIC Stamp Command Reference Page 308 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 324: ...STOP BASIC Stamp Command Reference Page 322 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 340: ...ASCII Chart Page 338 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 342: ...Reserved Words Page 340 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 346: ...Conversion Formatters Page 344 BASIC Stamp Programming Manual 2 0b www parallaxinc com...