Monday, March 25, 2013

Multiple microphones


In my previous experiments I have measured distance between a microphone and a speaker. In order to use trilateration to position the sound-source I need multiple microphones.

Multiple Microphones
The other day I built another Arduino-board intended to work with another microphone. Today I added some headers on it to make it easier to connect to the microphone.

Currently one of the microphones circuits is on a breadboard and the other one has been soldered to a perfboard. Eventually I will have three microphones in order to pinpoint the location of the sound.

The idea is that my Raspberry Pi is going to be connected to the Arduino´s. The RPi  sends a serial signal to the Arduino´s that initiates the distance measurements.

A measurement starts by sending a radio transmission to the robot. The robot responds by outputting a sound and the Arduinos use their microphones and sample like crazy until their buffers run full. After that they calculate their individual distances and report to the RPi.

Hardware prep and test

The new board with microphone on breadboard.

Two Arduinos with microphones and a single 433Mhz radio transmitter

The Java project

The java program is going to run on the RPi but since the pi is so slow to compile on I will write it on my Windows machine using Eclipse.

Serial communication might be tricky on Java but there is a library called RXTX

I downloaded from that site but ended up using the ones supplied with the Arduino IDE.

I copied the "rxtxSerial.dll" to my C:\Program Files (x86)\Java\jre7\bin

and jar file copied to project/libs of my Java project.

The outline of the code

The java program identifies the Arduinos by enumerating the serial ports. After that a calibration step happens to calibrate the sensors at a known distance. The calibration consists of 15 samples that are taken, any failing samples are discarded before the median error is used to correct the following samples.

It seems that the synchronization of the radio should be done last.

All serial communication is done asynchronous in separate threads. But I think that will be removed in favor for simpler synchronous communication.


I have not done any detailed testing but initial results are very promising. I get very good results on short distances (within a cm, sloppily measured).
Two microphones listening to a speaker
The multiple measurements is done a lot slower than with a single Arduino, where I did everything on one board and no extra serial information was needed. But I got some ideas on how to speed things up.

With only two distances I can in theory calculate a position but will get an extra shadow position. Think of two circles that intersect in two positions. I expect that the measurement errors may result in the circles not connecting and overlapping in a larger area.

I need to wire or solder up another Arduino and a microphone circuit to get the trilateration working.

During this project I keep wishing for more Arduinos... Today I ordered 2 PCB´s from Lawicel to build me another set of Arduino boards.

No comments:

Post a Comment