Impact location, using four sound sensors.

Would i be able to implement some form of an interrupt on analog sensors ?

You can set an interrupt on the acquisition of a sample. Then you can decide whether to fall through to whatever else you want to do.

As far as I know only digital signal can trigger IRQs so you need to make electronics that makes a square wave of the analog signal when a threshold (soundlevel) is reached.

The Arduino 328/UNO has only two direct IRQ lines but also has a collective IRQ on the other pins. So you need to determinew which pin was triggered. See - Arduino Playground - PinChangeInt

Another option could be using the a/d converter in free running mode. Than at least the samples are taken with a known interval.

Following this thread with interest,

Jeroen

if you have 4 known locations (x1,y1, x2,y2, x3,y3, and x4,y4),
3 times after the trigger event, and you want to determine x0,y0 that is the location
of the sound source then you have 7 equations and 6 variables that means that the task is
solvable.
the equations are:
(x_i-x0)^2 + (y_i-y0)^2 = R_i^2 for i=1..4

  • 3 equations of type:
    R_i-R_earliest = v_sound*(t_i-t_earliest)=v_sound*t_i since t_earliest=0 as it syncs everything.
    R_earliest is one of R_i, each time it's a different one but it doesn't change anything

rewrite this system to express x0 and y0 and you're done.

rewrite this system to express x0 and y0 and you're done.

funny that many come out on how to solve this (oh yeah, it's trivial, search wiki) problem, without actually presenting a working solution! In the end I got really annoyed, and here is a a solution to calculate the positions (mathemetica, matlab did not help much so I did it by hand) and you can find here the algo for this particular problem: jayduino - Arduino stuff written by me (in 4 iterations you get a 1E-09 result).

scjurgen:
In the end I got really annoyed

so next time you'd suggest people to forget about everything and start coding
and testing anything they suggest? Really? lol

Artem_F:
so next time you'd suggest people to forget about everything and start coding
and testing anything they suggest? Really? lol

Nope

Thank you..

Will start working on this approach,

Honestly, i understand you frustration, i have been trying to solve this for a long time now, and
every single person i present with the challenge says it is easy, until they need to prove it..

I have rewritten this application about 20 times now...

Hope this is the last one...

Thank again for all your inputs gents..

scjurgen:

rewrite this system to express x0 and y0 and you're done.

funny that many come out on how to solve this (oh yeah, it's trivial, search wiki) problem, without actually presenting a working solution! In the end I got really annoyed, and here is a a solution to calculate the positions (mathemetica, matlab did not help much so I did it by hand) and you can find here the algo for this particular problem: http://www.schwietering.com/jayduino/#newtonmethod (in 4 iterations you get a 1E-09 result).

Just found this contest - https://gw.innocentive.com/ar/challenge/overview/9932699 - related to this subject. The difficulty is that there are (at least) 3 dimensions iso 2 changing the number of micros to 8? -think cubistic - and the math will be squared too :slight_smile:

Think the solution is a mesh-networked-zigbee-arduino-with-rtc-combination at every corner of the cube or so.

Real problem is how to detect the shot/impact in the first place, distinguish it from other noise and as it is a soundWAVE which point to take.

Hi Gentleman,

I am looking for some more advice on this project,
i am using this sound sensor..

I would like to add a comparator to the circuit so i can send the data to
the Digital inputs..
or do the ADC Conversion externally...

I have read quite a bit and most people advise OPAMP's but i have no idea
about the electronics, so some guidance or direction would be helpfull.

Thank you
Marcel

Have you considered - http://www.arduino.cc/en/Tutorial/KnockSensor ?

Hi Rob,

yes, i did try that, i seem to be getting better data from the preamp and mics...

The digital input i need to improve the acquisition speed..

Regards
Marcel

robtillaart:
Have you considered - http://www.arduino.cc/en/Tutorial/KnockSensor ?

Marceldv:
The digital input i need to improve the acquisition speed..

I wrote some code to get faster digital reads.
You will initialize the drbit and drport arrays using initDigitalRead() in setup. Then, when calling digitalRead2() you can get 265Khz max sample rate (instead of 166Khz).

for faster analogread refer to Index of /jayduino/fasterAnalogRead which gets you about 72Khz as sample rate (theoretically 83Khz, but it starts to get crappy) .

#ifndef cbi
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#endif
#ifndef sbi
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
#endif

static inline void turnOffPWM(uint8_t timer) __attribute__ ((always_inline));
static inline void turnOffPWM(uint8_t timer)
{
	if (timer == TIMER1A) cbi(TCCR1A, COM1A1);
	if (timer == TIMER1B) cbi(TCCR1A, COM1B1);

#if defined(__AVR_ATmega8__)
	if (timer == TIMER2) cbi(TCCR2, COM21);
#else
	if (timer == TIMER0A) cbi(TCCR0A, COM0A1);
	if (timer == TIMER0B) cbi(TCCR0A, COM0B1);
	if (timer == TIMER2A) cbi(TCCR2A, COM2A1);
	if (timer == TIMER2B) cbi(TCCR2A, COM2B1);
#endif

#if defined(__AVR_ATmega1280__)
	if (timer == TIMER3A) cbi(TCCR3A, COM3A1);
	if (timer == TIMER3B) cbi(TCCR3A, COM3B1);
	if (timer == TIMER3C) cbi(TCCR3A, COM3C1);
	if (timer == TIMER4A) cbi(TCCR4A, COM4A1);
	if (timer == TIMER4B) cbi(TCCR4A, COM4B1);
	if (timer == TIMER4C) cbi(TCCR4A, COM4C1);
	if (timer == TIMER5A) cbi(TCCR5A, COM5A1);
	if (timer == TIMER5B) cbi(TCCR5A, COM5B1);
	if (timer == TIMER5C) cbi(TCCR5A, COM5C1);
#endif
}


uint8_t drbit[50];
uint8_t drport[50];

int initDigitalRead(uint8_t pin)
{
   uint8_t timer = digitalPinToTimer(pin);
   drbit[pin] = digitalPinToBitMask(pin);
   drport[pin] = digitalPinToPort(pin);
   if (timer != NOT_ON_TIMER) turnOffPWM(timer);
}


int digitalRead2(uint8_t pin)
{
   if (*portInputRegister(drport[pin]) & drbit[pin]) return HIGH;
   return LOW;
}

Marcel, I had some questions that I asked a while back trying to make a sound localization sensor. I am delighted to find this thread as it is good reading for me. I will be paying close attention to your progress as I am still thinking about my next step in making a better sensor.
http://arduino.cc/forum/index.php/topic,55578.0.html

I made a prototype sensor that did sound localization using some LM324N op amps first as amplifiers then as comparitors. I have a video and also schematic diagram that may help you build your own circuits.
http://filear.com/index.php/arduino/90-diy-sound-localization-sensor

Hey there.. got to this topic from electronics-lab.com, via Fileark sound localization sensor.

I am doing very similar product like you - sound localization based on impact of metal BB pellet on metal target (square).

Long story short, so I am not boring - most probably, math won't be your biggest problem, in fact, it is/was the simplest problem of my setup.

So you have four sensors like in your image

From your input, you get 4 values. In example on picture, let's say that they were:

0: 0000
1: 1200 (A..1)
2: 2000 (B..2)
3: 2500 (C..3)
(the unit is not important for now.. in this case, it could be CPU cycles or whatever)

my default, most simple algorithm did this:

Imagine four circles, with their center in microphones. Lets call those circles M0, M1, M2, M3.

You know delta times.. so let's do this:

M0 radius = 0000
M1 radius = 1200
M2 radius = 2000
M3 radius = 2500

Now you have four imaginary circles (one is in fact point - zero radius) and they are touching big circle on your picture.

What you have to do is start adding number one to each of those circle radii.

M0 = 1, M1 = 1201, M2 = 2001, M3 = 2501..

Four imaginary circles are now a bit bigger and closer to impact zone.

After each addition, you have to calculate intersections of neighbour circles. In ideal case, they will all end up in the same point - point of impact. In real world, there will be some error.. then you have to calculate when where all intersection closest and pick a point between them.

EDIT: i forgot that you need to know distance between neighbour microphones in our imaginary unit (miliseconds, CPU cycles, whatever) to calculate the intersection - simple triangle.

Also - this is a solution for 2D, not for 3D. If you want to minimize error, mic's should be as close to edges of measured plane as possible. If they are not, then you have to use 3D coordinates for microphones, edges of target and do lots of triangle math in 3D.

I hope it was understandable - English is not my native language :slight_smile:

And in real world, there will be many problems, as I have said, math is nothing. Problem is with intensity of signals at microphones - it goes down with distance squared, also with precise measuring the difference between signal arrival at microphones. Don't even think about using piezoelectric disks clamped onto surface of the target. Speed of sound in steel is nearly 6000 m/s, there will be various reflections and therefore it is virtually impossible to calculate with cross-corelation, because the signal from each sensor is different. A lot! It is possible to try triggering with first sine wave coming from sensor, but it is about milivolt levels, very picky on environment and if you are shooting, it will register shooting sound before impact sound - not good.

Thanks you guys for all the input, i have been busy with another project the past few months and did not get allot of time to work on this, but yes, it is not an easy solution but i am will find a way to make it work...

Thank you for all the new ideas, i must say the approach from necromancer sounds like it would be the simplest way..

I will keep you up to date as i make progress, still struggling to get the Comparator part sorted out, i am stupid with the electronics, so i need to go by trial and error..

Marcel

This is an interesting thread as I've been trying something similar. I think I will give Necromancers approach a try as it sounds pretty simple and sensible at first glance.
On the sensor side I might have something to contribute. I need to detect a "knock" on a 2d surface so I am using piezo contact mikes. I posted my schematic here

I'm just now having to leave for work. I'll try and get back later in detail. Know, however, that this equation can be solved WITHOUT angles using Law of Cosines, which is straightforward algebra without recourse to esoteric functions.

I did it once using string pots, where I had only three string potentiometers giving distance only from three corners of a right angle to the point of intersection. This was done to record the 3D displacement of a car axle being exercised on a tramp test machine for the automotive industry so as to calculate the angle of oversteer.

I saved that info someplace. I'll try to find it for you, if you care to go that route.

I've been looking at this some more, based on Necromancers iterative method (which I think might be quite slow in practice). I think I'm getting somewhere with a fast and dirty calculation to get the start point for the iteration, but it seems to show potential as a method by itself. I wanted to share the idea (and also see if anyone can suggest where to go with it :)) here Stuff and Nonsense: Lost in Maths! (2D Sound location with 4 sensors)