Sonar 5 Equations

1. Coordinate System

Figure 1 shows the Cartesian coordinate system I used on my sonar system. This system uses two planes which are separated by a line perpendicular from the face of the transmitter. The face of the transmitter transducer is X = 0 and Y = 0. In Plane 1 (right plane) both the angle and X are positive and in Plane 2 both the angle and X are negative. In both planes Y is positive and increase as the distance from the transmitter increases. In my system both receivers are six inches from the transmitter.

Figure 1

2) Echo Time and distance

Distance in inches = ( echo time in uS / 2 ) / 74.0 = Echo Time uS / 148.0
Divided by 2 because the echo time is a round trip, double the distance
Divided by 74.0 because sound travels one inch in 74.0uS at 25°C.

3) Right and Left Echoes

Mathematically simply dividing the echo time by two to calculate the distance is not correct due to the distance, 6”, between the receiver and the transmitter. However, it is difficult to calculate the actual echo distances ( Ld and Rd ) because the X point of the object where the two echoes converge is not known. Assuming the two echoes are from the same object a very good approximation of the Td distance is the average of the two echo distances.

Td (approximate) = ( Re + Le ) / 2.

Since the actual distance of the two echo, Le and Re is the sum of Ld + Td and Rd + Td.
Le = ( Ld + Td ) /2
Re = ( Rd + Td ) / 2

Once the Td (approximate) is found the Right and Left distance to the object can be found re-arranging the these two equations
Ld = 2Le – Td
Rd = 2Re – Td

Graph 1 below shows the actual X error due to approximating Td.

Graph 1

4) Double Echo Object X & Y Calculations

The equations are:
X = (2Le2 – 2Re2 + (Le+Re)(-Le + Re ))/X1

If ( Le > Re )
Y = sqrt ( (Re2 – ( X – X1/2 )2 )
Else
Y = sqrt ( (Le2 – ( X – X1/2 )2 )

Re = Echo distance to right side receiver
Le = Echo distance to the left side receiver
X1 = Distance between the two receivers.
All distances are in inches.

Graph #2, below, is a graph of the X distance calculated from the difference of the right and left echo distance at a Y distance of 15” to 60”. As you can see as the Y distance increases the X distance relative to echo difference increases. The sample rate of my system is about 12uS which results in a distance resolution of about 0.1” per receiver which is a total resolution of about 0.25” for the two echoes. From Graph 3 a resolution of 0.25” is an X resolution of about 0.6” at a Y distance of 15”. But at Y distance of 60” that same 0.25” echo resolution is an X resolution of only 2.6”.

Graph 2

5) Object with only one Echo

There is an area about 10” wide to the left of the left receiver and to the right of the right receiver where an object will be picked up by only one receiver.

Figure 4, Single Echo Object Area

This window can be described with the following equation.
XRmin = C * Sin 30° ) – 10”
XLmin = -C * Sin 30° ) + 10”

An object detected by one receiver and not the other falls somewhere between Xmin and Xmax.
The rising slope of the returned echo from objects in this area becomes shallower as the X distance increases. The correlation between slope and X distance is good for solid objects, but not as good for softer objects, such as a sofa. I use the rising slope to give me an approximate idea of a single echo object’s location, but usually double check these objects by aiming both receivers at the general area of the object to obtain two echoes from the object.

Yo = ( Echo Time /148.0 )
Xo = Echo Rise Time * M + B

Yo = ( Echo Time / 148.0 )
Xo = -Echo Rise Time * M + B

In my system M & B are:
M = -0.001799
B = 8.1

6) Far Edge or Object Width Calculations

The Pulse Width of the returned echo is a good indication of size (length) of the object. However, there are a number of things other things that will also affect the pulse width of the echo.
These are a main things that will affect the pulse width of an echo.
1) Material object is made of.
2) Angle of the object.
3) Height of object.
4) Width of object.
5) Distance the object is from the sonar.
6) Transmitter Pulse Width.
7) Sonar Range

The first two are unknowns which at this time cannot be factored in an equation. However, in my Sonar 3 system I am measuring the amplitude of the echo pulse which may help identify the objects material and angle.

The echo from an object of some given size will have a minimum pulse width that is related to the transmitted signal’s pulse width. The transmitter pulse width is related to the number of transmitter cycles and the amount of ringing. In my Sonar 2 I used two transmit cycles in most of my testing which resulted in in resulted in a transmitter pulse width of about 150uS, two cycles plus ringing. This creates an offset of about 1.8” which must be subtracted from the far edge calculation. In my Sonar 3 I have reduced the transmit cycles to one and am working on some ideas to reduce the ringing.

Both the width and height of the object will change the Pulse Width of the returned echo. The reason this happens is because as you move across the surface of the object away from closest edge the distance to the receiver increases and it takes longer for the echo to return. To the receiver this appears to be one long echo which produces a longer pulse width.

For objects with two matching echoes, I use the largest pulse width. However I am still reviewing this. It might be better to use the pulse width of the shortest echo distance or an average of the two pulse widths.

Also distance affects the pulse width. When the same object is moved further away from the sonar system its pulse width becomes shorter. Therefore there is a need for a correction factor, which I have labeled K, that adjusts the pulse width based on echo distance. I am still working on defining the best value for K.

The following equations are used to generate a rough estimate of the size of the object. They can be used to tell the difference between a thin pole and a wall, but there are too many unknowns to accurately determine the width of the object.

Figure 5 – Object Size

Ed = Echo Distance to the closest edge of object in inches
Edf = Echo distance to far edge
PW = Pulse Width in uS
Pw = Pulse Width in inches
Os = Object Size, inches
K = Pulse width correction for distance, for now it is zero.

Adjust Pulse Width for distance and Convert to inches
Pw = (( PW / 2 ) / 74 ) * ( Ed * K ) // Convert Pulse Width to Inches

Far Edge Echo Distance
Edf = Ed + Pw

Object Size
OS = √ ( Edf2 – Ed2 )

Far Edge Coordinates Calculations
Assuming the Object Size is its width, not it height, these are coordinates of the far edge.
Far Edge Xe = Xs + OS
Far Edge Y = Assumed to be same as near edge Y