3 Design The heart of this design consists of comparing an input wave with a wave that is delayed due to the finite travel time of sound. To accomplish this, the circuit consists of five basic segments: Sine wave generator and speaker to emit sound Electret microphone and amplifiers to detect sound Logic circuit to compare speaker input, microphone output, and control the counter 1.0 MHz crystal oscillator and 16 bit binary counter to measure the time separation of signals Optical bench and ruler to maintain precision separation of the microphone and speaker Figure 1: Design Sketch The first stage of the circuit is that of sound production. A speaker is fed with a sine wave generator to produce a smooth sound wave. This signal is also used as the input to an amplifier which feeds the logic circuit. This provides a signal which can ultimately be compared to the time-delayed signal. After the sound is emitted it is picked up by an electret microphone and then amplified by two 531 op-amps. This allows for good amplification, a non-inverted wave, and the ability to easily vary the amplification, depending on the distance of the speaker. Typically, the microphone produces a voltage change of approximately 5mV, so the amplifiers are used to achieve a gain of 60dB. The intention for the gain was to produce a sinusoidal wave into the logic, having peak to peak voltage of at least 10V. Using a supply of 12V allowed us to attain this range of amplification. This amplified signal is then input to the logic portion of the circuit. The on button, input signal and inverted delayed signal are ANDed together to start the counter. The input signal, delayed signal and inverted on are ORed together to clear the clock. This makes the clock count while the waves are out of sync so the delay can be measured. The OR then clears the clock so that the delay is only measured once. Between these counting and reset stages the clock is paused so that the output can be read. This is done because the initial plan had a flaw. Initially, we wanted to emit a pulse, start counting, and measure the amount of time before the pulse was picked up. However, this is much more difficult than it sounds. Filtering the pulse causes a large delay, and in addition, the digital logic requires a pulse to be "set up" before it can stop the timer: this also causes errors in the process. So, we decided to measure frequency shifts between the two standing waves, as the frequency should not change with the components we are using. As it is, there exists an issue. With a 550 Hz pulse, we have not yet found a way to turn the counter off while it is paused, 100% of the time. As the time shift between the two waves becomes large, the pause region becomes prohibitively small, and the chances of stopping the timer at a full count markedly decrease. Figure 2: Pulse Response Diagram Design Equations There were not many equations used for this design; most of them existed for theory. Nonetheless, we state them below. v= 4 d t Gaininvertingamp = −R 2 R1 Time seconds = Count 1 MHz 10 6 Accuracy= Timestep v =10−6 Timedelay d Testing The circuit was tested in pieces, to make sure each component of the circuit operated successfully, before it was combined together. The binary counter was built and tested with an input sine wave from the Tenma Sweep/Function generator. The microphone was connected to the oscilloscope and initially tested with the raw signal. Then, an amplification system was built and tested with the oscilloscope. In an effort to obtain a cleaner signal, the "offset null" pins from an op amp were connected to a voltage divider at 2.5 V. This caused the signal to become very clean, but it was biased on a DC voltage, and it behaved somewhat erratically. The digital logic did not fare well with this offset, and we sacrificed the cleaner signal in order to make the circuit work properly. The digital counter was then connected to the 1 Mhz clock and the outputs were tested. This operated well, so the digital logic was developed. Initially, our plans included using a multivibrator to produce the speaker's sound wave, but due to technical problems encountered converting a square wave to a speaker output and receiving it through the microphone, this route was discarded. The digital logic was tested with isolated DC inputs to various parts of the circuit, and it operated as we had hoped. Finally, the two boards were connected together, and the whole digital logic setup was tested. Barring a few bugs and rebuilds, the circuit did work as expected. The response to distance was linear, and though the error in our results was too great to determine a precise speed for sound, the qualitative result was that the circuit worked successfully. Furthermore, our design was also used to measure the speed of sound in a chalkbrush. We searched for a reference of the exact speed of sound in a chalkbrush, but unfortunately, such studies were not forthcoming (probably due to the large amount of variation between different chalkbrushes). Wikipedia told us that the expected speed of sound in steel is between 4900 and 5600 m/s, while in air we expected 343 m/s, and in water we expect around 1500 m/s. Our result, after calibrating our air results to give the correct speed of sound, was that the speed of sound in a chalkbrush is around 2700 m/s. This is somewhere within the expected range. Figure 4: Negative Slope, Sound in Air Figure 5: Speed of sound in air. Calibration The simplest and most accurate way to measure sound with this setup was to take a series of measurements at varying distances and determine the speed of sound from the slope of the graph. This also meant that higher frequencies could be tested, since a phase shift of more than pi would simply result in a decrease of the time delay rather than an increase. As can be seen in the above graph the time delay increases with distance until about 1.5 cm. Beyond this point the delayed wave is shifted by more than pi radians and the counter has less time to count as the speaker is moved away. This can also tell us the approximate time delay of the circuit by the x intercept of the lower plot. This indicates a circuit delay of 244 ns, which is only about 1/4 of a count time, making it fairly negligible. This is probably lower than the actual delay, due to measurement errors. However, noise was a serious problem, especially at these lower frequencies so additional measurements were made at 6.44 kHz. Due to the negative slope we can see that the waves are out of sync by more than pi, however the slope produces a speed of sound of 361 m/s. This is within 7% of the actual speed of sound in air: 343 m/s. Obtaining these measurements though took a fair bit of trial and error, with outliers being rejected. The above plot shows a typical result for the speed of sound in air. The data points are in a linear trend, though the errors in the data are too great to allow for a perfect determination of the speed of sound. With an automated stopping mechanism, the error is expected to decrease to the point at which a numerical result for the speed of sound can be determined (from slope of this graph). For now, qualitative results are used. The following table shows the uncorrected values for speed of sound in air versus that of the chalkbrush. Since no delay is implemented, the speed is not a correct value, but it is instead shifted by a constant amount. This is also shown in the table. To us, the speed of sound in a chalkbrush seems reasonable. It is greater than that of water yet lower than that of steel. Table 1: Brush Speed versus Air Speed Distance (cm) Distance (m) Frequency Decimal Binary Count (Hz) Count Delay Time (s) Speed (no correction, m/ s) Brush 3.7 0.037 334.3 100000010 0 0.000258 143.4109 --> 2690.823 Air 3.7 0.037 334.3 11111101000 2024 0 0.002024 18.28063 --> 343.000 258 5 Discussion Most of this circuit performed as expected with the counter, digital logic, and microphone performing as expected. We ran into problems mainly in the signal amplification stages. The signal from the microphone was increasingly noisy at low frequencies; part of this effect is likely the poor speaker response at lower frequencies. The noise in the circuit through this step was also not filtered. Designing an LCR filter for the frequency of sound used would probably be our next step for this circuit. Another issue was that of the frequency response of the circuit. When observing the microphone response versus the input sound wave on an oscilloscope, the shifting of the waves could not vary too much between distance measurements. If the phase shift was more than pi the time delay would start to decrease since the waves would move completely out of sync. To avoid this small changes in distance had to be used between measurements, adding addition error. One solution would be to use lower frequencies which would allow for larger distance changes. However, as mentioned before, the speaker was not very good at producing a high quality, low frequency sound. Larger distances also added addition noise to the signal, stressing the need for a tuned filter. Another addition that would make the circuit more user friendly would be a method of holding the count for the entire period, rather than having a count and clear section where a faulty measurement is given. This could be done by using a comparator and data latch to check if the counter is higher than the latch data, and if so enabling the data latch to store the new number. This latch data would then be output, so that he LEDs always displayed the highest number that had been counted too. However, since this is a 16 bit circuit, converting this to analog for the comparator and creating a large enough latch was not possible in the time frame. Overall, this circuit proved interesting to build with a good mix of analog and digital components. While accurate and consistent measurements of the speed of sound were not obtained many targets of the design were met. The logic circuit successfully compared an input and delayed wave, the microphone received and amplified signals, and counter provided precise (if not accurate) data. Conclusions The ultimate result of this circuit was that the theory portion was a success, while the practical application left a little to be desired. The circuit appeared to operate correctly according to the theory. We observed expected slopes of distance versus time, with values near that of the speed of sound. However, the control system which stops the circuit was very difficult to operate and caused a large amount of error in our results. The background noise and phase shifting also forced all of our measurements to be taken within a few centimeters of one another. Ideally, this circuit would be corrected to allow measurements between 10cm and 1cm, giving a much wider range of study for the speed of sound. Future Work First, fixing up the stop button should be done. We tried a number of methods to increase the amount of time allowed, but the only one we can think of that would work fully would be an ADC, converting the output count to an analog number, storing it in a latch, and then comparing that value with any other counts. This would ensure that the maximum count would always be returend. Next, studies could be easily done which involve measurement of the time and/or frequency dependence of the speed of sound. Also, once a frequency correction is obtained for air, other materials could accurately be studied. 5B User's Manual It is first important to note that this design is a prototype, and since it is a new design for our electronics lab, there are a few aspects which may require revision. In a perfect world, the circuit would be able to self regulate, holding the maximum count value and displaying that to the user. Unfortunately, there was not enough time to implement this, due to some other issues with measuring the speed of sound. Ideally, this circuit would operate by pushing the on button until the highest reading was determined, then subtracting the delay of the circuit from the LED counter, and converting this number to speed with the formula v = f*d/count. However, due to noise and the difficulty of determining the highest count, especially at increased distances where the hold count time is quite small, it is best to take multiple measurements and determine the speed from the slope of the graph. This method also allows for higher frequencies to be used which helps reduce the amount of noise. The best situation for operation is a quiet environment. After numerous measurements are taken, the largest values should be taken as the correct ones: the counter will reach a peak value and pause there for a short period (depending on the frequency of the sound pulse being tested). The correct result will also be the one with the most probability of occurring. If one result is seen to occur many times while a larger one is observed, it could be that due to noise, the larger value was erroneous and should be discarded. To accomplish this the sine wave generator is set to a frequency which best eliminates noise (we chose 6.44 kHz). The speaker microphone distance is measured and pushing the on button starts the process. When the button is released the process is stopped and the binary counter displays the number which it was paused on. If the button was released during the hold count phase the measurement should provide an accurate reading. To ensure this is the case the on button should be repeatedly pushed and the highest number taken. This can be repeated for numerous distances and a plot of distance vs. time made to determine the speed. The counter display itself is made of the LEDs on the circuit board and is labeled. The counter operates in binary (this would be easy to convert to a digital LED display if time permitted) with the leftmost LED being the Most Significant Bit. Currently the LSB is not hooked up - its resolution is half of one microsecond, and with the errors we experienced, such precision is completely needless. The circuit would also require modification for operation with far lower frequency sound waves - the count rate may become very high and extra bits might be needed. We only required 13 bits for our testing.