Oil temp sender. Can someone help me come up with a function for this plot?

I just discovered I’m worse at maths than I thought. I’ve been wrestling with this for a few hours, but I simply don’t have the skills or time to learn right now.
The plot is for the oil temp sender on my car. I’m going to the track on Sunday and I need to have this up and running by then.

If someone can help me convert these values into volt and then come up with an efficient function which can be used to display oil temp on my LCD I will be extremely grateful. The sensor will be fed 5v from the Arduino board.

Oil temp.ods (17.4 KB)

No plot attached...

You won't be able to power it directly from 5V, you will need a series resistor to divide the voltage across. If you select a resistor, you can re-plot your curve as voltage and if you have Excel, you can fit a curve to the data quite nicely. Then, you just apply the coefficients that Excel gives you to convert the voltage to temperature in your sketch.

For example, with a 500 Ohm series resistor and a 5V supply, you get the values in the attached plot.

You calculate the voltage for each step:

(5V * Rsensor) / (500 Ohms + Rsensor)

If you can’t get a polynomial curve fit from Excel you can just build an array of the calculated values and interpolate between them.

V vs T.tiff (179 KB)

Hi,

This is a case for multiMap() - Arduino Playground - HomePage - maybe you need the floating point version at the end.

Give it a try. (note the in array must be increasing)

int out[] = { 150,145,140,135,130,125,120,115,110,105,100,95,90,85,80,75,70,65,60,55,50,45,40,35 } // 24
int in[] = { 34, 39, 45, 51, 58, 65, 74, 85, 98,112,130,150,172,203,234,275,328,388,463,553,670,788,963,1177}
val = someMeasurement();
Volts = multiMap(val, in, out, 24);

The integer version keeps the code fast :wink:

Rob

Oh, cool! I didn't realize there was a float version. That's exactly what OP needs.

Give it a try. (note the in array must be increasing)

int out[] = { 150,145,140,135,130,125,120,115,110,105,100,95,90,85,80,75,70,65,60,55,50,45,40,35 } // 24
int in[] = { 34, 39, 45, 51, 58, 65, 74, 85, 98,112,130,150,172,203,234,275,328,388,463,553,670,788,963,1177}
val = someMeasurement();
Volts = multiMap(val, in, out, 24);

In that case OP will have to solve for resistance knowing voltage.

Bebbetufs,

if you do use multiMap, please give some feedback of your experience. It looks like a useful function (though I have not used it yet).

I've been playing around with the numbers and if you use a 100 Ohm series resistor you can use a straight line fit and your error is +/-5% from 45 C to 150 C and
+/-1.5% in the range from 90 C to 150C. That might be close enough and would really simplify the calculations.

T = V * (-32.27) + 190.42

Just FYI, OpenOffice will calculate the function for trend lines for you. Excel would refer to this as regression analysis (google = your friend).

  1. Doubleclick the graph to enter the edit mode
  2. Select "Insert" from the menu and then "Trend lines".

You'll figure it out from there. :slight_smile:

Thank you for all your answers.
I have not had time to look into this as I have been busy blowing the turbo of my car. I have plenty of time now :slight_smile:

Bebbetufs:
Thank you for all your answers.
I have not had time to look into this as I have been busy blowing the turbo of my car. I have plenty of time now :slight_smile:

Oops! Well, get to work on your oil temp project. :slight_smile: