Measurement and process control loops often use 8bit microcontrollers. The devices are inexpensive and widely available, and they can be programmed in many popular highlevel languages – like C and Basic. However, if the loop requires a nonlinear sensor, the designer faces the added challenge of having to develop a software linearization algorithm.
One solution is to design hardware to perform the required curve fitting before the sensor’s output signal is applied to the microcontroller’s analogtodigital converter (ADC) input. This is an especially attractive solution if processor memory is limited and cost and component count can be kept low. An added benefit is a small printedcircuit board (PCB) footprint.
Figure 1.  Instead of a software linearization algorithm, this circuit uses a hardware solution to perform the required curve fitting for a nonlinear sensor. 
An example is the circuit shown in the Figure 1, which uses a typeE thermocouple to measure temperatures that are expected to vary from 0 °C to 500 °C. The circuit’s output ranges from 0 to 5 V – the full span of the ADC – and can be expressed as a linear system equation:
(1) 
The thermocouple amplifier section consists of a thermocouple coldjunction compensator (IC1), an op amp (IC2), and accompanying circuitry. IC1 tracks ambient temperature (T_{R}) and adds a correction voltage (V_{C}) to cancel the coldjunction voltage (V_{R}) created when chromelconstantan thermocouple leads are attached to the copper pads of a PCB. IC2 then amplifies the thermocouple’s temperaturedependent signal (V_{M}) by 175 to produce V_{T} prior to linearization. A gain of 175 eliminates the need for additional amplification during curve fitting.
Lowpass filter C1R2 has a pole at approximately 6 Hz to remove powersupply noise.
Table 1.  The temperature entries for T_{M} with their corresponding thermoelectric voltages 


You can use an Excel spreadsheet to create the nonlinear mathematical relationship between the output of the thermocouple amplifier (V_{T}) and the input to the ADC (V_{O}). The Table 1 shows 11 temperature entries for TM (0 °C to 500 °C in 50 °C steps) with their corresponding thermoelectric voltages, V_{M}. The values of V_{M} were derived from a standard typeE thermocouple reference table. Also shown are V_{T} and V_{O}, which are charted using the (XY) Scatter feature of the software. The equation for V_{O} is created using the software’s trendline feature:
(2) 
An analog multiplier (IC3) and five 1% resistors implement this equation, a secondorder polynomial of the form:
(3) 
The four (X and Y) inputs of IC3 are wired to create a negative square term that’s scaled at the chip’s output by an internal scale factor of 0.1 V. Comparing terms, we note that c must equal 0.0165. Since R3 and R4 form a voltage divider to attenuate V_{T}, we can express c as follows:
(4) 
You can then solve for R3 by substituting c = 0.0165 and selecting a value for R4, which for this design was chosen to be 10 kΩ.
Resistors R5, R6, and R7 form a passive adder to create the offset term, a, and the linear coefficient, b, in Equation 3. The output of the passive adder is applied directly to the Zinput of IC3, which adds the offset and linear terms to the square term. Again comparing terms, a (Equation 3) equals 0.0342 V (Equation 2). We can express this as:
(5) 
To design this part of the passive adder, we chose a stable 2.500V reference for V_{REF}, selected R5 to be 10 kΩ, and solved for R6.
Finally, compare b (Equation 3) with the corresponding value of 0.8703 (Equation 2) and express the linear coefficient b as:
(6) 
This equation is solved to determine the final component, R7:
(7) 
We evaluated the circuit by replacing the thermocouple with a lowimpedance voltage source to simulate V_{M}. IC3’s output voltage (V_{O}) exhibited a worstcase error of about 3.4 °C at 0 °C (V_{O} = 0.034 V) and an error of –1.8 °C at 500 °C (V_{O} = 4.982 V) at full scale. At 250 °C, a midrange error of 0.2 °C (V_{O} = 2.502 V) was recorded.
Reference
 “IC Generates SecondOrder Polynomial,” Electronic Design, Aug. 5, 1993, p . 83.