3.1. Range Sensor
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.
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.
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
is the time difference between emission of the sound wave and the reception of the echo. However, the speed of sound is not constant.
3.1.1. Speed of Sound
In general, the speed of sound in the air is described by the Boyle’s law [
24], expressed by Equation (
2).
where
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.
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.
3.1.2. Sensor Signals
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.
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.
3.1.3. Sensor Stability
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.
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
, allowing Gaussian behavior to be rejected. A test for unimodality [
26] gives a result of
with
p-value <
. 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%.
3.1.4. Measuring Angle
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.
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.
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.
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, 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.
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.
3.2. HC-SR04 Working Principles
In
Figure 11, a general schematic of the HC-SR04 is shown. The ultrasonic range is composed of three circuits, a LM324 classical operational amplifier (circuit U1), a specific unmarked drive circuit as power amplifier and a signal adapter (circuit U3) and a EM78P153 8 bit One-Time Programming (OTP) micro-controller (circuit U2).
The module is divided in two parts, the ultrasound reception, amplification and detection and the ultrasound generation. All the steps are controller by the EM78P153 micro-controller.
In the ultrasound reception, the transducer RX is a piezo electric sensor centered on a 40 kHz bandwidth. It listens to the ultrasounds in the environment and generates a millivolts range signal (from 5 to 50 mv). This input signal is amplified in the first step by the U1D operational amplifier, configured as inverting amplifier, with a gain of 5.6. The output voltage is centered at 2.5 volts, generated by a voltage divider based on the 5 v voltage input (R3 and R4 resistor). The next step is a band-pass filter in the U1C operational amplifier; the band pass filter is centered at 12 kHz, which looks like as a design error. This filter should remove noise filtering for frequencies other than 40 kHz, but the error in the design converts this stage into a signal loss. The last step is an inverting operational amplified centered at 2.5 volts, with a gain of 10. After these steps, a filtered amplified signal, centered at 2.5 volts is obtained. This signal has a peak-to-peak voltage from from 0.1 to 0.5 volts, depending on the distance and the material of the detected obstacle.
The next step in the HC-SR04 is detection. Detection is made based on the operational amplifier U1A in a comparator configuration. The sensitivity of the detector can be changed using the threshold pin [
31]. If the threshold input (pin 9 of the EM78P153 micro-controller) is fixed to high impedance, this means that the comparator is working on maximum sensitivity. When the threshold signal is set to 0, the value of comparisons is reduced to apprimately 1 volt, and the sensitivity of the comparator is reduced to the minimum (a signal of 1.5 volts peak to peak is needed to activate the comparator). A pulse of 500 µs is applied in the threshold signal by the micro controller to avoid the detection of the emitted signal as an echo; in that time, the C7 capacitor discharges, generating a minimum value of 1.3 volts (which means that a received signal centered on 2.5 volts should achieve 1.3 volts to activate the comparator, 1.2 volts of peak to peak signal). When the threshold value is fixed to high impedance again, the comparison value increases to a value of 2.3 volts in 3 ms (a signal of 0.2 volts peak to peak is enough to trigger the comparator). This generates a comparison ramp, avoiding the detection of low-power close signals and increasing sensitivity over time. Any signal smaller than 2.3 volts in the static, or the ramp voltage when capacitor is charging (between 1.3 and 2.3 volts), will trigger the comparator, and a detection will be found. The output of the U1A operational amplifier is converted to a 5 volts TTL signal using the internal transistor inside the Drive Circuit (circuit U3). The operational amplifier gives 0 when echo is detected; this signal is applied to the base of the transistors inside the U3 circuit. This allows it to convert the analog output signal to a 5v TTL signal received by the EM78P153 micro-controller and used to stop the detection counter.
The generation of the ultrasonic wave is straightforward. The EM78P153 micro-controller generates a train of eight pulses using two pins in an inverting way. When pin 13 is 5v, pin 14 will be 0 and vice versa. This signal is used to polarize the H-bridge inside U3, getting a 10 volts 40 kHz signal, applied to the TX piezo electric transmitter.
The sequence of steps on a conventional HC-SR04 sensor is described in
Figure 4 and is based on the following steps:
The master microprocessor, which controls the HC-SR04, generates a pulse in the Trigger pin of the connector (pin 4 of the EM78P153 micro-controller). This starts the measurement process.
The threshold pin is set to 0 to avoid detecting the pulses emitted by the TX.
The EM78P153 generates 8 pulses of 40 kHz, in its 13th and 14th pins (U1, U2). These pulses are amplified in current and voltage by the H bridge of the Drive Circuit, and applied to the TX ultrasonic emitter.
The Threshold pulse is fixed to high impedance, 10 µs after last pulse of 40 kHz is emitted. This allows the C7 capacitor to charge and generates a dynamic threshold for the UA1 comparator. It takes about 3 ms to get the value of 2.3 volts for comparison. This prevents false positives due to detecting emission waves as reception.
The Echo signal is set to high, and the time measurement to obtain the distance begins.
When a signal smaller than threshold value is received, the comparator is triggered, and activates the M5, and M6 transistors inside the Drive Circuit. This convert this signal into a TTL signal, received by the EM78P153. When the first detection pulse is received, the Echo signal is set to 0, indicating that the measurement is finished. The time that Echo pulse is high, is proportional to the obstacle distance and the microprocessor which controls the HC-SR04 can use this time to measure the ultrasonic travel time.
3.3. HC-SR04 Modifications
HC-SR04 is quite cheap, and an external microcontroller is needed to use it. In the eBAT design, the standard ultrasonic receiver is modified to improve accuracy while maintaining the low cost. It is the cheapest option available, and the results can outperform more expensive options.
The first step consists in changing the badly tuned band pass filter, centered at 12 kHz. Changing R5 to 2.5 K and R7 to 22 K, the band pass filter will be centered at 40 kHz. This change allows it to obtain an output signal on U1B 10 times bigger than before, allowing it to detect not only distant obstacles but small close obstacles.
One of the problems of the eBAT system is the interference between two prototypes. This device is designed to help blind people, and users will meet frequently. Blind people share associations and areas, and the possibility of interference between different eBAT devices is large. Other sources of interference can include car parking ultrasound sensors and similar devices. A conventional ultrasound measurement system sends an ultrasound train pulse and wait for a response. The system does not discriminate if the response comes from other source, and that can produce errors. To avoid this problem, the device has been modified to detect echos coming only from its own source.
The idea is to identify the received ultrasound pulses. For that purpose, the emitted pulses should be representative. One way to identify the pulses is modulating information in them. The modulation can include a code that can be used to distinguish the emission source. If the received pulses are not detected as the ones emitted, because code is erroneous or modulation is not detected, the echo will be discarded. If this happens 3 consecutive times, the user will be warned, that the results can be inaccurate due to the presence of other ultrasound source.
To include information in the ultrasonic wave, a modulation should be applied. There are three main kinds of modulations: amplitude, frequency, and phase. Amplitude modulation cannot be used, as the received signal amplitude can be affected by many parameters such as obstacle size, distance or surface. The ultrasound emitter and receiver maximum performance is fixed to 40 kHz, so a change in frequency reduces accuracy and range, and it implies a change in amplitude. Thus, the natural way to include codification in a ultrasound pulse train is to code information, changing the phase in a Phase-Shift Keying (PSK) style modulation. To distinguish this phase change, a 180-degree change is used in order to maximize code detection. In [
18], a similar schema is explained but with a very complicated and expensive hardware that is quite difficult to implement in an actual application.
The PSK modulation used is DPSK. DPSK is a digital modulation based on changing phase of a sinusoidal signal. In this case, the 40 kHz ultrasound frequency carrier is used. The phase of the signal changes 180 degrees with every bit transmitted, so a change in the phase means a change in the transmitter bits, and no change means the bits keep constant. The received will obtain the phase changes in the carrier, and it detects the transmitter bits. DPSK is simpler to implement than ordinary PSK, as it is a “non-coherent” demodulator. There is no need for the demodulator to keep track of a reference wave, and demodulation is made that only compares phase changes.
To make these changes possible, the EM78P153 OTP micro controller is removed from the board, and the 2.5 volts reference, U1B operational amplifier output, and U1 and U2 ultrasonic generation are directly connected to an ATMega328P, low-cost micro controller in an Arduino Nano board. All the measurement tasks, ultrasound wave generation, and blind user interface are made in the same micro controller, thereby reducing the costs. The tasks made in the micro controller are:
40 kHz ultrasound wave generation with PSK code modulation.
Reception of ultrasound echos and measurement echo time.
Signal reception demodulation and source verification.
User interface.
For step 1, the micro controller generates a 40 kHz signal codified with DPSK information. It is easy to modulate analog signal as in [
18]; however, a high-speed digital analog converter is expensive. Therefore, an analog modulation should be made using only digital available signals. In this case, a modified sine wave of 40 kHz is used, as shown in
Figure 12. This digital signal simulates the behavior of a true sine wave. The piezo electric emitter converts this digitized signal into a analog one due to its dynamics. Only two digital pins are used to generate it, using a very accurate time control. In the sequence presented on
Figure 12, three different phases are presented, it starts with a normal phase, and after 7 pulses, a 180-degree phase change is generated, and again after 11 pulses, the original phase is emitted. With this train of pulses, applied to an analog piezo electric emitter, an actual analog sinusoidal wave with different phase modulation is emitted.
For step 2, the receiver transducer listens to the environment, getting all the ultrasonic information. The aspect of a received modulated signal is shown in
Figure 13 as a blue plot. The time of the first pulse when the received wave is bigger than a dynamic threshold is saved. This threshold decreases over time, controlled by a micro controller software. After this time, the output of the internal analog comparator is shown in red. A temporal filter is applied after the first pulse in order to avoid possible noise, and a inverse (negative or positive) pulse of similar amplitude should be received after approx 12.5 µs. The threshold is calculated based on the average analog input value before sending the transmission pulses. This whole process is completed in the micro controller program, and no external components are needed. The in-circuit analog-to-digital converter is used to measure the signal level and is set to a 6.5 µs measurement time, reducing the conversion resolution to 8 bit in order to increase measurement speed. Using a frequency measurement of 150 kHz, the 40 kHz input signal is correctly sampled according to the Nyquist–Shannon theorem. In this step, a signal is received and a distance can be calculated, but now the modulation is tested to detect the signal source. The red plot shown in
Figure 13 is saved using the times when the received signal changes from 0 to 1. The time in µs when the signal change is stored, allowing the entire reception to be saved. This saves computation time, as signal reception and processing can be made at different times.
For step 3, the received signal demodulation is made in order to detect the origin of the ultrasound pulses. The saved signal in step 2 is processed in order to detect if it comes from the emitter, so a valid detection is achieved. In the example of
Figure 13, there are three phase changes in the signal. To detect the signal in a low-cost micro controller, the high speed in the circuit analog comparator is used. The comparison is made with respect to the middle voltage point of the amplification coming from the ultrasound board, as shown in
Figure 11. The binary generated function is shown in red in
Figure 13, and it can be seen that the phase change is also appreciable in this digital signal. In the micro controller, a digital phase detection is made. This detection is quite easy, and it does not consume many computation resources. The demodulation is made based on a XOR comparison between 0-degree phase signal, and the received signal. This comparison obtains the phase change of the received signal over time.
The comparator included in the HC-SR04 circuit is no longer used, and it is not necessary to detect the obstacles. The continuous analysis of the received signal filters any glitches or noises that could trigger the comparator, obtaining a more robust and accurate detection.
In
Figure 14, the demodulation of the received signal is presented, where blue plot shows the captured analog signal, (blue plot in
Figure 13), the yellow plot shows the demodulation of the analog signal using the phase change detection, and red plot shows the demodulation of the digital signal (red plot in
Figure 13). The code included in the emission phase is recover in the demodulation of the binary signal. The maximum bit code rate is about 3.000 bps, but in this case, a short code is sent to avoid reducing minimum obstacle detection distance. As we can see, it is quite simple to detect the code in the analog and digital demodulated signal. If the received signal does not match with the emitted code, it will be detected as an error, and the distance will not be valid. If the code of the demodulated signal does not match, it will be detected as an interference or a measurement error.
As a downside, while the demodulated signal is emitted (1.7 ms), no detection can be performed. This means that objects closer than 28 cm can not be detected by the sensor. Fortunately, this distance is under the average upper arm length (39.1 cm) [
32], where obstacles can be detected with regular exploration.
3.4. HC-SR04 Results
In order to validate the accuracy of the ultrasonic interference detection system, a test where two ultrasonic devices emits pulses in a common area was made. In this case, interference between pulses can occur. The first ultrasound is a standard HC-SR04 without any modifications. This device emits pulses at random times. The second device is an eBAT prototype with phase modulation. The eBAT is tampered by the standard ultrasonic sensor, and the phase coding system should reduce the number of erroneous measurements.
The test included 692 measurements: some were made without interference, and some are tampered with. The expected distance is used to detect correct measurements and errors. Thus, if the measurement is close to the expected distance, it is assumed to be a correct measurement.
The results are shown in
Table 1. In the first row, the eBAT is used as a standard ultrasonic device that just measures the echo time. In this case, with a number of measurements of 692, there are 637 correct measurements and 55 errors. In the second row, the modulation information included in the ultrasonic signal is used to discriminate the possible errors. In this case, the measurement of a correct distance can be classified as an error due to the lack of modulation. This can occur because the interference occurs at the same time. Using the information, every measurement can be classified in Correct Positives (CP), Correct Negatives (CN), False positives (FP), and False Negatives (FN). Correct Positives are the values correctly demodulated and with a correct distance. Correct Negatives are measurements incorrectly demodulated and with an incorrect distance. False Positives are measurements correctly demodulated but with an incorrect distance. False Negatives are measurements incorrectly demodulated but with a correct distance. As
Table 1 shows, the number of errors is reduced from 55 to 7. There is only one false positive, so this assures the security of the user. The number of false negatives, where the distance is correct but the demodulation is not correct, is not representative. Thus, the ultrasonic information can be tampered with just at the same time that the echo is received, so it is a correct solution to invalidate that measurement.
In
Table 2, the percentage error in the experiments is shown. The error is reduced from 7.95% to 1.01%, which shows a great improvement. It is more important to highlight that only one false positive is found, a 0.14% of the measurement. This test shows the improvement obtained in the device with a very low implementation costs. The results show better accuracy than any other ultrasonic transceiver and increased security and robustness.
This means it has a more than detection rate greater than 98% and a Bit Error Rate (BER) close to 0.01, which better than other studies [
17,
18] also using DPSK modulation and transmission over the air.
As a reference, for this experiment, the user can be warned about inaccurate data after 300 ms (three consecutive measurements). For an average blind walking speed of 0.6 m/s [
33], only 18 cm are traversed by the subject.