[ Pobierz całość w formacie PDF ]

of any linear circuit to sinusoidal input.
118 A Pragmatic Introduction to the Art of Electrical Engineering
How Do I Detect a Clap?
How Do I Detect a Clap?
Quick, sharp sounds tend to have lots of power at high frequencies. So one of the
keys to being able to detect a clap will be the ability to detect high frequency
sounds. Since most conversation is at a lower frequency, you would like to remove
these sounds from consideration. The key to doing this will be the filters we dis-
cussed in the last section.
Let s look at a block diagram for a reasonable (though far from ideal) clap-activated
switch.
mic
High-Pass Precision Low-Pass
amp
Filter Rectifier Filter Stamp
5V
sensitivity
adjustment
The microphone converts acoustic energy into electrical signals. In addition to the
amp in the microphone, an external amp will be needed to get reasonable signal lev-
els. The next step is a high-pass filter, to remove unwanted noises, such as conversa-
tion. A precision rectifier then removes the negative parts of the signal. This is so
the following low-pass filter can average only the positive peaks to get a measure of
the amplitude of the high frequency components of the signal. Finally, this is com-
pared to a reference level. Any loud, high frequency sound will cause the compara-
tor to trip, which can be detected by the Stamp. The pot provides a sensitivity
adjustment to change the reference level for the comparator.
The detailed schematic is fairly complicated, and is shown below. A major issue
you will have to confront right away is the problem of running off of a single 5V
supply. To deal with this, an op amp is dedicated to creating a false ground approx-
imately 1 volt above ground. This will give the op amps some room to swing both
negative and positive with respect to our false ground.
The amplifier is a basic noninverting gain stage. We would suggest you start with a
gain of approximately 100. This should get you up to a reasonable signal level. Be
sure to examine the signals on a scope.
A simple high-pass filter attenuates low-frequencies. You will have to determine
reasonable values for the resistor and the capacitor.
A Pragmatic Introduction to the Art of Electrical Engineering 119
Clap On...
5V
precision
2.2k&!
electret
amp rectifier
microphone high-
pass
1µ f low-
pass
1N4007
Ch
Stamp
R
l
10k&!
Rf Rh Cl
5V
R s Rr
10k&!
false
ground
generator
Rg
The precision rectifier is next. When the V+ input is higher than the V- input, the
diode is turned on, and the amplifier pours its silicon heart out trying to make
V+=V-. When V+ goes below V-, the diode turns off, the op amp output shoots to
ground, and the rectifier output is held at the false ground by the resistor.
The last piece of circuitry left to design is the final low-pass filter. This smooths out
the rectified waveform. If you make the time constant too small, the comparator
output will flutter up and down. If you make it too big, the response will be very
slow. Getting the time constant right here may well be the trickiest part of the
design.
Finally, you will need to write some software for your Stamp to recognize a double
clap. We suggest you carefully consider, and actively look for the appropriate on
and off times. You will be amazed how much clever software can clean up mediocre
hardware!
What s Next?
That s up to you. As for this book, this is the end. We hope you enjoyed it!
120 A Pragmatic Introduction to the Art of Electrical Engineering
APPENDIX A The BASIC Stamp 2
Serial Cable
Roll Your Own
Before you can make a Stamp do anything, you will need a way of connecting it to
your development computer. While there are a number of commercial solutions,
you can make up your own cable very easily and inexpensively. This discussion
presumes that you have some experience with ohm meters and soldering. If you do
not, seek out someone that does. It takes less than ten minutes to make up the cable
once you have all the parts. I would consider this is a one-beverage level favor to
ask a more experienced friend.
Version 1.0 - ©1998 Paul Henry Dietz - All rights reserved. 121
The BASIC Stamp 2 Serial Cable
The Connections
Most modern PCs have a 9-pin serial port connector on the rear panel. Your goal is
to connect pins 2, 3, 4 and 5 on that connector to pins 1-4 respectively on the Stamp
2. In addition, you need to connect pin 6 to pin 7 on the PC serial port. This is
explained in the Stamp documentation and is diagrammed below.
1 TX
2 RX
BASIC
STAMP 2
3 ATN
4 GND
5 4 3 2 1
9 8 7 6
The easiest way to do this is to buy an inexpensive 9-pin serial cable, and cut off the [ Pobierz całość w formacie PDF ]

  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • amkomputery.pev.pl
  •