Introduction
Our project involves using a two-dimensional array of microphones to determine the direction from which a mystery signal comes. This involves taking data from the microphones, doing analysis of the data, and then outputting the results. The second step we chose to implement in Labview. In order to interface correctly with the DAQ card we had available, we used Labview 5.1.
The labview implementation of our project involved several stages: First, we wrote a vi designed to get the input from the microphones by sampling the eight inputs to the DAQ card, and separate the resulting data into eight arrays, each holding a digitized signal. We then upsampled each array (using a separate vi for that purpose) and passed the upsampled signals to themain analysis vi.
The main analysis vi tests three of the signals by taking two of them and testing them individually against the third. This test involves delaying the two signals and taking the norm of the delayed signal and the third signal. Each norm is collected in an array, from which the max norm -- correspondent to the correct delay between the two signals -- can be found.
If we know the correct delays between three signals, we can do some mathematics (explained in greater depth in the section on the delay generation vi) and derive the angles the signal is coming from.
NOTE:
As a two-dimensional array has the ability to discern a point in three-dimensional space, there are two angles found here: theta, the angle along the xy plane, and phi, the angle relative to the z axis.From the angles found, we can then calculate the appropriate delays to be applied to the other five signals. Finally, we take all eight signals, delay them appropriately, and add them together to get our final result. This is known as delay and sum beamforming.
Waveform Generation VI
Most of the work here was done for us already, through Labview's Generate Waveforms VI, a module that, given certain information about an attached DAQ card, sampling rate, time to be sampled, etc., will seek out that DAQ card, sample the requested channels, and return the results in a two-dimensional array of doubles, where one dimension corresponds to the sample of the signal at one particular point in time, and the other to which channel sampled from.
Waveform Generation VI |
---|
Our module took the data from said VI and separated it into eight one-dimensional arrays, one for each microphone. (This was an essential step, as many of the array analysis functions that we wished to use would only work with one-dimensional arrays.) Using our Upsampling VI (discussed below), we then upsampled the signals, lowpass filtered them to interpolate the signal, and set the eight filtered and upsampled signals as the output of this VI. This module takes as an input N, the amount by which the signals should be upsampled, and an input fs, the sampling frequency.
Upsampling VI
From the beginning, we knew that there would be restricted sampling rate of the DAQ card, and the buffer would be effectively decreased by a factor of eight for any one signal (since the data from all eight signals comes into the same buffer). Whatever sampling rate was left would meet the most basic Nyquist requirements and avoid aliasing in that fashion; however, the resultant signal was unlikely to possess much resolution beyond that. Thus, upsampling would be a necessity.
We initially searched Labview itself for a premade upsampling VI, presuming that one would exist, as it is a fairly common signal processing algorithm. However, we were unable to find one and so set about creating a module that would do the job. Our module takes as inputs the signal (array of points) to be upsampled and N, the amount the signal was to be upsampled, and passes as an output the upsampled signal.
Upsampling VI |
---|
Following upsampling theory discussed in class (ELEC 301: Signals and Systems), the first step to our upsampler was to zeropad, that is, add zeros in between each point on the signal being upsampled. Instead of attempting to implement a dynamic array, this was accomplished by creating a new array of the appropriate length (N times the length of the original array, where N is the amount the signal is being upsampled) and using a for loop to place the original signal elements into the new array spaced N points apart.
This enlarged array of data is then passed back to the Waveform Generation VI where it is lowpass filtered in order to fill in (interpolate) the new zeroed out positions, and passed onward as an output of the Waveform Generation VI. The filter used in this operation is the Equi-Ripple FIR low pass filter.
Delay Generation VI
This VI does the bulk of the mathematical analysis of the input signals. It takes as inputs the two delays between microphones one and two, and one and four (derived from the calculations of max norms in the Main Analysis VI) and outputs an array that contains theta, phi, and the corresponding delays for the seven microphones (the delay of the first microphone is automatically set to zero). In all cases, the delays are scaled to correspond to the number of indexes the corresponding signal should be shifted, instead of the actual real-time delay. (As we cannot shift a signal by fractional indexes.)
d12 = k12 / (fs * N);
d14 = k14 / (fs * N);
phi = acos( sqrt (v^2 * (d12 ^ 2 + d14 ^ 2) ) / d ) * sign (d12 * d14);
theta = atan (d14 / d12);
d13 = d12 * 2;
d16 = d14 * 2;
d18 = d13 + d16;
d15 = d13 + d14;
d17 = d16 + d12;
The first part of the above code is calculates the angles based on the spatial relations between the three microphones (microphone 1, used, as we said before, as the origin, and microphones 2 and 4, which can be found directly adjacent to microphone 1 in both directions). As you can see, it is fairly simple geometry, complicated primarily by the scaling necessary to match the 'k' values (integer values used to iterate the for loop) to their corresponding 'd' value (actual delay in time).
The second part of the code uses the angles mentioned above to calculate the delay values, although again due to the regular nature of our array, it is possible to calculate only two of the delays outright and extrapolate the rest of the delays from those two. (Which is indeed what we have done in an effort to reduce calculations and make the algorithm more efficient.)
The final part of the code, not shown in the code above but which can be seen in the function node in the figure below, involves the recipropcal of those first two lines; that is, rescaling all the 'd' values found to 'k' values that can actually be used when shifting the signals prior to adding them together.
Delay Generation VI |
---|
Main Analysis VI
This is our top-end module, where all the modules mentioned in the previous section are brought together in the same vi and linked together in the proper ways so as to create a working project.
Main Analysis VI |
---|
First, not unexpectedly, there is a call to the Waveform Generation VI, which provides us with our collected and upsampled signals. From that sub-VI, the signals from microphones 1, 2, and 4 are taken, microphones 1 and 2 passed to one for loop and 1 and 4 passed to the other. Within the for loop, as mentioned before, one signal is shifted relative to the other, and the norm taken, for all delay values possible. The result of this is concatenated into an array, the maximum norm found, and from the location of the maximum norm, the value of the delay, or as close as we can get with the sampling resolution we have.
These shift values (the integer index corresponding to as close as we can get to the ideal time delay) are passed to the Delay Generation VI, which then returns an array of values. The theta and pi values function as outputs to the front panel, and then the delay (shift) values are used to set the necessary shift for their corresponding microphone. Finally, the shifted output arrays are all summed (using a for loop, as a point by point summing module also seemed to be among those useful things not premade in Labview 5.1), and the output of the for loop, the array that is the sum of all the previous ones, is then attached to a waveform graph, also on the front panel.
An Example Result |
---|
No comments:
Post a Comment