The Newton’s Polynomial Based - Automatic Model Generation (AMG) for Sensor Calibration to Improve the Performance of the Low-Cost Ultrasonic Range Finder (HC-SR04)

— The ultrasonic range finder sensors is a general-purpose sensor to measure the distance contactless. This sensor is categorized as a low-cost sensor that is widely used in various applications. This sensor has a significant deviation that leads to significant errors in the measurement result. The error produced by this sensor tends to increase proportionally to the measured distance. The implementation of a particular algorithm is required to reduce the error value. The model-based calibration is a solution to increase accuracy. The model-based solutions are no longer feasible if the states of the model have changed. The length of the usage of the sensor leads to sensor fatigue. Sensor fatigue is one of the causes of model state changes. If the drift is still within the tolerance limit, the sensor performance can still be restored using the calibration method. The model-based calibration calibrates the sensor by using the model. The update of the model must be made whenever the changing of the model state occurred. Since the manual model-making process is not an easy task, time, and cost required, then the Newton polynomial-based (Automatic Model Generation (AMG) has been implemented in this research. The AMG algorithm generates the new sensor model automatically based on the most updated states. This automatic model generation is implemented in the calibration process of the ultrasonic sensor. The implementation of a polynomial-based AMG algorithm for sensor calibration has been succeeded in improving the calibrated sensor’s accuracy by 96.4% and reducing the MSE level from 25.6 to 0.914.


INTRODUCTION
The ultrasonic range finder is a general-purpose distance measure sensor contactless. This sensor uses ultrasonic sound wave to measure the distance of a certain object. This sensor is categorized as a low-cost sensor and is widely used in many applications [1]. This sensor's advantages are very affordable in price, easy installation, and simple interfacing mechanism [2]. On the other hand, this sensor also has a weakness. The significance of the deviation level is the main weakness of this sensor. The deviation level increases proportionally to the measured distance. The farther distance of the object's measurement results affects the deviation level [3]. This weakness is successfully addressed in the previous research by using the Newton polynomial method. The Newton polynomial method usage has been succeeded in decreasing the error level significantly [4]. This method is categorized as a model-based solution. The model-based solution's weakness is the feasibility of the model's change of state [5].
the replacement solution requires a high cost, the existing sensors' usage might become another solution to the users. As long as the sensor performance is still within the tolerance limit, the sensor performance could be restored using calibration methods [11]- [14]. Certain sensors have options for calibration features, especially for high-end sensors [15]- [18]. Low-cost sensors are not featured with calibration options, mostly. A model-based solution is one of the methods to calibrate a low-cost sensor. This is an alternative solution besides a sensor replacement solution [5], [19]- [23].
The update of the sensor model must be made whenever the changing of the states occurred. Since the manual model-making process is not an easy task, it requires more time to calculate and evaluate, and the cost is required [24], [25]. This research proposes the Newton polynomial-based-automatic model generation. This automatic model generator algorithm automatically generates the new sensor model based on the changing of the model states. The calibration process of the ultrasonic sensor would implement this automatic model generation. The users can perform calibration process on the run. A microcontroller or microprocessor can embed this algorithm. The decrease in the error level reduced setting time duration, and increased cost-efficiency in calibration process is the goal of this research.

II. RESEARCH METHOD
The most important part of the HC-SR04 sensor is divided into two parts. The first part is the ultrasonic transmitter, and the second part is the ultrasonic receiver. The working principle of this sensor is based on sound wave reflection. The receiver unit captured the reflection of the ultrasonic sound wave transmitted by the transmitter unit. The wave reflection occurs when the ultrasonic wave pounds an object. The frequency of the ultrasonic sound wave transmitted by the transmitter unit is 40 kHz. This sensor counts the wave travel time as a reference to obtain the measured distance [1]- [3], [26], [27].
Many applications utilize the HC-SR04 sensor to measure the distance of the object contactless. The benefit of this sensor's usage is cheap since this sensor is categorized as a low-cost sensor. The weakness of this sensor is the high of the deviation level. Thus, a high level of deviation leads to a high error level. The error rate of this sensor is proportional with the measured distance. The Newton polynomials method has been succeeded in decreasing the error level. The accuracy of this sensor has been increased by 55,54% [4].
The long-used and less-robust sensors tend to decrease the accuracy and precision level [6]- [10]. The decrease of the sensor performance is affected by several factors, namely temperature effect, density, humidity level, measurement range and material effect [28]. The long-used sensor tends to experience the decrease of quality and parts performance, high possibility of sensor fatigue, a high level of deviation, and sensor failure [6]- [10].
The performance restoring is required for a sensor that is experiencing a decrease in performance. The calibration method is the most general solution for this sensor performance problem [5], [19]- [23]. Calibration established a relation between the measurement values with measurement uncertainties provided by particular standards and corresponding measurement results with its measurement uncertainties [23], [29]. However, the calibration feature is only owned by an upper-middle-class sensor [15]- [18]. Generally, the low-cost sensor is not featured with calibration features. Performing calibration for low-cost sensors required a particular method, namely, model-based calibration method [5], [19]- [23].
There are three types of calibration methods, namely one-point calibration, two-point calibration, and multipoint curve fitting. One-point calibration requires a pair sensor signal (y) and true value (x) for the calibration process. The constant I 0 can be added as a particular sensor constant or remains as zero [30]. The sensor sensitivity (m) of one-point calibration can be defined by: A two-point calibration is required when there are two pairs of signal values, namely 1, 1 and 2, 2 and the 0 is unknown. A two-point calibration equation can be described as following [30]: When multiple data points are available, the multipoint curve fitting could be applied as calibration method. Multipoint curve fitting method leads to the model-based calibration method [22], [29], [30].
Wenjun proposed model-based pressure sensor calibration using Support Vector Machine (SVM). The pressure sensor is a non-linear sensor. The performance was affected by temperature and supply voltage. The SVM method has been succeeded in decreasing the error to 0.6%. Before the implementation of the SVM-based model calibration, the error percentage is 22% [29]. Cai proposed modelbased calibration for the Electronic Control Unit (ECU) in diesel engine pumps. Local models and global models are used in the research. The polynomial spline algorithm was implemented in the local model. The RBF hybrid model was implemented in the global model. The results are the decrease in fuel consumption, and the workload has been decreased significantly [23]. Luo proposed a curve fitting calibration method for the ultrasonic flow meter. The interpolation polynomial theory became a ISSN : 2085-3688; e-ISSN : 2460-0997 base method in this curve fitting method. The result showed the ultrasonic flow meter had been succeeded in achieving level-1 accuracy. This method also offers low complexity in computation [12]. Jiang proposed polynomial fitting based on camera calibration. This vision system involved a digital camera and a polynomial fitting method. The precision between real-world coordinate and calculated coordinate is the aim of this research. The result showed the overall error is 0.5049 cm [31].
Polynomial fitting is a powerful method for many applications, especially in the computation area. It can perform error correction, outlier detection, calibration, and fixing for defect data [19], [31]- [35]. The Lagrange's polynomial interpolation is another method of fitting algorithm. That a widely used algorithm in the computation area.
Newton's polynomial interpolation is also categorized as a fitting algorithm. Srivastava performs a performance test for Lagrange's polynomial interpolation and Newton's polynomial interpolation. The performance test, including operation of trigonometric, logarithmic, and exponential. Newton's polynomial interpolation has better performance that Lagrange's polynomial interpolation. The interpolation produces higher error than Newton's polynomials interpolation [36]. The advantages offered by Newton's polynomial algorithm made this algorithm suitable for performing modelbased calibration.
The model-based calibration method required a mathematical model because they would affect the accuracy level. The valid model leads to the invalid measurement result, higher deviation level, and measurement failure. So, the model determination is critical in model-based calibration. The manual model making is not an easy task. Require calculation, evaluation, and simulation. All manual model-making requirements leads to time and cost-consuming [24], [25]. The automatic model generation (AMG) is expected to overcome this circumstance. The AMG algorithm automatically makes its model based on certain states. By using this algorithm, the manual model making is not required. The usage of automatic model generation is expected to save time and cost.
Feng applied an automatic model generation for the black box component with the imperfect accompanying specification in the automotive area. The automatic model generation clones the black-box component model by analyzing the input and output parameters. The black-box or unknown part leads to difficulties in analyzing and perform system integration. The automatic model generation algorithm mitigates these difficulties by providing implicit dependencies and model features [37]. Zhang proposed a Parallel Automatic Model Generator (PAMG) to speed up the microwave model development. The AMG converted the modeling process by a human into a computational process.
Since microwave modeling has complexity in the model, then the AMG algorithm with a parallel mechanism is proposed. In parallel, the AMG algorithm usage has been succeeded in increasing development time above 90% [38]. Dinechin proposed the automatic model generation for polynomial hardware architecture. This algorithm was implemented in FPGA hardware. Which is this algorithm creating synthesized model architecture using polynomial approximation. With the specified function was inputted in the approximation engine. It resulted in the coefficient tables. A polynomial-based evaluation optimizer evaluated the generated coefficients. The result of this evaluation algorithm is architecture parameters. The VHDL code generation used the architecture parameters to generate the VHDL code. By using this method, the accuracy of the model is guaranteed [39]. Using Dinechin's research principle, the AMG algorithm is highly possible to implement in a model-based calibration system. A polynomial-based AMG algorithm created the model for the calibration process. It offered the flexibility and comfort in calibration process. A high accuracy level for the calibrated sensor is expected in this research.

A. Data acquisition of HC-SR04 sensor
The data acquisition process has been performed in the earliest stage of this research. This stage involved the HC-SR04 ultrasonic sensor and a microcontroller. The block is shown in Fig. 1.   The connection pin of the HC-SR04 sensor includes a Ground pin, Vcc pin, Trigger pin and Echo pin. The Vcc pin and Ground pin provides an input power line to the module. The Vcc pin must be supplied with 5 Volt DC voltage. The ultrasound emission process requires µs pulse in the trigger pin. The reflection of the ultrasound wave is received by the Echo pin. The microcontroller calculates the travel time by using its internal clock to obtain the counted pulse. The counted pulse was used to determine the actual distance.
The microcontroller stored the recorded data in the data logger module. The record schema of the data logger module consists of 3 series of data, namely , , ( ). Where represents th sequence number of the data record, represents th measured values, and ( ) represents th true values. Fig. 4 shows the comparison of distance measured by the HC-SR04 sensor and the ideal values.

B. The AMG implementation
The  Once the model updater applied the most updated model, the model would automatically calibrate the sensor. A better result has been expected for the utilization of the AMG algorithm for model-based calibration.

C. Performance evaluation
The performance evaluation has been performed in the final stage of this research. The performance evaluation consists of two steps of operation. Firstly, the obtaining of MSE Mean Squared Error (MSE) value from the sensor without using model-based calibration. Latest, the obtaining of the MSE value of the sensor with model-based calibration. Both MSE values would be compared to obtain the best performance.

III. RESULT
The data acquisition is resulting in the measurement values with significant deviation. This high number of deviation levels leads to significant errors. The interval 5 cm has been used in the data acquisition stage. The most significant error occurs in 300 cm of ideal value. The error level at this point reached 8.38 cm. The Mean Squared Error (MSE) level of this measurement result is 25.6. The measurement drift is proportional to the measured distance. The measurement comparison figure is shown in Fig. 4.

IV. DISCUSSION
Newton's polynomial-based AMG algorithm for sensor calibration is divided into four main important parts: polynomials approximator, model builder, model validator, and model updater.  Table 1.  Each field of the dataset scheme has a different role, represents the sequence number of data, represent the th measurement values, and ( ) represent the th true values. The matrix representation with a size of 3 x is required since this pair scheme was embedded into a microprocessor or microcontroller.
The polynomials approximator approximates the coefficients of Newton's polynomial model. Newton's polynomials computation is divided into two parts. The first part is the computation for model coefficients as pre-processing computation. Secondly, model determination. The pre-processing step of Newton's polynomials was computed in this step. This computation involved the matrix. The computation formula is shown in (4).
The pre-processing step is resulting in the coefficient values arranged in Table 2.
Where = ( − 0 )( − 1 ) … ( − −1 ) and [ 0 , 1 , … , ] is the th divided difference of . The model builder involved T matrix as a coefficient table to build the model. The iteration process has been used to simplify the model building. The iteration involvement simplified the computation complexity in the model building. The simplification of Newton's polynomial algorithm with iteration involvement is shown in (7).

C. Model validator
The model validator validates the generated model that resulted from the model builder. The validation includes the fitting level calculation of the generated model. A certain fitting level threshold would be set up to the target machine. When the model in a fitting level lower than the threshold value, then the failure message would be occurred.
The Means Squared Error (MSE) method has been used as the principle of the model validator. The MSE level represents the closeness level to the target value. The lower MSE value leads to a lower error level. The equation of MSE is shown in (8).
The number of data quantity represented by , the number of true values represent by ̂, the number of measurement value represents by [40]. The MSE threshold value of 3 has been used in this research. When the MSE level of the model generated by the model builder resulting in an MSE level of more than 3, then it would be assumed as a failure.

D. Model updater
The model validator instructs the model updater to perform the model update. Model updater updates the values of and [ 0 , … , ] coefficient's when the most updated model was available. The equation scheme is shown in (6). Once the model update has been done, the microprocessor or microcontroller runs the most updated model to perform model-based calibration.   25.6 has been achieved before the implementation of a polynomial-based AMG algorithm. This algorithm succeeds in decreasing the MSE level by 96.4%. This improvement leads to the rising of sensor accuracy and a well-calibrated sensor. In our previous research, the utilization of Newton's polynomials with manual model-making succeeded in improving sensor performance by 55.54% [4]. Since the manual model making require more time and cost [24], [25]. The AMG algorithm requires no manual model making. A significant improvement of sensor performance has been succeeded in achieving achieve with the polynomial-based AMG algorithm. The low complexity computation also the advantage of this algorithm [12]. The resulting figure is shown in Fig. 6. The Automatic Model Generator (AMG) is a robust algorithm to generate a model in polynomial form. However, it has a weakness in generating a model for the non-linear dataset. The modification of the algorithm is needed for generating a non-linear model.

V. CONCLUSION
The low-cost sensor calibration is relatively difficult to perform. The low-cost sensors are not featured with calibration feature mostly. A modelbased calibration is a solution to resolve this problem. The model-based calibration requires the model to perform the calibration. A manual model making is no easy task. Require time and cost. The polynomialbased AMG (Automatic Model Generation) algorithm is a solution to create a model automatically. It offers comfort and flexibility in model-based calibration since no manual model making required. The machine generates a model automatically to be used in the calibration process. A significant result has been achieved in this research. implementing a polynomialbased AMG algorithm for sensor calibration has been succeeded to improve the accuracy of the calibrated sensor by 96.4% and reduce the MSE level from 25.6 to 0.914.