Hexamite

Ultrasound and Microcontroller Applications

Main Index

Speed of Sound

The nominal value for speed of sound in seawater is nominally 1500 m/s at about 13 degrees centigrade. At salinity level of 35 parts per thousand, depth 0 meters and temperature 0 degrees, speed of sound is 1449.3 m/s. Speed of sound in air is nominally 344m/s at 25 degrees, this speed drops to 334 at 0 degrees. The temperature dependency is second order given that other parameters are constant.

Sound Attenuation in Seawater

Attenuation in seawater is composed of geometric spreading, shear and dilatational viscous losses, relaxation of the MgSO4, and applicable boundary conditions. At lower frequency under 1khz an unidentified relaxation mechanism dominates the attenuation. The absorption losses in this medium are effected by temperature (relaxation), depth (pressure) and salinity.

Sound Attenuation in Air

Overall attenuation in air can be composed from the following: geometric spreading, conduction and shear viscosity losses, molecular relaxation, boundaries, refraction by non-homogeneous atmosphere,  diffraction by turbulence. Atmospheric absorption is a function of distance and is effected by secondary factors like temperature, humidity and atmospheric pressure. Decibel variations in atmospheric attenuation due to secondary factors can be more than an order of magnitude.

The Embedded Microcontroller

The embedded microcontroller is a single chip microcomputer, it has all the properties of what is referred to as a computer today. In many cases the embedded microcontroller will go beyond the conventional computer. Some embedded microcontrollers include analog to digital converters, pulse width modulation generators, high speed I/O subsystems and etc. In the following we freely equate embedded microcontrollers with microcomputers and computers.

The 40Khz Sonic Wave

The media through which the sound travels in the following is assumed to be air, see (HE-US series Transceivers). Any material different from air is referred to as the object (this includes solids, gasses and liquids). An object can also be temperature gradient in air, although not chemically different it will conduct sound at an altered speeds. All objects reflect, absorb and feed a portion of the wave through. It depends on the frequency how this is proportioned.

The amplitude of the wave reflected is directly proportional to how much surface is available on the object for coherent reflection. Surface size, shape and orientation, are major factors contributing to the strength of the reflected signal; material composition is also a factor. A part of the wave landing on the surface of the material is reflected, while a part of the wave penetrates the material and is eventually reflected of any surface boundaries encountered while travelling within the material. Hence you will receive a signal coming from inside the material as well, but it is minuscular.

example

Figure E1.

Measurement of Position using the HE-US series

If T0 is the time at which a burst of pulses is transmitted (see fig. E1 TX) and T1 is the time at which the transmitted burst is received (see fig. E1 RX), then the distance D from the sensor to the object can be determined.

D = 0.5 * C * ( T1-T0 ) ... (EQ1)

Where:
D = Distance to Object
C = Speed of Sound
T0 = Time at which sonic wave is transmitted
T1 = Time at which sonic wave is received
Using the Microcontroller

It is straight forward to trigger a timer (stopwatch) when the sonic burst is transmitted and stop the timer when the transmitted burst is received. Many readily available embedded microcontrollers and microcomputers have a integrated timer/counter which operate similar to a stopwatch. These timers can be incremented ever microsecond or once every few nanoseconds. In many cases, means to capture the time is also provided; this way you do not have to stop the timer, you capture time on the fly.

Assuming that sound travels 344m/s; we can calculate the best displacement resolution expected using ordinary microcontrollers, in terms of meters. In the following it is assumed the microcontroller is able to capture time within a microsecond, hence smallest measure of time is 0.000001 or 1ls.

D = 0.5 * Speed of Sound * ( smallest measurable time increment )

D = 0.5 * 344 * (0.000001) = 0.000172 meters

Ideally, the displacement of an object, can be measured with a precision of approximately 0.2 millimeters using a common microcontroller referred to above.

Doppler Effect

If the object is traveling at speed V as shown in figure E1., the wavelength of the received (reflected) sonic burst (rx) will be different from that of the transmitted burst (tx) (Doppler Effect). The following relationship can be deducted:

krx = C * ktx / (C+V) ..object approaching (EQ2)

krx = C * ktx / (C-V) ..object retreating (EQ3)

Where:
k = Wavelength
C = Speed of Sound
V = Velocity of the Object

Since Frequency = 1/ (Time period) and Frequency = (speed of sound)/wavelength, this relationship can be re-written using EQ2 and 3 for V in terms of frequency. It goes like this:

V = C * ( Frx / Ftx - 1 ) ..object approaching

V = C * ( 1 - Frx / Ftx) ..object retreating

Here F stands for frequency

It is better to measure time difference with the microcontroller than measuring frequency. Since frequency of a sinusoidal wave, can be expressed in terms of the time periods between the wave peaks, (F = 1/T). The relationship above can be expressed in terms of time instead of frequency, which yields:

V = C * ( Ttx / Trx - 1 ) ..object approaching

V = C * ( 1 - Ttx / Trx ) ..object retreating

T = Time period between wave peaks
C = Speed of sound
V = Velocity of object
Practical Consideration when using Microcontrollers

If you ever wondered why you were forced to learn mathematics, here you have a piece of the answer; we have manoeuvred bits and pieces of information into a usable form. Microcomputers are very well suited for time measurements, and to determine the velocity of the object, all you need now, is to program your microcontroller to measure Ttx and Trx.

If the frequency of the transmitted wave is 40Khz, then the time period between peaks is 1/40000 equivalent to 25 microseconds.

Lets assume we have a microcontroller which increments a timer once every microsecond, and calculate the resolution by which we can distinguish between different velocities. Clearly the microcontroller can only count to 25 in 25 microseconds. The computer can only tell us that a wave front was received somewhere between counts, it cannot tell us the exact time it happened. Thus if the time period T between wave peaks is 24.5 microseconds, the computer will tell us that the period between peaks is 25 microsecond. For the microcomputer to tell us that the time between peaks is 24 microseconds the actual time, must be an element below that, like 23.9999 microseconds, but this depends on capture capability.

Now we can calculate what speed difference we can measure using the microcomputer under ideal conditions.

V = 344 * (25/24 - 1) = 14.33 m/s and similarly

V = 344 * (25/23 - 1) = 29.91 m/s

The above would require ideal conditions, if the wave peak picked for measurement is distorted or shifted due to complications in the environment, your measurement will not be reliable

It is better to send burst of sonic waves like 100 waves and then average the periods between tops on the reflected wave. This will significantly increase the resolution of measurement and improve reliability. It will take 2500 microseconds to transmit 100 wave fronts. In this case the microcontroller can count to 2500 between wave peaks measured. We can calculate the ideal resolution of measurement as follows.

V = 344 * (2500/2499 - 1) = 0.14 m/s

This is equivalent to a motion of 0.5 Km/Hour or 0.32 Miles/Hour.

 

interface exampleApplication of the HE-US series

If a HE-US series transceiver is connected to an Oscilloscope one can expect to see something similar to the following, provided there is only a single object around to reflect the signal. We can visualize the oscilloscope display resulting from a setup similar to that in GRAPH A.

The signals from the WHITE wire in GRAPH B., are clusters of sinusoidal waves with varying amplitudes. The amplitudes of the RX signal are proportional to the strength or sound pressure level (SPL) of the received signal. The TX burst, is the transmitted signal coming through the receiver.

The signals from the BROWN wire (GRAPH C) are square pulses all the same in amplitude. These pulses can be connected to standard input port pin on any microcontroller or microcomputer. It is possible to use this signal to measure both velocity and displacement of the object. In fact no A/D is absolutely needed.

The signal applied to the BLACK wire controls the length of the transmitted (TX) signal. A sonic wave is transmitted only when the level on this wire is logic high. Since it takes a few milliseconds to build the transmitted signal to full strength. Therefore, in cases where an object being monitored is close and large, the width of this pulse can be used to control the strength of the transmitted signal. You can calculate the total physical width of your sonic burst by the equation width = (Speed of sound) * (pulse duration). By holding the voltage level on the BLACK wire high for 500 microseconds, you have the following.

W = 344 * 0.0005 = 0.17 meters

The total length of the sonic wave burst transmitted through the air is in this case 170 millimeters.