3.1. Range Sensor

DA David Abreu
JT Jonay Toledo
BC Benito Codina
AS Arminda Suárez
ask Ask a question
Favorite

There are several types of range sensors that can be divided into three families according to measurement technology: optical, radio-frequency (RF) and ultrasonic, all with advantages and disadvantages.

In the optical family, laser and infrared are the main ones. The highest accuracy is found with the laser units, but they are usually expensive and the measurement is punctual, with a very small detection angle [19]. Those based on infrared diffuse light do not have enough power to properly work outdoors. RF sensors are still under development for short ranges but are starting to be competitive.

Keeping in mind that low budget is a priority of this design, the selected sensor family was the ultrasonic, based on prices and the reasonable accuracy that can be achieved. They can work outdoors and indoors with a quite large detection angle to perceive obstacles from different directions.

Several models of ultrasonic distance sensors were tested. In Figure 1, the result of 1000 measurement to a 1 m obstacle is shown for an HC-SR04, a Parallax Ping and an SRF08 ultrasonic sensor. Results show that Parallalx Ping is the best one, with a normal distribution centered on 1 m but with a unit price of about USD 30. HC-SR04 has reasonable accuracy, but the measurements tend to underestimate the actual distance, and the dispersion is larger. However, it is the sensor with the lowest price (USD 2). The worst results come from SRF08, with greater measurement dispersion than others and a price of USD 25. For this project, and keeping low budget in mind, HC-SR04 has demonstrated enough accuracy and a great value–price relationship. Two of them are needed to detect obstacles from both the ground and the head level, so the unit price is critical. The selected model is then the low-cost HC-SR04 [20]. The main characteristics of this device are its low budget, being widely tested and used, low power consumption, and fifteen-degree measuring angle. It provides a detection range from a few centimeters up to four meters.

Measurement noise to an static obstacle with a HC-SR04 sensor, a Parallax Ping sensor and a SRF08 sensor.

The HC-SR04 emits 8 × 40 kHz pulses, falling in the ultrasound range beyond human hearing [21] but within the limit for dogs [22], which can go as far as 47 kHz. Some tests were done with the range sensor and guide dogs and no disturbance was observed. Despite this, further research should be done to verify that the ultrasonic waves do not annoy them.

A picture of the HC-SR04 range sensor can be found in Figure 2.

Picture of the HC-SR04 ultrasonic sensor. Top view in the left panel, bottom view in the right panel. The ultrasound emitter is labeled as “T” (left) and the receiver as “R” (right). It has 4 pins: “Vcc” and “Gnd” to provide the needed power, “Trig” to deliver the trigger signal that activates the ultrasound emission, and Echo”, which is activated when the echo is detected.

The HC-SR04 includes two transducers: one for ultrasonic emission and the other for detection, with a band centered at 40 kHz. It provides four pins for external device control: two of them to power the unit, one to trigger the ultrasonic signal and the last one that rises until the echo is detected. The HC-SR04 receives the measurement commands with a pulse in the trigger signal, and then it sends the ultrasonic pulses and listen for the echos. All the electronics to generate the ultrasound pulses, the signal amplifier and a level comparator are included in the board. The HC-SR04 is used as a base design platform, with its characteristics modified and its software performance improved with minimum changes in the hardware.

The method used to calculate the distance to the objects detected is the Time-of-Flight (ToF) [23]. By measuring the time it takes between the sound waves’ emission and the echo detection, and knowing speed of the sound in the environment (c), distance (D) can be obtained according to the Equation (1).

where ToF is the time difference between emission of the sound wave and the reception of the echo. However, the speed of sound is not constant.

In general, the speed of sound in the air is described by the Boyle’s law [24], expressed by Equation (2).

where γs is the specific heat ratio, R the universal gas constant, T the absolute temperature (in Kelvin), and M is the molar mass. From the formulation, it can be derived that there is dependency on the temperature and the humidity [24,25]. Graphical representation of this variability is shown in Figure 3.

Speed of the sound in the air for different temperatures and three humidity levels.

Around room temperature (20 °C), the variation with air temperature is almost linear, and the influence of the humidity is quite contained. In the case that this speed is used to measure a distance, placing an obstacle at one meter can give different results. A variation of 10 °C gives a 3.5 cm error. To compare, for humidity, the difference between 0% and 100% is 0.7 cm. Thus, assuming room temperature and 0% humidity can give an error of 4.2%.

These source of errors come from the natural propagation of sound waves and can not be avoided but can be corrected using environment sensors. For the approach of this study, the error is assumed because distances lower than 10 cm are negligible from the human point of view.

To better understand the behavior of the HC-SR04 sensor, an oscilloscope was connected to pins labeled “Trig” and “Echo”, and the detected signal was obtained from the comparator circuit. Signals obtained for a flat object at 30 cm are shown in Figure 4.

Signal obtained from HC-SR04 “Trig” pin (blue line), “Echo” pin (orange) and detection (green) of a flat object at 30 cm.

The “Echo” signal rises when the HC-SR04 changes its mode from emission to detection until any signal is received back.

Figure 4 shows that there is an offset of 0.453 ms between the trigger (blue line) and the echo (orange line). This corresponds to the 8 × 40 kHz pulses (0.4 ms) emitted, avoiding confusing the receiver. For room conditions it means 7 cm.

In the detected signal (green line), the individual pulses of 0.025 ms (corresponding to 40 kHz emission) can be observed. First peaks are weaker as the piezo is starting to vibrate. Then, after the 8 pulses, the piezo keeps vibrating and generating additional weaker peaks. Orange line represents the detection time, starts after emitting the pulses and ends with the first one received.

Another error source when measuring distances with a range sensor is the stability. To characterize the noise in the HC-SR04, a flat panel was placed in front of the sensor at a fixed distance of one meter. One measure each second was acquired to a total of ten thousand. The histogram of the recorded values is presented in Figure 5.

Histogram of 10,000 distance measurements of static obstacle located at one meter from the HC-SR04 sensor. It is centered at 100 cm and spreads over a bit less than two centimeters with 0.269 standard deviation.

The results show a distribution centered in 100 cm with an standard deviation of 0.269. Values move from minimum to maximum over less than two centimeters.

Applying a normal test, a value of 114 is obtained with a p-value 1.46×1025, allowing Gaussian behavior to be rejected. A test for unimodality [26] gives a result of D=0.09035 with p-value < 2.2×1016. This rejects the unimodal assumption, meaning that the distribution is at least bi-modal.

Looking at the signal obtained from the sensor (Section 3.1.2), the peaks can be explained by different pulses detected. The 40 kHz emission (0.025 ms) correspond to 0.43 cm. Then, an obstacle at one meter is few times detected by first (low energy) pulses. Most of the times by the stronger signal (central peak). And then some more times by the following vibrations of the piezo, corresponding to peaks at 100.4 and 100.9 cm.

Compared with better-quality ultrasonic range sensors [27], the noise is a bit higher. However, value for money is on the side of the HC-SR04 as other sensors are more than 20 times the price. In any case, the recorded noise is sufficiently small for obstacle detection as it remains below 1%.

One characteristic related also to ultrasonic sensors is the detection angle. Although the manufacturer provides a value of 15 degrees, this number should be different for diverse obstacles and can even depend on their shape.

To validate sensor’s behavior, a configuration was set up in the laboratory using a robotic arm. See picture in Figure 6.

Picture of the laboratory setup to test the aperture of the HC-SR04. Range sensor is mounted in the robotic arm that can rotate the base with high accuracy, leaving the other axis fixed. Data are acquired using an Arduino UNO board (under the sensor) and serial monitor.

For steps of one degree, a set of one hundred measurements was acquired. The process was done for two plastic cylinders located at one meter, both one meter in height but with two diameters: 75 and 120 mm. Measured distances are displayed in Figure 7 and Figure 8, using value of 0 cm when no detection was performed.

Measurement results for a cylinder one meter height, 75 mm diameter located one meter from the sensor. For steps of 1 degree, 100 measurements were acquired each. (a) In the left panel, the box plot of the data is in full range. (b) In hte right panel, details of the values where a detection was performed. The bottom line of each box indicates the first quartile. The box itself is the second and third divided by an horizontal line (the median). The top line is the fourth quartile. Outliers are plotted as individual points with a cross. The obstacle is detected from −6 to +6 degrees with a dispersion of 4 cm.

Similar to Figure 7 for a cylinder one meter height and 120 mm of diameter. (a) Full range in the left panel. (b) values where a detection was performed in the right one. The dispersion for this larger obstacle is lower, and the round shape of the cylinder can be observed. It can also be observed that the detection is not horizontally symmetrical, as the range sensor has the ultrasound emitter on one side and the detector next to it. The object was detected for angles between −13 and +14 degrees and 2 cm dispersion.

For both cylinders, a box plot [28] is shown. There, each set is described by a box with a central horizontal line and two vertical lines. From the bottom to the box, the first quartile. The box is divided by the median into the second and the third quartile and the top line up to the fourth quartile. Outliers are identified as individual points with a cross symbol.

Left panel of Figure 7 and Figure 8 show the full range of data and right panel the detail where something was detected (non-zero). For better comparison, a polar plot of median values is shown in Figure 9.

Polar plot of median values for each angle. (a) Left panel for the 75 mm cylinder. (b) Right panel for the 120 mm.

Can be observed that the detection angle for the small object is about 12 degrees and 25 for the larger one. The detection is also not symmetric. This last is not unusual, as the detector itself has two transducers with different tasks next to each other. However, the profile of the cylinder can be intuited.

To continue with the sensor inspection, for the large cylinder, data were acquired for three more orientations. As already done for the HC-SR04 aligned with the horizon (0 degrees), 45, 45, and 90 degrees were added, which were obtained by rotating the wrist of the robotic arm and scanning the obstacle again for steps of one degree around z-axis. The 3D plot of different orientations is presented in Figure 10.

HC-SR04 detection of the 120 mm cylinder. For wrist angles of −45, 0, 45, and 90 degrees of the robotic arm, an scan of steps of one degree around z-axis was performed.

Despite some differences on the edges of the detection, the conical shape of the sensor emission-detection can be assumed. There is no preferred orientation to improve the signal.

This sensor in particular is quite directional compared with those studied in other works [29,30]. Although the sensibility is not as good as in other high quality sensors [30], it is sufficient to fulfill the requirements of this study.

The lower detection angle is an advantage in this case, providing a better compromise between detecting obstacles in different directions and those outside the travel path, because the reflections coming from the last ones are reduced. The sensibility is again justified by the reduced cost of the HC-SR04 units.

Do you have any questions about this protocol?

Post your question to gather feedback from the community. We will also invite the authors of this article to respond.

post Post a Question
0 Q&A