Editors Note: This is an updated and improved version of an article I swiped off our listserver a couple months ago.
The following circuit can be used to detect those annoying piezo whistles that one can get from Radio Shack. For the Trinity Home Fire Fighting Contest, additional points accrue when the robot is started by a sound similar to a fire alarm. The actual whistle is specified as a particular Radio Shack piezo element, but the following circuit should be tunable across a wide range of pitches.
PDF version of the schematic
Gain Stage: The input is a standard surplus electrect microphone. Although I have not tried it, I suspect any condenser computer microphone will work just fine. The microphone is powered by the 4.7k load resistor. The resulting signal is coupled to the input stage via C4 and amplified by roughly 100x. The gain is set by the ratio of R2/R5.
The second stage is a band pass filter. The center frequency of the filter is set by C7, C5 and R1. The Q (or narrowness) of the filter is set by R9. With R9=560 the filter is pretty particular.
The third stage is simply more gain, about 30x and the forth stage is a peak detector. The diode makes a rectifier that charges C9 to the peak value of the signal from the second gain stage. R14 is then chosen to determine the decay of the peak detector. With R14=10k the capacitor discharges in a couple milliseconds.
There is nothing critical in the circuit except for the band pass components, C5, C7, R1 and R9. Most +5v quad op amps should work fine and if you use an op amp that works rail-to-rail, modify R6 and R7 to bias the amps more in the center of the voltage range.
To tune the audio detector, hook an oscilloscope, or DVM to the output of the circuit. With your signal on, adjust R1 to the center of the peak reading. If your signal is really loud it will be hard to determine the center frequency. In that case, move your signal across the room or tape the piezo element so it isn't so loud.
The detector will detect random noises or whistles or hand claps, but, the output will not be held high for very long. So, to determine when a valid signal has been detected, sample the output and verify that it has been active for more than 2-300ms. My Fire Fighting robot, Dilbert uses the detector as a "Push On, Push Off" switch; so the output is sampled every 100ms (10hz) and five consecutive active samples are required before changing the state of the internal switch.
If you have the EAGLE cad package you can use the following files to generate your artwork:
EAGLE Schematic File
EAGLE Board File
If not, the following images are the top and bottom view of the PCB. The bottom view is mirrored so it is correct when placed upon the bottom of the blank PCB. The images were intended to be printed out at 300dpi - that is why they are so big on your screen. So, copy them down, load them into your favorite image processor and print them out at 300dpi.. The board is ~1.2" x 1.5" - so it should be pretty tiny.