Gunshot Locator

Discussion in 'The Projects Forum' started by kochevnik, Jul 10, 2013.

  1. kochevnik

    Thread Starter New Member

    Jan 7, 2013
    OK - I've been working on this Gunshot Locator project for a couple of weeks - I'm a newbie at a lot of this stuff so be kind please :)

    I started with Sparkfun Electret microphone BOBs :

    I built my own peak detectors, opamps, duplicated the BOB with a different opamp, used a picaxe, used a coridium mcu (which is pretty cool BTW - $10 for a 50 mhz ARM chip) :

    Even tested a bunch of designs with wav files of various gunshots. Also did a bunch of testing with a frequency generator & learned how to better use my scope. I have the math worked out so that if I could get a consistent readings I can do the location part - time delay of arrival (TDOA) is all worked out.

    My main problem after all of this is that I cannot get two different electret mic designs + to give off signals CONSISTENTLY read the gunshot sound and also get consistently read by the microcontroller. Each electret + opamp gives off slightly different signals and when those signals are fed into a peak detector (diode + R + cap) the variance in those components mean that introduces more variance in the readings - and then the microcontrollers adc pins also dont always give totally consistent readings as well, altho this seems something that I could work with if I could get the rest of the circuitry sorted. There is a peak detector IC out there, a PKD01EP but it's not cheap and I'm not sure if it work for this app.

    Some basic info - gunshots have basically two components, one a muzzle blast somewhere in the 75hz to 750hz range - this is what I want to get the peak for and there is also a shockwave at roughly 3 to 4 khz which I need to filter out.

    The electret puts out a small waveform of about 20 to 200+ mvolts depending on the sound pressure level - the opamp seems to bias this to Vcc/2 which in my case is 3.3v / 2 - which when fed directly into an adc pin gives me readings which oscillate around 255 / 2 = 127 points. If I feed the signal into a hand built peak detector, I get rid of all the AC stuff and get a nice easily read DC signal to work with, it just isnt consistent, this may have to do with the logarithmic nature of sound, or just the variance in the R & cap values, or some other screwup on my part.

    When the peak detector didnt work, I moved to the coridium chip with the idea that I could read the waveform directly. This actually works fairly well with a freq generator signal of about 1 khz. It take about 6 to 10 usecs for the coridium chip's adc to read a value and the wavelength at 1 khz is about 1 msec - so when I rectified the 1khz signal and tried to read the 1/4 part of the signal as it goes up to the peak, I actually got the correct readings almost all of the time - so this part works. At 10 usec per read, I would get 1000 / 4 / 10 = 25 reads on the 1/4 wave up of the rectified signal - going from 0 to 255 this can give some gaps, but the peak seems to always get within 1 or 2 points at the top - maybe because a nice neat sine wave is rounded/flattened at the top whereas the actual gunshot waveform would be much more jagged.

    But when I run an actual gunshot waveform thru two different electret + opamp circuits into adc pins, and the variance is back.

    So I am open to any ideas, suggestions, about what I should try next.

    I know that if I can get consistent readings this will work, just how do I accomplish that.
  2. wayneh


    Sep 9, 2010
    What do you mean by "run an actual gunshot waveform thru"? I think anyone that could help you needs a lot more information (pictures say a lot) about your setup and your experimental details. For all we know, you're seeing artifacts from the "waveform" process and your rig would actually work in the real world.
  3. Kermit2

    AAC Fanatic!

    Feb 5, 2010
    What exactly are you trying to do in respect to 'locating' the sound?

    These systems work by triangulation of the sound source. Direction is all that is necessary for the system to report.

    You can use programming to 'discern' sound sources at the site to which the direction finders report. The field detectors can be 'dumb' is what I am saying. They merely report an event and its direction. The recording of the sound can be processed by a single base unit(computer) to determine whether the sound is gunfire or other. This is mostly done with timing and variations in microphone response will not greatly affect the sequence of the various sounds which comprise a gunshot. concentrate on discerning the timing of those different high and low pitched sounds and you will have much better results. don't worry so much about each individual microphones 'timber'.