In this ible I will show you how to build a circuit which responds to sound. Think sound activated switch, whistle keyrings or sonic screw driver. Ok, maybe it can't track alien life forms :( The circuit uses a microphone and band-pass filter to determine when a particular tone is heard. The circuit in this ible listens out for a whistling frequency, but it can be set up to listen to any tone, including ultrasound!!! The output of the circuit can be used to create a remote trigger for your camera, a mains relay to turn on the radio in the morning or a remote controlled car. I will show you how to do the bare minimum, and you can go off and make something awesome. Be sure to document and share your idea .
Turn off your hairdryers and lets get started!
Step 1: System Overview
This section gives you an overview of the circuit without all the nitty gritty.
The sound source is the thing that produces an audible tone. In this instructable we will be using our mouths to whistle. If you are like me and suck at whistling you might like to use a mobile phone or computer to generate the tone. I will give you a couple of options later on.
The sound is picked up by the microphone and turned into an electrical signal.
The electrical signal from the microphone contains all frequencies. The purpose of the bandpass filter is to filter out all the frequencies except for the frequency of interest - the whistle.
In this ible we will be using an LED to indicate when circuit picks up a whistle. You can substitute this for a relay to turn things on and off.
Step 2: Component Selection
In this step I'm going to explain the components I chose for the circuit. I have chosen components that are easy to get started with. There are many other components that will give you better results, but I am trying to keep this as simple as possible.
When I first started building this I was playing around with piezo microphones and amplifiers. Even though I have an oscilliscope at my disposal I found it difficult to get anything to work. The signal from the microphone is usually quite small, and because I was prototyping my circuit on a breadboard the signal was always dominated by the 50Hz hum. I finally gave up in frustration and decided to fork out some money and buy a microphone circuit. Printed circuit boards are normally designed with a shielding ground plane, which means that the weak signal from the microphone doesn't get washed out by the 50Hz hum.
I ordered the electret microphone and the MEMS microphone from Sparkfun. These breakout boards do all the hard work for you and have been designed to be easy to connect to. I first tried the electret microphone, but managed to fry it somehow (I'm convinced it wasn't my fault :S). As a consequence I am using the slightly more expensive MEMS microphone.
The pin out of the MEMS microphone is shown in the first image. The breakout board has 3 connections. Ground (GND), supply (VCC) and audio out (AUD). The supply pins need to be connected to a supply with a voltage between 1.5-3.3VDC (Read the section about power supply compatibility below). The audio out port floats at one half the supply voltage and is the input to the bandpass filter.
The Bandpass Filter
Circuits with a high quality factor (narrow band) are very difficult to design and are usually unstable. I searched the net for a long time to find a simple circuit, but it seemed that my efforts were futile, until...I found the LM567. A tone decoder which does exactly what I want it to do. The chip was originally used for Dual-tone multi-frequency signaling (DTMF) in old telephone systems. The chip seems to have been forgotten with time; I found few resources on how to use it, and the datasheet from Texas Instruments is absolutely terrible. Philips produces a similar component with the name NE/SE567; it has a much better datasheet which I have attached.
Here is the description of the chip:
The LM567 and LM567C are general purpose tone decoders designed to provide a saturated transistor switch to ground when an input signal is present within the passband. The circuit consists of an I and
Q detector driven by a voltage controlled oscillator which determines the center frequency of the decoder. External components are used to independently set center frequency, bandwidth and output delay.
The pin-out is shown in the second image and the function of each pin is outlined below.
1 - Output smoothing pin. Reduces erratic switching. Output switching time increases with an increase in capacitance
2 - Bandwidth setting pin. A high capacitance results in a narrow bandwidth
3 - Input pin. Connect the AUD channel from the microphone to this pin
4 - Supply pin. 4.7-9.0V
5 & 6 - timing pins. Sets center frequency of filter
7 - Ground pin
8 - Output pin. Switched to ground when an input signal within the passband is present
To calculate the center frequency and the bandwidth of the LM567 you can use the formulas from the datasheet, or if you're lazy like me, this online calculator.
The MEMS microphone requires a supply voltage of 3.3V; the LM567 on the other hand needs a minimum voltage of 4.7V. The operating range of the two devices doesn't overlap, because of this we need a regulator to step down the voltage for the microphone. If you don't want to add a regulator to the circuit I suggest you try using the Sparkfun electret microphone instead; it can be powered from the same 5V supply as the LM567.
Step 3: Prep
Here is a breakdown of the things you will need before you get started.
1 x LM567CN (8 pin DIP package)
1 x Sparkfun electret/MEMS microphone
1 x LED
1 x 390R Resistor
1 x 8K2 Resistor*
3 x 4u7 Capacitor*
3 x 100n Capacitor*
* These components affect the center frequency and bandwidth of the circuit; select components with low tolerance and low temperature coefficient if possible.
1 x 5V Power supply
1 x 3.3V Regulator or variable power supply*
1 x Breadboard
A bunch of jumper cables
*Only necessary if using MEMS microphone
optional - These items will make error checking easier.
Soundsource (whistle, iPod touch, iPhone, computer)
Step 4: Breadboard Prototype
The image shows you how to lay out your components on a breadboard. The exact placement is not important, just make sure that the connections match the circuit diagram. Please note that the power buses on the top and bottom of most breadboards are usually disconnected. Make sure you run some wires between these so that the whole circuit is powered!
Step 5: Testing
SoundSwitch is available from the app store. It can be installed on iPod and iPhone. It has three modes that make it useful as a remote, a countdown timer and an oscillator. It can also produce ultrasonic sounds.
If you are good at whistling it should be easy to change pitch and find the sound that turns on the LED.
SweepGen Desktop Application (Windows)
This application can produce a custom audio sweep. It has a frequency readout telling you what frequency its up to. The application is free to download here.
Soundcard oscilloscope application (Windows)
The soundcard oscilloscope by Christian Zeitnitz is an excellent application to generate audible and ultrasonic sounds. The application is free to download here.
Online Tone Generators
Once you know the center frequency of your circuit you can generate a sound file using a website like this. The sound file can be used by your standard alarm app to turn the circuit on at a particular time.
Try a number of ways to light up the LED. If you can't get the circuit to respond double check the connections and component values.
Step 6: Improvements
To demonstrate how ultrasound can be used to communicate I have put together a little video (below). The video uses two portable devices, the iPod touch running SoundSwitch and my cellphone running Frequensee. The iPod is used to generate a 19kHz signal and my cellphone uses its inbuilt microphone to listen to sounds. Frequensee applies a Fourier transform to the audio signal to display its frequency components.
In the video a peak appears at 19kHz whenever the iPod is playing the 19kHz signal. As the cellphone is moved away from the iPod the peak gets smaller, showing that the volume drops as it is moved further away - what we expect to happen. At 4.5m the peak gets slightly larger. I presume this is due to the reflections within the room and how the ultrasound signal is propagated within the table.
In this instructable I haven't shown you how to modify the circuit to pick up ultrasonic frequencies. Ultrasonic frequencies are much lower in amplitude and require higher amplification than the Sparkfun circuits are capable of. I am not saying that it isn't possible, but you would have to add an extra amplification stage to your circuit. This adds a lot of components to the circuit and a lot of places where something can go wrong, for this reason I have not included it in this instructable.
For those of you that have an arduino, you could give this library a go. I came across it while reading the comments on the Sparkfun microphone product page. The library lets you do a fast Fourier transform on the incoming audio signal. I haven't tried it yet, but maybe it is possible to pick up ultrasonic frequencies without hardware filtering. Give it a go and let us know whether it works for frequencies above 18kHz.
Well that is about it. Make sure to make an instructable with whatever ideas you come up with. I'm interested to see what cool applications you come up with. Keep ripping stuff apart and keep making!