study of directivity and sensitivity of a clap only on-off ... · pdf filestudy of directivity...

9
Study of Directivity and Sensitivity Of A Clap Only On-Off Switch Ajaykumar Maurya Dept. Of Electrical Engineering IIT Bombay Sarath M Dept. Of Electrical Engineering IIT Bombay Abstract—Clap clap switches find applications in domains such as automation and security. A clap sound can be used as a triggering signal either to switch the relays on/off, or as alert signal for some Security System. However the sound is very directive and sensitive to noise floor. Also,being an impulse,it is difficult to distinguish between a clap and a similar impulsive sounds like bang,dog-barking, coughing,etc. Our report presents an efficient way to design omni-directional device for detecting clap from a distance and be able to distinguish it will other impulsive sounds using time and frequency domain analysis. KeywordsImpulse,Correlation,Sampling,Threshold,Directivity, Sensitivity I. I NTRODUCTION The basic motivation of the project was to develop a product which will make a person’s life simpler, say to turn ON a particular device or an appliance, rather than the customary practice of switching ON the device explicitly, a simple ’clap’ would suffice, thereby reducing the human effort. In case of emergency, a clap switch can be used an emergency alert device. A. Block Diagram Clapping generates sound waves. A sensors which converts these sound waves into electrical signal is desired to detect the occurrence of sound event. Hence a microphone is used to sense audio signal whose output voltage level typically is of the order of few millivolts depending upon the loudness of sound and distance of source from the microphone. The block diagram of the circuit designed for the project is shown in Figure 1. Fig. 1: Simplified Block Diagram It consists of an op-amp based amplifier circuit, sufficient enough to amplify the electrical signals generated by micro- phone. This amplified signal is then fed to the Tiva TM4C129 module, wherein we perform some signal processing to distin- guish clap signals from other randomly occurring signals. B. Basic Design Elements The clap activated switching device can basically be de- scribed as a low frequency sound pulse activated switch that is free from false triggering. The input component is a transducer that receives clap sound as input and converts it to electrical pulse.The transducer (microphone) is connected to an amplifier sub-circuit which is then fed to Tiva TM4C module. 1) The Sensor(Microphone): Microphones converts acous- tic energy i.e. sound signal into an electrical signals. Basically, a microphone is made up of a diaphragm, which is a thin piece of material that vibrates when it is struck by sound wave. This causes other components in the microphone to vibrate leading to variations in some electrical quantities thereby causing electrical current to be generated. The current generated in the microphone is the electrical pulse. There are two major types of microphones based on the technical methods of converting sound into electricity namely the dynamic and condenser microphone. Condenser microphones generally have flatter frequency responses than dynamic, and therefore mean that a condenser microphone is more desirable if accurate sound is a prime consideration as required in this design. And hence, we have also preferred the same in the form of electret microphone. Figure 2. shows the basic circuit diagram for an electret microphone. An electret is a thin, Teflon-like material with a fixed charge bonded to its surface. The electret is housed between two electrodes, and the structure forms a capacitor which contains a fixed charge. Air pressure variations (sound waves) move one of the electrodes of the capacitor back and forth, changing the distance between the two electrodes, and modulating the capacitance of the structure. Because the charge on the microphone is fixed, varying the capacitance causes the voltage on the capacitor to also change, satisfying the equation: Q = CV (1) where Q is charge, C is capacitance, and V is voltage. Therefore the microphone capacitor acts as an accoupled voltage source. Because the charge on the microphone capac- itor must be fixed, the amplifier circuitry directly in contact with it must have extremely high input impedance. Most electret microphones have an internal JFET which buffers the microphone capacitor. The voltage signal produced by sound modulates the gate voltage of the JFET, labeled VG in Figure 2 causing a change in the current flowing between the drain and source of the JFET (IMIC). An extremely high resistance, RG, may be included to bias the gate of the JFET.

Upload: dinhtu

Post on 27-Mar-2018

216 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Study of Directivity and Sensitivity Of A Clap Only On-Off ... · PDF fileStudy of Directivity and Sensitivity Of A Clap Only On-Off Switch Ajaykumar Maurya Dept. Of Electrical Engineering

Study of Directivity and Sensitivity Of A Clap OnlyOn-Off Switch

Ajaykumar MauryaDept. Of Electrical Engineering

IIT Bombay

Sarath MDept. Of Electrical Engineering

IIT Bombay

Abstract—Clap clap switches find applications in domainssuch as automation and security. A clap sound can be usedas a triggering signal either to switch the relays on/off, or asalert signal for some Security System. However the sound is verydirective and sensitive to noise floor. Also,being an impulse,it isdifficult to distinguish between a clap and a similar impulsivesounds like bang,dog-barking, coughing,etc. Our report presentsan efficient way to design omni-directional device for detectingclap from a distance and be able to distinguish it will otherimpulsive sounds using time and frequency domain analysis.

Keywords—Impulse,Correlation,Sampling,Threshold,Directivity,Sensitivity

I. INTRODUCTION

The basic motivation of the project was to develop aproduct which will make a person’s life simpler, say to turn ONa particular device or an appliance, rather than the customarypractice of switching ON the device explicitly, a simple ’clap’would suffice, thereby reducing the human effort. In case ofemergency, a clap switch can be used an emergency alertdevice.

A. Block Diagram

Clapping generates sound waves. A sensors which convertsthese sound waves into electrical signal is desired to detectthe occurrence of sound event. Hence a microphone is usedto sense audio signal whose output voltage level typically isof the order of few millivolts depending upon the loudness ofsound and distance of source from the microphone. The blockdiagram of the circuit designed for the project is shown inFigure 1.

Fig. 1: Simplified Block Diagram

It consists of an op-amp based amplifier circuit, sufficientenough to amplify the electrical signals generated by micro-phone. This amplified signal is then fed to the Tiva TM4C129module, wherein we perform some signal processing to distin-guish clap signals from other randomly occurring signals.

B. Basic Design Elements

The clap activated switching device can basically be de-scribed as a low frequency sound pulse activated switch that isfree from false triggering. The input component is a transducerthat receives clap sound as input and converts it to electricalpulse.The transducer (microphone) is connected to an amplifiersub-circuit which is then fed to Tiva TM4C module.

1) The Sensor(Microphone): Microphones converts acous-tic energy i.e. sound signal into an electrical signals. Basically,a microphone is made up of a diaphragm, which is a thin pieceof material that vibrates when it is struck by sound wave. Thiscauses other components in the microphone to vibrate leadingto variations in some electrical quantities thereby causingelectrical current to be generated. The current generated inthe microphone is the electrical pulse.

There are two major types of microphones based onthe technical methods of converting sound into electricitynamely the dynamic and condenser microphone. Condensermicrophones generally have flatter frequency responses thandynamic, and therefore mean that a condenser microphone ismore desirable if accurate sound is a prime consideration asrequired in this design. And hence, we have also preferred thesame in the form of electret microphone.

Figure 2. shows the basic circuit diagram for an electretmicrophone. An electret is a thin, Teflon-like material witha fixed charge bonded to its surface. The electret is housedbetween two electrodes, and the structure forms a capacitorwhich contains a fixed charge. Air pressure variations (soundwaves) move one of the electrodes of the capacitor back andforth, changing the distance between the two electrodes, andmodulating the capacitance of the structure. Because the chargeon the microphone is fixed, varying the capacitance causes thevoltage on the capacitor to also change, satisfying the equation:

Q = CV (1)

where Q is charge, C is capacitance, and V is voltage.Therefore the microphone capacitor acts as an accoupledvoltage source. Because the charge on the microphone capac-itor must be fixed, the amplifier circuitry directly in contactwith it must have extremely high input impedance. Mostelectret microphones have an internal JFET which buffers themicrophone capacitor. The voltage signal produced by soundmodulates the gate voltage of the JFET, labeled VG in Figure2 causing a change in the current flowing between the drainand source of the JFET (IMIC). An extremely high resistance,RG, may be included to bias the gate of the JFET.

Page 2: Study of Directivity and Sensitivity Of A Clap Only On-Off ... · PDF fileStudy of Directivity and Sensitivity Of A Clap Only On-Off Switch Ajaykumar Maurya Dept. Of Electrical Engineering

Fig. 2: Electret Microphone Circuit

Fig. 3: Clap Waveform At figure 2 output

2) Amplifier Stage: Operational amplifiers can be used intwo basic configurations to create amplifier circuits. One isthe inverting amplifier where the output is the inverse or 180out of phase with the input, and the other is the non-invertingamplifier where the output is in the same sense or in phasewith the input. The gain of the non-inverting amplifier circuitcan be determined by the using the fact that the voltage at bothinputs is the same. This arises from the fact that the gain ofthe amplifier is exceedingly high. If the output of the circuitremains within the supply rails of the amplifier, then the outputvoltage divided by the gain means that there is virtually nodifference between the two inputs.And hence the gain is givenby

Vout = 1 +R2

R1Vin (2)

3) Tiva TM4C Module: One of the prime requirement ofour project was the huge amount of samples that we neededto store on the micro-controller, and hence Tiva TM4C waschosen as it has 256 KB of data memory and 1 MB of

Fig. 4: Basic Amplifier Circuit

flash memory. Since our idea was to perform certain signalprocessing on the samples of the external signals and distin-guish it from the desired clap signal, both time domain andfrequency domain analysis had to be performed. Tiva TM4Cmodule has 12 bit precision ADC with a maximum samplingrate of 1 million samples per second. Also these, samples sogenerated can be directly processed in frequency domain usingfast fourier transform. Thereby making the processing muchsimpler.

II. DESIGN FLOW

The electrical signals so generated from microphone areonly of the order of millivolts, and hence an amplificationstage is required. A non-inverting amplification stage usingop-amp was hence designed initially with a variable gain andthen the gain was fixed at 100 after observing the output waveforms. This stage was followed by a comparator circuit, whichbasically compares the amplified signal level with a predefinedthreshold which is depicted in figure 3.

Fig. 5: Amplifier and Stage

However, since our aim was to separate ”clap” signals fromalmost all other signals, comparator stage is unnecessary andhence we removed the comparator stage. Now, from literaturesurvey, it was found that clap signal had a frequency rangeranging approximately from 2kHz to 3kHz, hence we designeda high quality factor band pass filter so as to notch out otherundesired frequencies.

Page 3: Study of Directivity and Sensitivity Of A Clap Only On-Off ... · PDF fileStudy of Directivity and Sensitivity Of A Clap Only On-Off Switch Ajaykumar Maurya Dept. Of Electrical Engineering

Fig. 6: A high Q band pass filter

For the figure 5. the transfer function is given by,

Vo

Vi=

sCR

1 + s2C2R2 + sCR(2−K)(3)

where, K is given by,

K =R4

R5(4)

And bandwidth is given by,

fH − fL = (2−K) (5)

However, desired result was not obtained even after theamplified analog signal was filtered using high Q band passfilter as undesired signals like desk banging etc where notgetting properly filtered. Hence, we resorted to process thesignals on Tiva TM4C board and analyze the samples.

III. HARDWARE IMPLEMENTATION

The clap-detector circuit was implemented on on a generalpurpose PCB as shown in figure 7. We have 4 LED’s indicatingthe confidence levels of clap detection. The Tiva TM4C isprogrammed such that the when the real time samples passeseach thresholds both frequency domain as well as time domain,the LED’s indicating the confidence levels blinks in sequence.Also another LED has been set up to indicate the detection ofsignals other than clap signals.

IV. SIGNAL PROCESSING

The signals from different possible sources are sampledusing ADC in Tiva TM4C with appropriate sampling rate. Thesamples were analyzed in both time domain and frequencydomain.In time-domain the captured samples were cross-correlated with a pre-loaded training sequence. Initial trainingis necessary as claps can be different for different person. Infrequency domain Fast Fourier Transform(FFT) was performedon the samples so as the distinguish different frequencies.Appropriate results were displayed to distinguish the clap fromother sounds.

Fig. 7: Clap Detector-Hardware

A. Time Domain Analysis

The continuous time analog time domain signal from theamplifier circuit was fed to the analog read pin of Tiva TM4Cmodule. The clap signals correspond to a frequency range of2kHz to 3kHz, and hence the signals were sampled at a rateof 10k samples per second, satisfying the Nyquist criteria. Ini-tially training sequences were generated by repeatedly clappingpredefined number of times. The training sequence so obtainedwas recorded and analyzed for its time domain specification.These specifications along with each signals is pre-loaded as atraining data in the Tiva module. For our application we havechosen the training data to be 10. Once the training data isloaded, the real time testing data is fed to the analog pin ofTiva. The sample rate (approx. 10K samples) and the numberof samples (128) is kept same so as to correlate the datawithout zero padding.Time domain correlation is done usingPearson’s formula.

numerator =∑

X1 ∗X2−∑

X1 ∗∑

X2 (6)

denominator1 =√∑

X1 ∗X1−∑

X1 ∗∑

X1 (7)

denominator2 =√∑

X2 ∗X2−∑

X2 ∗∑

X2 (8)

r =numerator

denominator1 ∗ denominator2(9)

where X1 and X2 are the sample Vector to be correlated.The maximum output of ADC of Tiva TM4C is 4095. Alsothe maximum number to which a float is defined in Tiva is4e9. By using Pearson’s formula the summation term wascrossing the maximum limit of a float thereby giving falsereading for the same. Thus an optimal number of points wasrequired to choose so as to get time time correlation as wellas frequency resolution in frequency domain as per required.Hence 128 sample points were chosen where in the maximumlimit the summation term can reach is 2.2e9 and the frequencyresolution is 144Hz which is acceptable for our application.

Page 4: Study of Directivity and Sensitivity Of A Clap Only On-Off ... · PDF fileStudy of Directivity and Sensitivity Of A Clap Only On-Off Switch Ajaykumar Maurya Dept. Of Electrical Engineering

B. Frequency Domain Analysis

The sampled real time signal is processed using 128 pointDFT in frequency domain to detect the presence of frequenciesbetween 2khz to 3 khz. The resolution for 128 point DFTis about 144 Hz. Also the amplitude for the correspondingfrequencies plays a very important role as high amplitude maylead to false triggering. Higher point DFT can also be doneas it will increase the resolution but on the cost of processtime. We went for for 128 point DFT as higher points couldn’tbe processed on Tiva TM4C because of range limitation offloating point numbers.

V. ALGORITHM

Initially, the clap signals are amplified by a non-invertingamplifier of sufficient gain. This amplified signal is fed to theTiva TM4C. Tiva is programmed to sample the analog inputat the rate of approx. 10k samples per second. These samplesso obtained are analyses in frequency-domain as well as time-domain. Initial analysis is done in frequency domain, werewe filter out the incoming signals which do not fall in therange of clap-signals. This is done by specifying appropriatethresholds for the amplitudes in the frequency domain duringthe training process. Once we have filtered out all the signalswhich are out of band of the clap frequencies, we switch totime-domain analysis. In time domain we correlate the realtime samples with the pre-loaded training sequence. Aftercomputing the correlation co-efficient, appropriate threshold isspecified on the value of correlation coefficient so obtainedduring the training process. If the value of correlation co-efficient is greater than the threshold then we say that a clapis detected. Figure 8 depicts the flow chart of the algorithmthat we have implemented.

VI. ANALYSIS AND INTERPRETATION

Initially the system was trained with ”five” claps at bothnear and far. By ”near clap”, we mean a clap at an approximatedistance of 30cm, and by ”far clap” we mean a clap at adistance of 2-3m. These signals were sampled on Tiva TM4Cand analyzed in Matlab. After repeating the experiments anumber of times, the thresholds for both time-domain andfrequency domain were set. Also these samples were preloadedinto the Tiva TM4C for correlating it with the real time signals.

Figures 8 to 25 and 12 to 29 depicts the training signalsalong with their FFT’s processed in Matlab after extractingthe samples using . As can be seen from the training data, amajority of the freTivaTM 4Cquencies for the clap signals,both near and far clap falls in the frequency range of 2-3kHz.Accordingly we chosen the lower cutoff frequency tobe 2.016 kHz and the upper cutoff frequency to be 3.016kHz. The frequency domain plots were processed with aresolution of about 144.06 Hz as there was a computationallimitation associated with the floating point numbers whileloading the program onto the Tiva TM4C. Similarly afteranalyzing multiple data sets and correlating it with the pre-loaded training sequence using equation 9, a threshold of0.15 was set on the value for correlation coefficient for clapdetection.

Fig. 8: Flow-Chart

Page 5: Study of Directivity and Sensitivity Of A Clap Only On-Off ... · PDF fileStudy of Directivity and Sensitivity Of A Clap Only On-Off Switch Ajaykumar Maurya Dept. Of Electrical Engineering

Fig. 9: Far 1 Waveform

Fig. 10: Far 2 Waveform

Fig. 11: Far 3 Waveform

Fig. 12: Far 4 Waveform

Fig. 13: Far 1 Frequency Response

Fig. 14: Far 2 Frequency Response

Fig. 15: Far 3 Frequency Response

Fig. 16: Far 4 Frequency Response

Page 6: Study of Directivity and Sensitivity Of A Clap Only On-Off ... · PDF fileStudy of Directivity and Sensitivity Of A Clap Only On-Off Switch Ajaykumar Maurya Dept. Of Electrical Engineering

Fig. 17: Far 5 Waveform

Fig. 18: Near 1 Waveform

Fig. 19: Near 2 Waveform

Fig. 20: Near 3 Waveform

Fig. 21: Far 5 Frequency Response

Fig. 22: Near 1 Frequency Response

Fig. 23: Near 2 Frequency Response

Fig. 24: Near 3 Frequency Response

Page 7: Study of Directivity and Sensitivity Of A Clap Only On-Off ... · PDF fileStudy of Directivity and Sensitivity Of A Clap Only On-Off Switch Ajaykumar Maurya Dept. Of Electrical Engineering

Fig. 25: Near 4 Waveform

Fig. 26: Near 5 Waveform

Fig. 27: Test 1 Waveform

Fig. 28: Test 2 Waveform

Fig. 29: Near 4 Frequency Response

Fig. 30: Near 5 Frequency Response

Fig. 31: Test 1 Frequecy Response

Fig. 32: Test 2 Frequency Response

Page 8: Study of Directivity and Sensitivity Of A Clap Only On-Off ... · PDF fileStudy of Directivity and Sensitivity Of A Clap Only On-Off Switch Ajaykumar Maurya Dept. Of Electrical Engineering

Fig. 33: Test 3 Waveform

Fig. 34: Test 4 Waveform

Fig. 35: Test 5 Waveform

Fig. 36: Test 6 Waveform

Fig. 37: Test 3 Frequency Response

Fig. 38: Test 4 Frequency Response

Fig. 39: Test 5 Frequency Response

Fig. 40: Test 6 Frequency Response

Page 9: Study of Directivity and Sensitivity Of A Clap Only On-Off ... · PDF fileStudy of Directivity and Sensitivity Of A Clap Only On-Off Switch Ajaykumar Maurya Dept. Of Electrical Engineering

VII. RESULTS

Correlation TableTesting Signals Freq(KHz) Near1 Near2 Near3 Near4 Near5 Far1 Far2 Far3 Far4 Far5

Pen-drop 1.782 -0.035 0.021 -0.042 0.015 -0.154 0.039 0.024 0.013 -0.182 0.115Click 4.610 -0.029 0.058 0.282 -0.015 0.207 -0.029 0.059 0.0282 -0.015 0.206Bang 1.440 -0.071 -0.038 -0.022 0.161 -0.084 -0.071 -0.038 -0.020 0.61 -0.084

Whistle 5.042 -0.024 -0.003 -0.064 0.126 0.047 -0.024 -0.003 0.064 0.126 0.047Clap1 2.881 0.019 0.006 -0.069 0.255 0.010 0.017 0.006 -0.069 0.255 0.010Clap2 2.305 -0.043 0.221 0.248 -0.027 -0.027 -0.043 0.221 0.248 -0.027 -0.027

The Correlation table shows the correlation co-efficient forvarious real time test signals with respect to stored sample.The frequency for Pen-drop, click bang and whistle were notin the range hence rejected. For the claps, as the frequency iswithin the band, time correlation is done with the store sample.For clap1, the correlation with near4 and far4 is greater thanthe threshold thus it is detected as a clap. Similarly for clap2near2, near3, far2 and far3 correlation exceeds and get detectedas clap.

VIII. CONCLUSION AND FUTURE WORK

We have successfully designed and implemented an effi-cient clap only detector. The system is highly sensitive andomni-directional. Testing the system showed 80% accuracy(40out of 50 claps were detected) for a maximum distance of4 meters. Out of remaining 20%, 12% were false negativeand 8% were false positive. Overall this system is much moreefficient compared to other existing counterparts. Future workincludes more regressive training of the system using otherefficient algorithms.

ACKNOWLEDGMENT

We would like to thank Prof. Siddharth Tallur for constantlyhelping and motivating us constantly in completion of theproject. And Prof. Joseph John for giving insights on micro-phone operation. We also like to thank WEL Lab staffs, inparticular Maheshwar Mangat Sir for his valuable inputs.

REFERENCES

[1] Wasim Ahmad and Ahmet M. Kondoz, Analysis And Synthesis Of HandClapping Sounds Based On Adaptive Dictionary, in Proceedings ofthe International Computer Music Conference University of Surrey,Guildford, United Kingdom 2011.

[2] Seyi Stephen Olokede,Design of a Clap Activated Switch, in LeonardoJournal of Sciences, College of engineering and technology Olabisionabanjo university,Ibogun,Ogun State 2008.

[3] Bruno H. Repp,Sound Of Two Hands Clapping-An Exploratory Study, inThe Journal of the Acoustical Society of America, Haskins Laboratories,Connecticut 1986.