Freakout (freqout) trick
Don Pomplun
Posts: 116
Is there a better explanation on the "freqout trick" somewhat discussed in the Sumobot book? Searching for freqout didn't make much headway.
-- Don
-- Don
Comments
-- Don
This note below, part of the original FREQOUT.BS2 program, may or may not answer your ultimate question. The frequency parameters in the FREQOUT statement are indeed limited to the value that can be contained in a WORD, or 32767.
Note from program mentioned above:
"' 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."
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
<!--StartFragment -->
I guess you could say the "trick" is simply that you can use FREQOUT Duration arguments above 32768 even though the BASIC Stamp wasn't designed for that, provided you have equipment to detect signals in that range. You will still always have a corresponding signal below 32768, which typically won't matter to equipment that's detecting signals in the 38 kHz range.· The couple of Boe-Bot enthusiasts were me and Russ Miller, the guy who designed the Boe-Bot chassis. While I discovered the FREQOUT trick on my own and purely by accident, Russ made the brilliant suggestion of sweeping the frequencies to detect distance. I got it working·and demo'd it for him the following day, and you'll get to try it in Chapter 8.
Post Edited (Andy Lindsay (Parallax)) : 5/20/2006 2:04:06 AM GMT
Thanks, Andy.
-- Don