<< Chapter < Page Chapter >> Page >
This module gives a summary of the code we wrote to implement multilateration.

Program:

Here is the code for the program that we wrote to record and analyze the data received from the microphones:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Program constants

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

nMics = 4; % The number of microphones

Fs = 44100; % The sample rate

nBits = 8; % The number of bits per sample, either {8,16,24}

nChannels = 1; % The number of channels recorded, either {0,1}

recordLengthSeconds = 3; % The length of each recording in seconds

recordLength = recordLengthSeconds*Fs; % The length of each recording in entries

v = 1130.90551;

maxLags = 0.5*Fs;

% Offset in seconds to add to each mic's tau to account for delay start in recording

mic1TauOffset = 0;

mic2TauOffset = 0.0279;

mic3TauOffset = 0.0596;

mic4TauOffset = 0.1095;

This first part demonstrates the variables that we created and our averages (the offsets) used in calibrating the microphones (we got these values with time delay tests before we tested the entire array). The variable v represents the speed of sound in the area that we tested, and the maxLags represents the maximum lag between the microphones.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Initialization

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

pause on; % Enable pausing, which is used below

ids = zeros(1,nMics); % The device ID for each microphone

ids(1) = 1;

ids(2) = 2;

ids(3) = 3;

ids(4) = 4;

taus = zeros(1,nMics); % The TDOA in seconds between each mic and mic 1

As = zeros(1,nMics-2);

Bs = zeros(1,nMics-2);

Ds = zeros(1,nMics-2);

xs = zeros(1,nMics); % The x-position in feet of each mic relative to mic 1

ys = zeros(1,nMics); % The y-position in feet of each mic relative to mic 1

%{

xs(1) = 0; % Microphone #1 is at (0,0)

ys(1) = 0;

xs(2) = 0; % Microphone #2 is at (0,2)

ys(2) = 2;

xs(3) = 2; % Microphone #3 is at (2,0)

ys(3) = 0;

xs(4) = 2; % Microphone #4 is at (2,2)

ys(4) = 2;

%}

xs(1) = 0; % Microphone #1 is at (0,0)

ys(1) = 0;

xs(2) = -.5; % Microphone #2 is at (-.5,1)

ys(2) = 1;

xs(3) = -1; % Microphone #3 is at (-1,2)

ys(3) = 2;

xs(4) = -1; % Microphone #4 is at (-1,3)

ys(4) = 3;

A = zeros(nMics-2,2); %

B = zeros(nMics-2,1); % The matrices used to solve for point of origin, AX = B

This second part shows how we set up our coordinate grid. We used Matlab to identify each microphone and them input the position of each microphone (both array setups are shown). The last three lines identify the matrices used to find the point of origin, meaning that position was solved with respect to a certain microphone (the microphone at (0,0)).

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Record audio data

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

recorder1 = audiorecorder(Fs, nBits, nChannels, ids(1));

recorder2 = audiorecorder(Fs, nBits, nChannels, ids(2));

recorder3 = audiorecorder(Fs, nBits, nChannels, ids(3));

recorder4 = audiorecorder(Fs, nBits, nChannels, ids(4));

record(recorder1, recordLengthSeconds);

record(recorder2, recordLengthSeconds);

record(recorder3, recordLengthSeconds);

record(recorder4, recordLengthSeconds);

pause(recordLengthSeconds*1.5); % Pause for the length of the recording

% plus 50% to ensure recording finishes

temp = getaudiodata(recorder1);

record1 = temp;

temp = getaudiodata(recorder2);

record2 = temp;

temp = getaudiodata(recorder3);

record3 = temp;

temp = getaudiodata(recorder4);

record4 = temp;

%{

figure;

plot(record1);

figure;

plot(record2);

figure;

plot(record3);

figure;

plot(record4);

%}

The third part involves the recording the data from the microphones and then plotting the impulse. The pause function is used to ensure that all of the impulse is recorded and not cut off. The data is then plotted on the same graph. The plots all showed the impulse response of the clap.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Analyze audio data

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Find TDOA for each mic

taus(1) = 0; % No TDOA between mic 1 and itself

crosscorrelation = xcorr(record2,record1,maxLags); % TDOA for mic 2

[maxVal, maxIndex] = max(crosscorrelation);

taus(2) = (maxIndex-maxLags)/Fs + mic2TauOffset;

crosscorrelation = xcorr(record3,record1,maxLags); % TDOA for mic 3

[maxVal, maxIndex] = max(crosscorrelation);

taus(3) = (maxIndex-maxLags)/Fs + mic3TauOffset;

crosscorrelation = xcorr(record4,record1,maxLags); % TDOA for mic 4

[maxVal, maxIndex] = max(crosscorrelation);

taus(4) = (maxIndex-maxLags)/Fs + mic4TauOffset;

% Find A_m, B_m and D_m for each mic m

for i=3:nMics

As(i) = 2*xs(i)/(v*taus(i)) - 2*xs(2)/(v*taus(2));

Bs(i) = 2*ys(i)/(v*taus(i)) - 2*ys(2)/(v*taus(2));

Ds(i) = v*taus(i) - v*taus(2) - (xs(i)^2 + ys(i)^2)/(v*taus(i)) + (xs(2)^2 + ys(2)^2)/(v*taus(2));

end

% Generate matrices A, B to solve for Ax = B

for i=3:nMics

A(i-2,1) = As(i);

A(i-2,2) = Bs(i);

B(i-2,1) = -Ds(i);

end

X = linsolve(A,B);

A

B

X

taus

The final part involved finding the actual time differences between the sound recordings of the microphones. As seen at the top, the known data of the different time arrivals of the sound to each individual microphone was cross-correlated in order to find the time differences in arrival of the sound for any two microphones. This information was then used to create matrix points for each of the microphones. The matrix was then solved to find the position of the person clapping using the equation Ax = B. The values were then printed out.

Questions & Answers

Is there any normative that regulates the use of silver nanoparticles?
Damian Reply
what king of growth are you checking .?
Renato
What fields keep nano created devices from performing or assimulating ? Magnetic fields ? Are do they assimilate ?
Stoney Reply
why we need to study biomolecules, molecular biology in nanotechnology?
Adin Reply
?
Kyle
yes I'm doing my masters in nanotechnology, we are being studying all these domains as well..
Adin
why?
Adin
what school?
Kyle
biomolecules are e building blocks of every organics and inorganic materials.
Joe
anyone know any internet site where one can find nanotechnology papers?
Damian Reply
research.net
kanaga
sciencedirect big data base
Ernesto
Introduction about quantum dots in nanotechnology
Praveena Reply
what does nano mean?
Anassong Reply
nano basically means 10^(-9). nanometer is a unit to measure length.
Bharti
do you think it's worthwhile in the long term to study the effects and possibilities of nanotechnology on viral treatment?
Damian Reply
absolutely yes
Daniel
how to know photocatalytic properties of tio2 nanoparticles...what to do now
Akash Reply
it is a goid question and i want to know the answer as well
Maciej
characteristics of micro business
Abigail
for teaching engĺish at school how nano technology help us
Anassong
Do somebody tell me a best nano engineering book for beginners?
s. Reply
there is no specific books for beginners but there is book called principle of nanotechnology
NANO
what is fullerene does it is used to make bukky balls
Devang Reply
are you nano engineer ?
s.
fullerene is a bucky ball aka Carbon 60 molecule. It was name by the architect Fuller. He design the geodesic dome. it resembles a soccer ball.
Tarell
what is the actual application of fullerenes nowadays?
Damian
That is a great question Damian. best way to answer that question is to Google it. there are hundreds of applications for buck minister fullerenes, from medical to aerospace. you can also find plenty of research papers that will give you great detail on the potential applications of fullerenes.
Tarell
what is the Synthesis, properties,and applications of carbon nano chemistry
Abhijith Reply
Mostly, they use nano carbon for electronics and for materials to be strengthened.
Virgil
is Bucky paper clear?
CYNTHIA
carbon nanotubes has various application in fuel cells membrane, current research on cancer drug,and in electronics MEMS and NEMS etc
NANO
so some one know about replacing silicon atom with phosphorous in semiconductors device?
s. Reply
Yeah, it is a pain to say the least. You basically have to heat the substarte up to around 1000 degrees celcius then pass phosphene gas over top of it, which is explosive and toxic by the way, under very low pressure.
Harper
Do you know which machine is used to that process?
s.
how to fabricate graphene ink ?
SUYASH Reply
for screen printed electrodes ?
SUYASH
What is lattice structure?
s. Reply
of graphene you mean?
Ebrahim
or in general
Ebrahim
in general
s.
Graphene has a hexagonal structure
tahir
On having this app for quite a bit time, Haven't realised there's a chat room in it.
Cied
what is biological synthesis of nanoparticles
Sanket Reply
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get the best Algebra and trigonometry course in your pocket!





Source:  OpenStax, Elec 301 projects fall 2011. OpenStax CNX. Jun 18, 2012 Download for free at http://cnx.org/content/col11431/1.1
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Elec 301 projects fall 2011' conversation and receive update notifications?

Ask