Improved Progressive Polynomial Algorithm for Self-Adjustment and Optimal Response in Intelligent Sensors

The development of intelligent sensors involves the design of reconfigurable systems capable of working with different input sensors signals. Reconfigurable systems should expend the least possible amount of time readjusting. A self-adjustment algorithm for intelligent sensors should be able to fix major problems such as offset, variation of gain and lack of linearity with good accuracy. This paper shows the performance of a progressive polynomial algorithm utilizing different grades of relative nonlinearity of an output sensor signal. It also presents an improvement to this algorithm which obtains an optimal response with minimum nonlinearity error, based on the number and selection sequence of the readjust points. In order to verify the potential of this proposed criterion, a temperature measurement system was designed. The system is based on a thermistor which presents one of the worst nonlinearity behaviors. The application of the proposed improved method in this system showed that an adequate sequence of the adjustment points yields to the minimum nonlinearity error. In realistic applications, by knowing the grade of relative nonlinearity of a sensor, the number of readjustment points can be determined using the proposed method in order to obtain the desired nonlinearity error. This will impact on readjustment methodologies and their associated factors like time and cost.


Introduction
The development of intelligent sensors involves the use of self-adjustment algorithms that should be able to fix major problems such as offset, variation of gain and no linearity with good accuracy. Besides, it will be focused to simplify the calibration process.
The calibration stage is where many of the major problems begin because in the development and maintenance of measurement systems verification and readjustment processes are required. An accepted practice utilized in the past by measurement systems designers was to linearize the sensor output. The subject of linearization has been considered on different forms and stages, basically in the design of circuits with MOS and CMOS technologies [1][2]. Studied cases included the usage of analog to digital converters to solve nonlinearities at the same time that the conversion is made [3][4]. Also, type R-2R digital to analog converters have proven the necessity to improve the linear response [5]. Other research focused on improving the nonlinear response of specific sensors, like the thermistor [6] and the Hall Effect current sensor [7]. Further, ROM memories are used to save data tables and to solve the linearization problem [8][9]. Numerical methods have been developed using modern technologies [10][11][12]. The self-calibration concept using artificial neural networks is approached from different perspectives: for a pyroelectric sensor [13][14], simulation of autocalibration results [15] and works related with specific sensors autocalibration [16][17][18]. These can not be easily implemented on a digital signal processor (DSP) or a small microcontroller ( μC ). However, additional work on complex training process, a personal computer and special background preparation of the users are required. Now, if the cost associated with the maintenance of the measurement systems is reviewed we can see that in a research done by Hutchins [19] at the end of the last century, he claimed that in the global marketing from the 70´s to the 90´s, the investment in test and measurement equipment reached 9,000 million dollars, from which, 2,000 million dollars were applied to maintenance and 1,200 million dollars were needed for the sole purpose of calibration. Companies' competitiveness must be certified. Initially, this was accomplished by the use of Military Standards and more recently with ISO´s standards [20]. As a consequence, operational costs have increased. By the end of 2004, in manufacturing industries of the Unites States alone it was estimated that a total of 218.8 million dollars was spent on calibration services during 2005 [21] and by the year 2006 the budget on quality services with the sole purpose of anticipating problems and correcting measurement equipment was 1.1B dollars [22]. The characteristics of measurement systems can change according to different factors such as work environment, use, age, etc. In 2003, Powell [23] stated that "the calibration services industry has seen growth rates in excess of 15% per year in many countries".
The development of intelligent sensors with readjustment capabilities is imperative in order to facilitate calibration while not increasing its costs. Today designers have different options for self readjustment sensors, some of which are artificial neural networks theory [16,24] or recursive algorithms [25][26] Several important works related to recursive algorithms that can be applied to the self readjustment of intelligent sensors exist, one of which is the progressive polynomial calibration method [25], although its effectiveness has not been proven yet and the number of points required to achieve a minimal error it is not clear. Another method used to select the number of readjustment points required is shown by Dias [26]. This particular calibration process is too expensive for the required number of points and the amount of time invested. Furthermore this criterion cannot be applied in a general way. Looking for a general solution that can be applied to different sensors, reducing the amount of time required for calibration process is a most. Further research is necessary to obtain an optimal result, and the minimum error with the lowest amount of verification points during readjustment process.
This paper presents the improvement of a progressive polynomial algorithm that facilitates the calibration process due to the self-adjustment of sensor. This proposal is based on the calibration method presented by Fouad [25]. The method has been improved in two aspects: the evaluation of the effectiveness method with respect to the percentage of nonlinearity of the input signal and the method´s optimization to achieve the minimum error. In this proposal a minimal amount of adjustment points are taken into consideration and an evaluation of the correct selection sequence of the calibration points are made in order to get the optimal yield. To prove the worthiness of this proposal a real temperature measurement system was designed.
One important point that needs clarification before proceeding is related to the meaning of the term "self-adjustment". Adjustment is mainly concerned to the process of removing systematic errors in accordance with the definition in the Metrology and the International Vocabulary of Basic and General Terms in Metrology (VIM), ISO VIM [27][28]. This action, in the past, was used as calibration by [4,15,24,25].
The paper structure will be the following: the basic system design considerations are presented in Section 2. The improved polynomial progressive algorithm and its simulation results are described in Section 3. A practical implementation of an intelligent sensor with improved algorithm on small microcontroller (MCU) is showed in Section 4 and the tests and results are described in Section 5.

Intelligent Sensors Functionalities.
The term smart sensor was coined in the mid of 1980s [29] and sensor intelligence has been discussed since 1993 [30]. Using the references regarding intelligent sensors and the smart sensor definition from the Institute of Electrical and Electronics Engineers [29][30] a classification of intelligence in sensors based on their functionalities is proposed in Figure 1. Due to the importance of these aspects, they are considered individually, as an example, the cases of processing functionality [31][32][33].
This paper is focused on the compensation functionality. The compensation factor will be operating in three categories: Nonlinear compensation that linearizes the relationship between input and output, Cross-sensitivity compensation due to ambient conditions and time based or long term drift compensation due to degradation of the sensor or its elements [30]. An improved algorithm to make the compensation of the linearity and compensation due to degradation will be explained in the following sections.

Progressive Polynomial for Self-adjustment Method.
A previous step to the application of progressive polynomial calibration algorithm is the normalization of the input and output variables. For example, the output electrical signal ' y of any sensor in response to the input variable ' x is defined by: In most of the cases the input and output variables scales are different, and these variables need to be normalized. We suggest making the normalization of ' and ' x y in the range of [0,1]. This can be obtained from the following equations: After the normalization, Equation (1) can be rewritten as: ( ) y f x  . Now, the desired output signal is one straight line with unitary slope. This will be the target in the adjustment process and will be the reference signal defined by: t x  (4) Once the input and output variables are normalized the four steps of the polynomial progressive polynomial method [25], described bellow, can be applied: 1. Based on the adjustment process of measuring systems [27], N readjustment points into of measurement range of the sensor are chosen and called readjustment vector, x' . The readjustment vector is supplied to the sensor and the output signal is recorded to generate the vector y' . Using Equations (2) and (3) . These values are required only to compute the coefficients 1 k to N k as described in the following steps. 2. With the first points x 1 , y 1 and t 1 any offset problem is fixed. This involves computing coefficient k 1 : and a new function f 1 is defined as follows: 1 1 f y k   (6) If the y function does not include an offset error, the coefficient k 1 is zero and the equation f 1 is equal to y . Remember, the normalized output signal for any input signal is represented by y and this signal is generated by the sensor under normal operation. 3. Using the points 2 2 and x y the gain problem, if any, is eliminated . Where 2 x is the upper limit of the measure scale. Then the k 2 coefficient is obtained by: The new function 2 2 1 1 ( , , ) f k t f , without the gain problem is defined as: If a gain error is not observed in y , the 2 k coefficient is zero and equation f 2 is equal to equation f 1 . For sensors with linear transfer function three foregoing steps are enough to self-readjustment of the sensor, but if the transfer function is nonlinear, more coefficients k and functions f are required. 4. If the transfer function of the sensor is nonlinear, a new set of coefficients and functions are defined. The coefficients k 3 to k N are defined by: (9) and the function f 3 to f N defined by: The new transfer function of the sensor is represented by: Finally, the relative error metric, (12), can be used to determine how linear is the f N function obtained: Or another way to corroborate the method is by using the least mean square error, expressed by Current literature qualifies this method just as a qualitative way; the criteria of how the sequence of readjustment points will be taken and its capability of quantitative means are not available. In the next section one proposal for effective algorithm evaluation with respect to the percent of nonlinearity of the input signal is presented, as well as the necessary modifications to improve the method to obtain the minimum relative error.

Permutation Vector Analysis.
In the previous section a recursive linearization method was described. However, it is necessary to define its performance under a set of important characteristics. Some of these characteristics include: number of adjustment points required, time expended in the adjustment process, the minimum nonlinearity error desired, and the applicability of the method to any sensor.
For example, a criterion to choose the number of calibration points based on a scale region where the sensor will be used is described in [26]. This scale region is determined by analysis of the probability distribution function of the measurements. Nevertheless, for some measurement systems this method is expensive considering the calibration time and the number of required points. A new process to evaluate the algorithm´s performance is described as follows.
The first step is to select a nonlinear function as the input to the linearization process. In this document an increasing exponential function defined by (14) was selected: ………………………………………………. (14) where ' x is the input signal of any variable, and the parameter r determines the increasing rate of the function. Therefore, r allows us to simulate different grades of relative nonlinearities. With the value of r the range of nonlinearity of the function ' y can be controlled and it may represent a great variety of sensors. Figure 2 illustrates several realizations of the Equation (14) showing different grades of relative nonlinearities, from 10% to 95% with ' and y' x normalized according to Equations (2) and (3).
The percentage of nonlinearity was computed with the Equation (12). The next step consists of selecting a set of adjustment points, with cardinality N, for each calculation of (14). The order of the adjustment points is taken randomly or empirically, in this paper the number of selected points was N=5 and N=7. For each set of adjustment points an input vector 1, 2,...., is generated together with its corresponding vectors. In order to reduce the computational burden and to standardize the process, 1 x and 2 x represent the lower and the upper limit that can be measured by the measurement system or the intelligent sensor.
Two sets of calibration points were randomly generated in order to consider two different cases. These sets are shown bellow: In the experiment, the range of x was from 0 to 100 normalized from 0 to 1. The parameter r was changed from 95 to 1. The maximum percentage of nonlinearity relative error between Equation (14) and Equation (12), ry  , was computed and the maximum percent of nonlinearity relative error ry  goes from 12.96% to 94.33%. The maximum nonlinearity relative errors using N= 5 and N=7, are shown in Figure 3 and Figure 4, respectively. According to these results, if five points of adjustment are used, then the method can compensate sensors with a maximum nonlinearity relative error under 21%, yielding a maximum nonlinearity relative error output lower than 1% as shown in Figure 3. It is important to notice the difference of results between Case 1 and Case 2. Notice that Case 2 has less error compared with the result of Case 1, the difference was the order of the elements (3), (4) and (5) x x x for N=5 that was taken.
According to these results, if seven points of adjustment are taken then the method can compensate sensors with a maximum nonlinearity relative error under 32%, yielding a maximum nonlinearity relative error output lower than 1% as shown in Figure 4. It is noteworthy that the difference of results between Case 1 and Case 2 with 7 N  . Case 2 has lower error compared with the result of Case 1. The difference is related to the order of the elements, (3) to (7) x x , supplied to compute the 7 f function. The error difference between the results of Case 1 and Case 2 is important and it is noted in Case 2 of both experiments, using N=5 and N=7 adjustment points, the yields have lower error and the algorithm can compensate the sensor with the highest nonlinearity. Another important observation from Figures 3 and 4 is that the nonlinearity relative error output changes not only with respect of the number of adjustment points used but also with the order of the adjustment points selected. In Figures 3 and 4, results showed that the error of Case 1 is greater than the error of Case 2. Therefore, this observation leads us to find a method to assure that the obtained result of the coefficients k N and the functions f N are optimal. This method is presented next.

Improved Polynomial Progressive Algorithm with Permutation Vector Analysis.
In order to establish a systematic method to avoid all the subjective aspects of the original algorithm an improvement to the algorithm was performed. This is proposed herein through the analysis of the response of the polynomial progressive algorithm. Then, considering the adjustment input vector for N=6, lets say: x vectors that can be generated in this case are 24 permuted vectors, that is, l goes from 1 to 24. The progressive polynomial method is then evaluated with each one of these permuted vectors. This process yields twenty-four N l f functions; for this example 6 N  and l take values from 1 to 24. Figure 5 shows the nonlinearity relative error output for each 6 f function. Considering an input signal with 28.87% of maximum nonlinearity relative error, the method will generate a maximum nonlinearity relative error output lower than 0.24%. This result is obtained with the permutation vector 2 p x , the number superscript 2 is to indicate the permutation number, defined by: As it can be noticed from Figure 5 the maximum nonlinearity relative error output using 2 p x is lower or equal to the nonlinearity relative error output reported with N=7. This finding indicates that with the following proposed method, the permutation vector analysis (PVA), the order of the optimal p x can be found. Consequently, the empirical aspect to select the order of the adjustment points involved in the progressive polynomial method is avoided. To summarize, the PVA method provides a novel formal methodology to select the order of the adjustment points to assure the optimal compensation result and the minimum nonlinearity relative error. Programming this algorithm into the μC or DSP or central processing unit of the intelligent sensor; provides the sensor with the selfadjustment capability or the self compensation capability.  x , and the nonlinearity error associated using (12) is evaluated. The optimal solution that corresponds to the minimum error will be selected, this algorithm can be represented by the flow chart on Figure 6. The following experiment was done using simulation software in order to evaluate the improved algorithm: First, five sets of readjustment points were taken; the difference between each set was the number of adjustment points N. Second, the input signal x for the algorithm was defined by (14) which is shown in Figure 2, the range of adjustment was 0 to 100. Third, the PVA algorithm described above was computed. The input signals x for the experiment after normalization process (2)  This was done to confirm that the result was the optimal with a minimum percentage of nonlinearity. x indicates that the best result was found in the permutation 108 when the vector of adjustment was nine points. Then, the corresponding l N f for the optimal function was computed and evaluated using the input signal of Figure 2, the results are shown in Figure 7.  By analyzing the results of Figure 7 we can see that with 5 N  , the improved polynomial progressive algorithm with permutation vector analysis (IPPA-PVA) can fix problems of nonlinearity up to 25% with less of 1% of relative error, instead of the 21.55 % obtained before the empirical application of the algorithm. Using 7 N  the improved algorithm and the kind of the input signal have the best results and can fix problems of nonlinearity up to 45% instead of 36% obtained before (see Figure 4). Besides, in order to get better results with the improved algorithm two important aspects needed to be considered here: the quantitative results of the algorithm capability and the improved method guarantee that the optimal result is always reached. With 8 N  and 9 N  the results were improved for input signal under 32% of nonlinearity but were not better for input signal upper to 32% of nonlinearity because oscillations were present around the solution, some author´s call this the "over fitting" effect [35]. This is not a problem here because an algorithm that works with a small quantity of readjustment points was being sought. This in turn results in an improved algorithm and its practical application is presented in the next section.

Intelligent Sensor Design with IPPA-PVA for self-Adjustment implemented on small MCU
Temperature measurement systems are commonly used in almost any process. A thermistor as temperature sensor was selected in the construction of a measurement system. The thermistors, besides having a diversity of applications, can be found in a great variety of ways, sizes and characteristics. In this case, the major characteristic that will be analyzed is the  coefficient, fundamental characteristic to describe the nonlinearity error. For example values from =3100 to =4500 generate nonlinearity errors from 41.07% to 51.34%. With this percentage of error it is too difficult to obtain acceptable results with the described algorithm.
It is clear that in practical cases, the sensor will be on a circuit converting temperature to voltage capability, for example, a tension divider circuit or a Wheatstone bridge. The intelligent sensor was designed on a small MCU. Its topology is shown in Figure 8. The major features of the MCU for physic implementation are: eight bits word, ten bits analog to digital converter ADC, clock of 20 MHz, 3 Kbytes of RAM and communication of Control Area Network (CAN 2.0B). The improved algorithm described in Section 3 was programmed using C language. Five thermistors of different values of  in the range from 3,100 to 4,500 were selected and the range for the temperature measurement system was selected from 0 o C to 120 o C. In order to perform the test, each thermistor was placed on a tension divider circuit and the output was switched to the MCU. The output voltage of the tension divider circuit is the signal ' y of (1) shown in Figure 9.This signal presents offset problems and nonlinearity that will be fixed using the improved algorithm described above. The maximum percentage of nonlinearity of the output voltage was 13% with a thermistor of =3890 and 22.7% with a thermistor of =4100. On Figure 10, the nonlinearity feature of each thermistor is illustrated. Using the methodology presented in Section 3.2 and reviewing Figure  7, it can be noted that if six points are used to carry out the Self-Adjustment, the maximum percentage of nonlinearity of the output signal will be less than 1%.

Tests and Results
The proposed improved algorithm was computed and the performance of the improved algorithm was compared against a Honeywell temperature meter, number UDC3000 with a thermocouple type K, span of -29 to 538 o C (-20 to 1,000 o F) and accuracy of  0.02%, taking 25 measures from a range of 0 to 120 o C in 5 o C steps using an oven system to change the temperature. The results are shown in Figure 11.
The output of the improved algorithm compared with the target straight line can be seen in Figure  11. In order to better visualize the error between the algorithm output and the target straight line the percentage of relative error of nonlinearity computed with Equation (12) is shown in Figure 12. In summary Figure 12 shows the difference between the ideal output and the output provided by the Improved Algorithm. It can also be observed that the maximum percentage of nonlinearity relative error of is under 1%, approximately 0.13% bellow of 1% as was estimated from simulation and was illustrated in Figure 7 with six calibration points. The same process as described above was done for the other thermistors and the obtained results are shown in Table 1. The thermistor characteristics are listed on the first column. Column two shows the percentage of nonlinearity of the output voltage. The best permutation of the vector l p x and its maximum percentage of nonlinearity error range obtained are shown in Columns 3 and 4, respectively.
The results indicate that the maximum nonlinearity relative error, for each case, is less than 1%. These results were generated from a quantitative analysis of IPPA-PVA, therefore, yielding the certainty of confidence that it is the optimal solution. the number of bits of the ADC is n . In our example the 5 FRS E  volts and the ADC is ten bits, then the sensor resolution is 9.8 mV, meaning that the temperature sensor is limited to detect temperature changes of about 0.3 o C. If this resolution represents a problem in a specific application, an external ADC with more than 10 bits can be used. Table 1. Improved Algorithm evaluation results.

Conclusions
In this paper an improved progressive polynomial algorithm to perform compensation in intelligent sensors was presented. The improved algorithm needs to be executed only the first time the sensor is calibrated. Using data from Figure 7, which was discussed early, the position of the calibration points changes according to the percentage of nonlinearity of the sensor output signal. Then the initial value of the percentage of nonlinearity can be saved as an important sensor specification data and the process will be repeated only if a substantial change in this value is presented. Beside a special methodology to evaluate the capability of any compensation algorithm with one quantitative parameter was presented. In this way, any doubt can be avoided and a significant amount of time can be saved for the designers.
The proposed method assures the optimal solution using few adjustment points, reducing the time spent in the adjustment of the calibration process and reducing the calibration cost as a consequence. This method can be used for any sensor, as long as, the percentage of nonlinearity is under 40% and if the desired error is less than 1%.
The algorithm can be easily programmed into a microcontroller because it consists of simple operations and only the coefficients from 1 k to N k , needed to be saved.