Go Down

### Topic: Impact location, using four sound sensors. (Read 50130 times)previous topic - next topic

#### rocketgeek

#30
##### Mar 01, 2011, 09:32 am
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.

#### robtillaart

#31
##### Mar 01, 2011, 10:01 am
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 - http://www.arduino.cc/playground/Main/PinChangeInt
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

#### Yot

#32
##### Mar 01, 2011, 10:10 am
Another option could be using the a/d converter in free running mode. Than at least the samples are taken with a known interval.

Jeroen

#### Artem_F

#33
##### Mar 02, 2011, 12:30 am
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.

#### scjurgen

#34
##### Mar 02, 2011, 12:49 am
Quote
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).
Juergen

#### Artem_F

#35
##### Mar 02, 2011, 01:10 am

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

#### scjurgen

#36
##### Mar 02, 2011, 01:22 am

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

Nope
Juergen

#### Marceldv

#37
##### Mar 03, 2011, 10:24 am
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..

Quote
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).

#### robtillaart

#38
##### Mar 05, 2011, 01:53 pm

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

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.

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

#### Marceldv

#39
##### Mar 08, 2011, 03:06 pm
Hi Gentleman,

I am looking for some more advice on this project,
i am using this sound sensor..
http://tinkerlog.com/2007/05/20/cheap-sound-sensor-for-avr/

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

Thank you
Marcel

#### robtillaart

#40
##### Mar 09, 2011, 11:42 am
Have you considered - http://www.arduino.cc/en/Tutorial/KnockSensor ?

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

#### Marceldv

#41
##### Mar 09, 2011, 07:37 pm
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

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

#### scjurgen

#42
##### Mar 11, 2011, 04:03 pm

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 http://www.schwietering.com/jayduino/fasterAnalogRead/ which gets you about 72Khz as sample rate (theoretically 83Khz, but it starts to get crappy) .

Code: [Select]
`#ifndef cbi#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))#endif#ifndef sbi#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))#endifstatic 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;}`
Juergen

#### fileark

#43
##### May 13, 2011, 07:17 pm
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

#### necromancer

#44
##### May 15, 2011, 04:25 pmLast Edit: May 15, 2011, 04:27 pm by necromancer Reason: 1
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:

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

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.

Go Up

Please enter a valid email to subscribe