E72(a) Project
A Binaural Locator
For this project you are to build a circuit that measures the location in space of a sound source by measuring the difference in time for a sound signal to reach two microphones. This is similar to the way that you localize many sounds. Your brain measures the difference in the time it takes a sound to reach your two ears. The phase difference of the component sinusoids of the sound gives the difference in the anount of time it took the sound to reach your two ears. This phase difference helps to localize the point of origin of the sound (along with other cues including relative amplitude of the sound reaching the two ear. The measurement for this lab will depend solely on the phase difference between the two signals.
The physical setup is shown below.
The distance between the two microphones is L, the distances from the microphones to the sound source (a speaker) are d1 and d2, the angle from the centerline to the speaker is r, and the angular position of the speaker is given by q. In our experiment r will be about 1 meter, the distance L is about 30 cm, and the frequency of the sound source will be fixed at 1000 Hz. You can drive the speaker with one of the signal generators.
To do this lab you will need two microphones and a speaker and whatever electronics you think you need. You will amplify the signal from the microphones, and then measure the phase difference. From this measurement you will determine q.
The microphones that you will use have a first stage of amplification already built in. If you put them in a circuit as shown below you can get a measurable output -- use the oscilloscope to see how big it is. This is one of the few time you may want to use AC coupling, because your signal consists of a small AC signal superimposed on a much larger DC signal.
Take note that you use 5V as your power source and that you put the microphone in with the red mark connected to the resistor. There is a transistor in the microphone which is why the use of 5V and the polarity of the connections are important. Although there is some ampolification already you will need to build a circuit to further amplify this signal. Note: you only want to amplify the time-varying (AC) part of the microphone output, not the constant (DC) part. You will also be using single supply op-amps, you should read the page on single supply design. You should use an op-amp like the LM324, or the TLCV2772, and the TLC2774. which can output near the voltage rails (a 411 is definitely a bad choice).
The diagram below shows one way to build a phase detector.
Truth table for XOR
(Exclusive OR)
![]() |
![]() |
![]() |
0 | 0 | 0 |
0 | 1 | 1 |
1 | 0 | 1 |
1 | 1 | 0 |
The output for an XOR is only true if the inputs are different, that is if one input or the other (but not both) are true.
If you have two sinusoidal signals, A and B, you can use a comparator as a zero-crossing (where zero is virtual ground) detector to get square wave outputs, A' and B'. If you make the square waves a logic-compatible levels (i.e. 0 and 5 volts) you can use them as inputs to an exclusive-or (XOR) gate. The output of an XOR gate is high if one input or the other is high, but not both -- see the truth table. The XOR function is implemented with a 7486. The output of the XOR now gives an indication of the phase difference. If the two signals are in phase then the output of the XOR will always be zero. If they are 90° out of phase the output will be high half of the time, if they are 180° out of phase the output will always be high. Thus the phase difference can be determined by the average value of the square wave output (0=0°, 50% of maximum=90°, 100% of maximum=180°).
Obviously all that is needed is to build a circuit that will measure the average value of a time varying signal. What you need is a circuit that will amplify the average (DC, frequency=0) part of the signal while greatly attenuating the signal at 1000Hz and above. You know how to do this. You may also be able to use the PIC to measure the width of the pulses (I think it would be fast enough, but I'm not sure).
One disadvantage of this circuit is that it doesn't distinguish between positive and negative values of phase (e.g., +90° and -90° look the same). I want you to build your circuit so that it detects the sign of the phase, as well as the magnitude.
A possible plan of attack:
- Build the microphone amplifiers.
- Build the phase detectors and calculate what the output should be as a function of phase.
- Calculate how the phase difference is related to the position, q, of the speaker. You may need to go back to your introductory physics text.
- Make a series of measurements of q (with a protractor) and compare with q as determined from the output of your circuit.
- Write a program for the PIC that measures the angle, q. You might first want to do this without worrying about the sign of the angle.
- Display the angle by lighting the LED's.
- Design your PC board.
- When you lay out the op amps it is important that EDWin knows that you want all the op-amps to be in the same package. When you put the op-amps into the design (with "Create Component" from the capture program, the first op-amp should use "OPAMP" as its symbol (there is a box for it in the "Create Component" dialog box). The other op-amps that you use the symbol "OPAMPA". This will give you one op-amp that has power attached to it, and other symbols without power. If you need more than 4 op-amps (you shouldn't), you will need to put another "OPAMP" symbol on your schematic.
- When laying out your PC Board make it exactly the same size (hole placement...) as your first board (refer to 1st lab) so it will fit in the other half of the box.
[Ref/E72Projects/E72Bottom.html]
- Document your design process, what worked, what didn't, explain your design choices.
- Turn in your finalized design.
- Include data that verifies that the circuits work as expected.
- Demonstrate your working circuit to me.