Uploaded by mason.french01

Sonar report

advertisement
Part 1:
Lines 1-3 exist to make the rest of the coding easier for the user. Making it easier to remember which Arduino pin
is connected to which pin on
the sonar. i.e. Arduino pin 7
can now be called by
echoPin.
Lines 5-8 tells the computer
that our measurement will be
a number of the type ‘long’.
Each duration1,2,3 relates to
each measurement
Lines 10-18 are required in
order to later use ‘qsort’. It
establishes what to do with
the inputs that we will give it
later.
In the setup function, the
serial monitor is initialised
and sets the trigger pin to
output and echo pin as an
input.
In the loop function; line 29
calls the function which tells
the sonar to obtain a reading.
duration1 is now equal to the
time taken for the echo to
return to the receiver in
microseconds.
Line
33
establishes ‘x’ as a local
variable within the loop
function which converts the
time into distance in cm. per
calculations given on the
datasheet.
Line 38 creates a 2 second
gap
before
the
next
measurement is initiated.
Line 40-50 and 52-58 repeats
the above however stores the
second
and
third
measurements as different
variables, y & z which will be
used later. The lines with
Serial.print, print to the serial
monitor each of the three
measured distances.
Line 62, places
the
three
measurements
into an array.
Line 63-66 sort
the array into
ascending order.
Line 69 selects
the second value
in the array which
is the middle
number, a.k.a the
median.
Lines 75-100 are
the functions I
have
created
which emit the
ultrasonic pulse
from
the
transmitter.
PART 2:
Data measured
at different
distances:
Precision:
Clearly, in figure
2, as the distance
increases,
the
precision
decreases,
highlighted by a
larger standard
deviation.
Evidently,
the
most
precise
readings are made in the 2-15cm range. Whereas outside of this range; distances 1cm and 100-300cm
create far less precise readings, see figure 1.
True Standard
Standard
distance Deviation of
Deviation of
(cm) Single
Median
1 0.060663
0.048477
2 0.004472
0.007071
3 0.048166
0.014142
4 0.051769
0.02881
5 0.067305
0.008367
10
15
20
25
0.062209
0.010954
0.25044
0.086718
0.017889
0.007071
0.129615
0.027928
100 2.816758776
200 4.01670636
300 0.2812117
0.205304652
0.256943574
0.1952434
Figure 1.
Accuracy: Observing figure 3, it is clear that the most
accurate readings are given at 2-3cm as on average, the
Figure
2.
sonars output varies by just .06 - .18 cm from the true value.
Furthermore,
the distances between 4cm
– 10cm are incorrect by approximately 0.44 – 0.57 cm. Interestingly, measurements given between 15
and 25 cm become more accurate where they are usually out by 0.24 – 0.32. Finally, the most inaccurate
readings are given around 1 and 100 – 300cm where measurements can differ by 2.18 - 4.58 cm.
Limitations: All three figures indicate that measurements at a distance of 1cm from an
object are highly inaccurate and unprecise, about 4 times greater than the true distance;
thus, being unusable. Limitations in the data are also present, as no data is given between
then 26-99cm range is given. Further, when the true distance becomes greater than 100, the
accuracy becomes far less than the 2-25cm range.
True value distance
(cm)
Mean of single
measurements –
true value (cm)
Mean of Median
measurements –
true value (cm)
1
2
3
4
5
3.01
0.18
0.08
-0.57
-0.48
3.04
0.18
0.06
-0.5
-0.50
10
15
20
25
0.44
0.24
0.24
-0.30
0.46
0.26
0.26
-0.32
Median
Median
Median
100
200
300
3.33
4.58
3.19
2.18
2.62
3.28
Single
Single
Median
Data measured at different angles:
Which
measurement type
less accurate
Median
Same
Single
Single
Median
Precision: Highest precision between 0-28°, above 28° precision is dramatically lost. Evident in Figure
4 where the taller bars represent higher standard deviations resulting in the data spread further away
from the mean [1]. As the graph pictured on the right applies a larger range on the y axis, it is clear that
measurements made at these angles have low precision.
Figure 4.
Accuracy: The highest level of accuracy is obtained when the sonar is at an angle of 0-20°;
reproducing error of up to .29cm, figure 5. Further, when placed at 28° the accuracy is not far behind,
however increasing to an average error of .82cm. Finally, perspectives of 29° and above reproduce
extremely inaccurate measurements, differing from the true distance by between 4.01-49.5 cm.
Limit of different angles: Evidently, angles of 29° and greater between the object and the sonar
result in greatly inaccurate distance measurements ranging from 2 5 times higher than the true
recorded distance. For example, at 30°, the distance can be seen to mistakenly record a 10cm distance
as 53.49
Figure
5. on average.
Difference from true
distance
Difference from true
distance
Compare single measurements vs median of three measurements.
In the 1-25cm distance range, both measurements obtained from a single reading and a median of 3
returned data with very similar accuracy, figure 3. Typically, the average they were out by only varies
by .02 cm. For example, the median measurements at a 15cm were wrong by an average of .46cm versus
single measurements by .44cm. However, as the distance increases to 100-300cm away from the object,
the median measurements become more accurate; for example, at 200cm, the single measurements on
average are wrong by 4.58 but median measurements only by 2.62cm. Conversely, figure 5, reveals that
measurements constructed from the median consistently present a more accurate output as the sonar is
positioned at varying angles. In comparison, the right-hand column under the median readings heading
reveals that measurements are off by smaller distances than the right hand column of single readings.
Across all distances with the exception of at 2cm, the median measurement produced a lower S.D
(Standard Deviation) consistently conveying that the measurements were closer to one another than
those obtained through single readings, indicating higher precision, figure 2. Further, from figure 4, it
is clear that this statement remains valid for measurements taken at different angles, where the median
measurements consistently resulted in S.D lesser than that of single readings. For example, in the 0°28° range, the S.D of median measurements ranged from .04-.19 whereas in single measurements, the
range increased to .17 - .71.
PART 3:
Accurate & consistent
As previously discussed, the HC-SR04 sonar module is able to make accurate measurements between
a range of 2-25cm with data varying by .06-.57cm on average from the true distance. Specifically, it
was found that the most accurate data was recorded at a distance of 2-3cm, varying by only .06 - .18
cm; evident in figure 6, where the collection of vertical lines (measurements from the sonar) are far
closer to the blue dot (true distance) than the rest of the measurements.
When observing single readings, the most consistent measurements were made at the 2cm space, where
the collection of vertical lines are the closest to each other in figure 6, only varying from each other by
.01cm. Further, figure 2 indicates that at distances between 2-25cm, consistent measurements are also
retained, where the maximum range between a set of data points is .22cm; with the exception of at
20cm.
Figure 7.
Re
co
rd
ed
Figure 6.
Per figure 7, the sonar module returns the most accurate
output when at an angle between 0°-30° from a subject.
According to figure 5, the peak accuracy lies between
1
4
2 2 3 3
4 5 5
the range of 0-28°. Further, the most consistent results
occur between 15-28°, from observing single
measurements in figure 4. Whereas between 0-10°
becomes slightly more inconsistent, where the standard
deviation increases from around .2 to (.4-.7). Similarly,
the orientation of the object in relation to the sonar will produce the same effect.
1,2,3… single measurements
1,2,3… median measurements
Conversely, measurements at distances of 100 cm or greater become inaccurate, which on average are
incorrect by 2.18 - 4.58 cm. Additionally, inconsistent results arise when at 20cm, see figure 2; also
when above 100cm, see the last 3 rows in Figure 1… with the exception of at 300cm, precision is
regained. Further, the sonar is incapable of measuring distances below 2cm or above 500cm according
to the datasheet and figure 3.
In addition, factors such as the material & size of the object in which the sonar is measuring against
will affect the result. In that, soft surfaces provide inaccurate measurements. Vice versa, hard surfaces
return more accurate results. On the other hand, small objects may avoid detection entirely or make it
difficult to provide consistent measurements against. Whereas larger objects will allow for more
consistent measurements. Environmental conditions such as extreme low/high temps, air pressure
and humidity can affect the accuracy. However, this can be rectified by adjusting the speed =
distance/time equations if these quantities are known. Also, the accuracy and precision of the
measurements may be affected by interference from external disturbances i.e. fans and air conditioning.
Why does the sonar have these limits?
The transmitter in the HC-SR04 sonar module outputs 8 bursts of ultrasonic sound waves at a
frequency of 40,000 Hz; in comparison, the human ear can only detect frequencies between 20-20,000
Hz [3]. Indeed, waves with higher frequencies in turn have shorter wavelengths, thus reducing the
distance it can travel. Consequently, this limits the range in which the sonar can obtain accurate and
consistent measurements, i.e. if the object is too far away, the emitted sound wave may be unable to
reach it and travel back to the receiver. Further, if the object is too close, it may enter a blind zone,
where the sound is reflected back too quickly for the sonar to register.
The sound waves emitted from the device must be reflected back to the receiver in order to calculate
the distance. Therefore, the orientation of the object with respect to the sonar as well as the angle
between the sonar and the object must be within the 0-28° range to provide accurate measurements.
Angles that exceed this range may deflect the waves away, see figure 8. As discussed, smaller angles
between 0-10° reduce the consistency of the results, this is result of the sound waves bouncing directly
back to transmitter rather than the receiver [2].
3
Figure 8.
Furthermore, softer materials like carpet or fabric will
absorb sound waves more than hard surfaces and
hence will not reflect it back to the receiver as
required. Also, smaller objects may not reflect enough
sound waves back to the receiver due to their reduced
surface area, whereas larger objects can reflect more
sound waves. Finally, sound travels at different speeds
through air as factors such as temperature, pressure
and humidity vary, affected by the increase or
reduction of interfering molecules in the air.
PART 4: Implications for rover:
The HC-SR04 sonar module will be utilised on the rovers to measure the distance between them and
the physical borders of both known and unknown mazes they attempt to navigate. Due to the physical
nature of this modules, potential errors in estimating this distance must be taken into consideration.
Indeed, if the rover becomes less than 2cm away from the walls, it will calculate the wall to be further
away than it truly is and as result continue moving forward and collide. For example, it has been shown
that at a distance of 1cm away the sonar module estimates the object to be 4.04cm away, 4 times greater
than the true distance. To combat this potential error, the rover shall be made to drive no further if the
measurement is returned to be 2cm, also the rovers’ future movements shall be determined when the
rover is at a position of over 2cm away, i.e, as it approaches the wall. Conversely, measurements when
the rover is further than 100cm away from the obstacle will be inaccurate, in turn, if the rovers’
movements were to be determined by this initial measurement, the rover will move forward the incorrect
distance. This distance will likely be too short, the rover will not drive forward enough, turn early and
proceed into a wall, not yet reaching the desired gap. Therefore, at this further distance, the rover will
be instructed to continue driving forward receiving additional measurements increasing in accuracy and
precise, then, once in the 2-3cm range future actions will be determined such as rotating.
Furthermore, during the maze the rover must measure distances from walls from a perspective of 0°,
see A in figure 9. Single measurements taken at this angleBhave been proven to be inconsistent; the
rover may hit a wall if its actions were to be
determined by one of these inaccurate
measurements. However, this problem can be
overcome by constantly using the median of 3
measurements
instead
of
solely
single
measurements, increasing precision greatly.
If wall is at angle above 28°, for example at 45 ° in
A
the known maze, B in figure 9, the wall cannot be
detected. To overcome this error, after every 5cm the
rover drives, it will stop, rotate the sonar which is
mounted to a servo motor 45° and obtain a
Figure 9.
measurement. When the rover is moving through the
straights, the sonar does not detect any walls on the
side as they are at 45° to the sonar and hence keep
moving. However, when the walls are placed at 45°,
the sonar (after it has been made to rotate) will face
it at 0° to the wall, detect it and modify the future
movements as a result.
If just single measurements were being used when at varying distances and angles, the wall could be
observed to be closer/ further than it really is, due to the inconsistent nature of the results. Instead,
greater precision and hence accuracy is obtained if the median of 3 measurements is utilised to
determine the rovers’ actions.
References
[1] Dillard, J. 2021, 5 Most Important Methods For Statistical Data Analysis,
Bigskyassociates.com. accessed 22 April 2021,
<https://www.bigskyassociates.com/blog/bid/356764/5-Most-Important-Methods-ForStatistical-Data-Analysis>.
[2] element14 presents 2021, accessed 22 April 2021,
<https://www.youtube.com/watch?v=2ojWO1QNprw>.
[3] Anon, 2021, Lastminuteengineers.com. accessed 22 April 2021,
<https://lastminuteengineers.com/arduino-sr04-ultrasonic-sensor-tutorial/>.
6
Download