# How to calculate measurement error in an exponentially non-linear sensor? (self made pressure sensor)

I'm trying to calculate the measurement error from a home-made pressure sensor which I have in a voltage divider circuit. It has the same negative exponential non-linear resistance characteristics as an NTC thermistor: with increasing force [N] the resistance [ohms] decreases non-linearly. The pressure sensor acts as a variable resistor, and I am measuring the voltage drop across it using an 8bit ADC.

So far, I have taken resistance measurements (with a multimeter accuracy to .1 ohm) of the homemade velostat pressure sensor at exerted forces from 1 to 10 N using a force gauge (with an accuracy of 0.05N), with 5 resistance measurements at each force value. The average of the 5 measurements are graphed below.

My plan to calculate the exerted force [N] is to use a "power function" which is created from the data in Excel and rearrange it to solve for X (force) at a certain Y (resistance). The resistance (Y) is derived from the voltage measured by the ADC.

Is this a good approach, or should I use a lookup table or linear interpolation? (I'm not sure on how to do either of these yet.)

How do I calculate the measurement error from the sensor seeing as resistance changes only a small amount in higher force ranges, and resistance changes a lot (sensitive) at small exerted force ranges?  EDIT: added chart of my resistance measurements with max and min values graphed (the 20 measurements at each value of F [N] not shown in table).  • You already found an equivalent function, doesn't it fulfill you requirements? Dec 27, 2020 at 17:44
• What makes you think that the accuracy of your meter is 0.1 ohm? Is it possible that you are interpreting the resolution to be the accuracy? Dec 27, 2020 at 17:45
• you assume an exponential model, and that might be very fine – but I could fit arbitrary functions to your measurement points. How do you know it's exponential? Does that come from physics? Dec 27, 2020 at 17:57
• @MarcusMüller He doesn't have his correlation on there, but it would be close to 1. It would be hard to come up with an arbitrary function that fits that data set that good. Dec 27, 2020 at 18:53
• @StainlessSteelRat A third-degree polynomial would not fit this just as well? I'd be suprised! This exponential fit has three free parameters just as well: an offset, a prefactor and a scale. Dec 27, 2020 at 19:02

$$V_2=V_{ref}\dfrac{R_t}{R_1+R_t}=V_{ref}(\dfrac{1}{1+\dfrac{R_1}{R_t}})$$

$$V_2=V_{ref}(\dfrac{1}{1+\dfrac{R_1}{244.5x^{-0.941}}})$$

$$R_t=\dfrac{R_1}{\dfrac{V_{ref}}{V_2}-1}$$

$$244.5x^{-0.941}=\dfrac{R_1}{\dfrac{V_{ref}}{V_2}-1}$$

$$x^{-0.941}=\dfrac{R_1}{244.5(\dfrac{V_{ref}}{V_2}-1)}$$

$$-0.941\cdot lnx=ln\dfrac{R_1}{244.5(\dfrac{V_{ref}}{V_2}-1)}$$

$$x=e^(\dfrac{ln\dfrac{R_1}{244.5(\dfrac{V_{ref}}{V_2}-1)}}{-0.941})$$

$$x=\left( \dfrac{R_1}{244.5(\dfrac{V_{ref}}{V_2}-1)} \right) ^\dfrac{1}{-0.941}$$

You can now use the measurements and write the function into partial Taylor series.

$$x_{approx} = f(V_a)+{\frac {f'(V_a)}{1!}}(V_2-V_a)+{\frac {f''(V_a)}{2!}}(V_2-V_a)^{2}+{\frac {f'''(V_a)}{3!}}(V_2-V_a)^{3}+\cdots ,}$$

For each measurement point a, you calculate the 1 to n-th differential (additional LUT table, with fixed numbers) and then you calculate the interpolated value. Using just 1st derivative could be just fine, with 2nd derivative the measurement error will be greater than approximation error, 3rd derivative is an overkill.

If you have some MATLAB, Octave,...you could solve the derivations and calculate numbers. Then you use those pre-calculated values with regard of your calibration points. The only overhead to the CPU is then squaring the (V2-Va).

You could expand/modify the Taylor series for two neighboring points. link

EDIT:

I have searched the net for some symbolic differentiation. First of all in the school books you will usually find a function defined as y=f(x) so lets rearrange

y=(R_1/(244.45*(V_R/x-1)))^(1/-0.941)

where y is the Force, and x is the measured voltage

I have inserted the equation (R_1/(244.45*(V_R/x-1)))^(1/-0.941) into an online solver - www.derivative-calculator.net. I have chosen the values Vref=3.3V, R1=220 ohm. I did compute the voltage V2 according to equation (1) when Rt=130, according to your graph (function equivalent) it should be at force=2.

V2=3.3* 130/(220+130) = 1,225V

I got this: The force should be approx. 2, I don't know why is this deviation. The solver also made an simplification of the function:

$$\dfrac{4889^\frac{1000}{941}\left(\frac{V_{ref}}{x}-1\right)^\frac{1000}{941}}{20^\frac{1000}{941}R_1^\frac{1000}{941}}$$

Finally, the 1st derivative is: $$-\dfrac{50{\cdot}4889^\frac{1000}{941}V_{ref}\left(\frac{V_{ref}}{x}-1\right)^\frac{59}{941}}{941{\cdot}20^\frac{59}{941}R_1^\frac{1000}{941}x^2}$$

Now all you have to do is to insert values.

For example 1st point (F=1; Rt=230), V2=3.3*230/(220+230)= 1.686V. I do insert this value as x, and the value of the 1st derivative is f'(1.686)= -1.37612. The second derivative is 1.737047. For the small deviation around the 1st point the force could be computed as Taylor series of 2nd order:

$$F_{approx} = 1 - 1.37612\cdot (V_2-1.686V)+0.68806\cdot (V_2-1.686V)^2$$

Calculating the V2 for the 2nd point (F=2; Rt=135) as already before V2=1.225 and inserting into above equation gives F=1.78

• Your last $x=\dots$ equation can be simplified.
– jonk
Dec 27, 2020 at 19:41
• @jonk I didn't spend time for simplifications, if you want to, you are welcome to edit. Dec 27, 2020 at 19:49
• I do these all the time, so it's kind of built-in to my psyche. Since $\ln\left(A^B\right) = B\,\ln\left(A\right)$ it follows that $\exp\left(B\,\ln\left(A\right)\right)=A^B$. I was thinking along those lines. That's all.
– jonk
Dec 27, 2020 at 19:55
• Is there a particular reason that you are using a Taylor series? Truncating it will not give you a good polynomial approximation. If the OP wants a polynomial of degree $n$ to relate the measured voltage $V_2$ and the measured force it is better to just do a polynomial fit, which will reduce the error of the approximation.
– jDAQ
Dec 27, 2020 at 20:11
• @jDAQ Taylor was the first in my mind, since the function and its derivatives are known. What polynomial would fit in your opinion better than the function itself? Dec 27, 2020 at 20:23