The Performance Improvement of the Low-Cost Ultrasonic Range Finder (HC-SR04) Using Newton’s Polynomial Interpolation Algorithm

The ultrasonic range finder sensors are widely used in many applications such as computer applications, general purpose applications, medical applications, automotive applications, and industrial-grade applications. The ultrasonic range finder sensor has many advantages. The advantages are easy to use, fast in measuring process, non-contact measurement, and suitable for air and underwater environment. However, the ultrasonic range finder has deviation, especially for the low-cost sensor. It affects the accuracy level of the measurement result that performed by its sensor directly. The HC-SR04 categorized as a low-cost ultrasonic range finder sensor. This sensor has a significant error level. The improvement of the accuracy level of this lowcost ultrasonic sensor is expected to this research. Newton’s polynomial interpolation algorithm has been used in this research to reduce the error during the measurement process. The implementation of Newton’s polynomial interpolation has succeeded in improving sensor accuracy. The MSE level of 29,96 is obtained without Newton’s Polynomial Interpolation implementation. The implementation of Newton’s Polynomial Interpolation algorithm has succeeded in increasing the accuracy level of the sensor by 55,54%. It has been proven by the decrease of the MSE level by 13,32.


INTRODUCTION
The ultrasonic range finder is a widely used sensor in computer application, general purpose applications, robotic applications, medical applications, automotive applications, and industrial-grade applications [1]- [3]. The advantage of the usage of the ultrasonic range finder is the ease in measuring the distance of the object could be obtained immediately without intensive processing [4]. This advantage made the ultrasonic range finder sensors are very popular since these sensors are relatively easy to use, fast in measuring process, non-contact measurement, and the varying prices. Ultrasonic-based sensors are also suitable for underwater and air environment [3].
Measuring the time duration during the signal propagates at a distance from the transmitter and receiver is the working principle of the ultrasonic range finder sensor [1]. Since the propagation speed of the ultrasound wave is 340 m/s, then the actual distance between transmitter and receiver is easy to find [5]. Mostly the ultrasonic range finder consists of two parts, namely transmitter, and receiver. The transmitter generates the ultrasonic wave, and the receiver perceives the echo sent by transmitter [1]. The transmitter sends eight signals (pulse) with a frequency of 40 kHz, respectively. The last signal triggers timer activation. Ultrasonic pulses travel out towards the surface of the barrier object and pound the object. The surface of the object causes the pulse to bounce back towards the receiver. The receiver detects this pulse and stops the timer as well. The average speed of the ultrasonic pulse is 340 m/s in the air [6]. The HC-SR04 has a similar principle to measure the distance. This paper focused on low-cost ultrasonic range finder HC-SR04 since this sensor is cheap and popular. The deviation is an issue in most sensor systems, especially for the low-cost sensor. The HC-SR04 sensor categorized as low-cost sensor and it has significant deviation [1], [2], [3], [6]. The significant deviation leads to significant error. The error level affects the accuracy of the measurement result directly. The minimization of the error is required to improve sensor performance. Newton's polynomial interpolation algorithm has been used in this research. Newton's polynomials interpolation algorithm is a powerful method to resolve the noise problem, reduces the error level during the measurement process, and it could be used as a digital filter algorithm [7]- [10]. This research aims to improve the performance of the HC-SR04 ultrasonic range finder sensor. This research result could be used as a value added to this low-cost ultrasonic range finder since this sensor is a popular sensor and cheap.

II. RESEARCH METHOD
The HC-SR04 is a low-cost ultrasonic range finder that consists of two mains basic parts. The first part is the ultrasonic transmitter, and the latest is the ultrasonic receiver. The output of the sensor has four pins, namely, Vcc pin, trigger pin, echo pin, and ground pin, as shown in the Fig. 1 [11]. The basic principle work of this sensor is capturing the wave reflection that transmits by the transmitter. The wave reflection occurs when the wave pounds the object. The transmitter was activated by pulse with a period of 10 us through Trigger pin. The reflected wave perceives by the receiver via pin Echo. The ultrasonic wave emitted by the transmitter has a frequency of 40 kHz. The duration of the travel time of ultrasonic waves from the transmitter to the receiver is used as a reference in the calculating distance of the sensor object [6].
The researchers have been working on methods to decrease the error level or deviation level. The main purpose of the error correction method is the accuracy level improvement of the sensors. Several numbers of researches have been used as a reference to emphasize the utilization of the error correction method in an accuracy improvement. The error correction method has been proposed by Liu to improve the accuracy level of the SAW (Surface Acoustic Wave) sensor. The usage of the error correction method has succeeded in improving the accuracy level and decrease the deviation level of this sensor [12]. The adaptive algorithm for error correction has been proposed by Pop. This error correction method has been used to measure the temperature. The objective of this proposed method is systematic error reduction. The systematic error is the error caused by highfrequency noise [13]. Jiang proposed an error correction method based on a neural network. The objective of the proposed method is the decreasing of the error level in pressure sensor measurement. The improvement of sensor performance has been achieved successfully [14]. The error correction method based on Support Vector Machine (SVM) has been proposed by Zhang. This method has been implemented to infrared the methane sensor. The challenge of this research is the difficulties of the support vector machine training [15]. The polynomial fitting based-error correction method to decrease the error of the gyro sensor has been proposed by Gao. By using the polynomial fitting, the error level of the gyro sensor has significantly reduced [16]. Yang also proposed similar polynomial fitting based-error correction for electromagnetic indoor positioning sensors. This method has been successful in improving accuracy by 1.5 cm. The accuracy improvement has been achieved successfully [17].
Polynomial fitting categorized as a powerful method since its ability to perform outlier detection, error correction, and automatic defect data fixing. The outlier detection feature has been implemented in aircraft industries to remove the outlier in flight data testing. The automatic defect has also been used to repair the flight data testing [18]. The error correction based on polynomial fitting has been proposed by Yang. This method has been implemented on the electromagnetic electronic indoor positioning system. The accuracy improvement has been achieved successfully [17]. The ability to restore the defective data is the feature of the interpolation properties.
The other method of the polynomial fitting is Langrange's polynomials interpolation. Langrange's polynomial interpolation is widely used in the computation world. Srivastava examines the performance of both algorithms to perform trigonometric, logarithmic, and exponential function operation.
However, Langrange's polynomial interpolation has poor performance that Newton's polynomial interpolation. Newton's polynomials interpolation produces less error than Langrange's polynomials interpolation [19]. Since the robustness offered by Newton's polynomials interpolation, then the implementation of this algorithm has been performed in this research. The stages of this research consist of four different processes, as shown in Fig. 2.

A. Data acquisition of HC-SR04 sensor
Firstly, data acquisition has been performed in this research. The sensor measures the distance between the target object and the sensor. The result of the sensor measurement was pulse signal. The pulse signal would be sent to the microcontroller. The hardware block diagram is shown in Fig. 3  The microcontroller has been used to calculate the measured distance. The connection diagram between HC-SR04 sensor and the 8-bit microcontroller shown in Fig. 4. The HC-SR04 sensor has four pins, namely Ground, Vcc, Trig, and Echo. The Vcc and Ground pin is the main power pin module. The Vcc pin must be connected to 5 Volt DC. The ground pin must be connected to the ground terminal. The ultrasound generation requires to set the Trig pin on a high state for 10 µs. The eight cycles sonic burst would travel at the speed sound. The wave would be reflected by the measured object and then received by the Echo pin. The changing of the state of the Echo pin would be read by the microcontroller. The microcontroller calculates the travel time of the ultrasound wave. The calculation result would then be sent to the RS232 monitor to display the measurement result.

B. Data modelling
The error analysis is the earliest step in the data modeling stage. It has been used to observe the deviation level of the sensor. This observation produces two vectors, namely error values and correct values. The next step is data modeling stage. The error values and the correct values would be modeled by using Newton's interpolation algorithm. The result of this step is the model equation.

C. Model implementation
The model equation generated by the data modeling stage would be implemented in the microcontroller. Firstly, the microcontroller calculated the distance range measured by the HC-SR04 sensor. It resulted in the measured distance range. Since the distance range generated by the HC-SR04 sensor has deviation, then Newton's polynomial interpolation algorithm would be performed. Fig. 5 shows the model implementation process.

D. Performance evaluation
The final stage of this research was performance evaluation. The performance comparison between the measurement result of the sensor without Newton's polynomials interpolation and the measurement result of the sensor integrated with Newton's polynomials interpolation has been performed in this research.

III. RESULT
The data acquisition stage is resulting in an actual measurement value that has a significant deviation. The significant deviation leads to a significant error. The interval of the data acquisition process that used in this research is 5 cm. The highest deviation level occurs in the ideal value of 90 cm. The error level at this point is 22.6 cm. The minimum level of deviation occurs in the ideal value of 10 cm. The error level at this point is -0.25 cm. Further processing is required to improve sensor accuracy. The data acquisition result is shown in Table 1.  According to Table 1, there is a significant deviation between the measurement result that perform by the HC-SR04 sensor and the comparative instrument as ideal values. The significance of the deviation level could be seen in Fig. 6.

IV. DISCUSSION
The Newton's polynomial interpolation basederror correction has two main steps, namely dataset creation and coefficient calculation.

A. Dataset creation
Dataset creation represents the relationship between error values and correct values. The error values are the sets of values derived from the observation result of the HC-SR04 sensor distance measurement. The correct values are a comparative value derived from the comparative instrument. In this research, the ruler or conventional distance meter has been used as a comparative instrument. The observation table is shown in Table 2.
The value is the data sequence, is the th data of the error values or observed values, ( ) is the th data of the correct values. Basically ( ) is a function of . However, the function ( ) is unknown. To find the unknown function then Newton's polynomials interpolation has been used in this research. In other words, Newton's interpolation polynomial is used to find the unknown function.
The result of the data modelling stage is in the form of (1). The model result then would be implemented to 8-bit microcontroller to perform the error correction.

C. Performance evaluation
The comparison of the MSE (Mean Squared Error) level has been used in this research. This performance evaluation compares the MSE level between the two datasets. The first dataset is the sensor measurement result without Newton's polynomials interpolation. The second dataset is the sensor measurement result that utilizes Newton's polynomials interpolation. The performance evaluation result shown in Fig. 7 As seen in Fig. 7, the utilization of Newton's polynomials interpolation resulting in a better result. Newton's IP line is very close to the ideal values line. The MSE assessment method has been used in this research. The MSE level represents the closeness level to the target value. The lower MSE value leads to a lower error level [20]. . The MSE value for the sensor measurement without Newton's polynomials interpolations is 29.96. The lower MSE level has been achieved by the utilization of Newton's polynomial interpolation. By utilizes Newton's polynomial interpolation, the MSE level decrease in the level of 13.32. The lower MSE value means it closer to the target value and leads to a lower error level. Newton's polynomials interpolation has succeeded in improving the accuracy level of the sensor by 55.54%.

V. CONCLUSION
The deviation is an issue in most sensor systems, especially for the low-cost sensor. The HC-SR04 sensor categorized as low-cost sensor, and it has a significant deviation. The significant deviation leads to significant error. The error level affects the accuracy of the measurement result directly. Newton's polynomials interpolation algorithm is a powerful method to resolve the accuracy problem in the sensor. This algorithm has superior performance and produces less error than Lagrange algorithm. By utilizes Newton's polynomial interpolation, the MSE level of the sensor measurement decrease in the level of 13.32. Newton's polynomials interpolation has succeeded in improving the accuracy level of the sensor by 55.54%.