Pages: [1]   Go Down
Author Topic: Oil temp sender. Can someone help me come up with a function for this plot?  (Read 1485 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 42
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 sender.jpg (97.77 KB, 971x500 - viewed 54 times.)
* Oil temp.ods (17.36 KB - downloaded 22 times.)
« Last Edit: August 15, 2011, 03:35:43 pm by Bebbetufs » Logged

0
Offline Offline
Shannon Member
****
Karma: 206
Posts: 12062
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

No plot attached...
Logged

[ I won't respond to messages, use the forum please ]

Dallas, Texas
Offline Offline
God Member
*****
Karma: 0
Posts: 861
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Dallas, Texas
Offline Offline
God Member
*****
Karma: 0
Posts: 861
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 (178.63 KB, 898x692 - viewed 95 times.)
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 216
Posts: 13664
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

This is a case for multiMap() - http://arduino.cc/playground/Main/MultiMap - maybe you need the floating point version at the end.

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

Code:
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 smiley-wink


Rob

« Last Edit: August 15, 2011, 06:11:06 pm by robtillaart » Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Dallas, Texas
Offline Offline
God Member
*****
Karma: 0
Posts: 861
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Dallas, Texas
Offline Offline
God Member
*****
Karma: 0
Posts: 861
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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


Code:
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.
Logged

Offline Offline
Full Member
***
Karma: 1
Posts: 200
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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).
Logged

Dallas, Texas
Offline Offline
God Member
*****
Karma: 0
Posts: 861
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Logged

Dubuque, Iowa, USA
Offline Offline
Faraday Member
**
Karma: 46
Posts: 2501
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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. smiley


Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 42
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley
Logged

Dallas, Texas
Offline Offline
God Member
*****
Karma: 0
Posts: 861
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley

Oops! Well, get to work on your oil temp project.  smiley
Logged

Pages: [1]   Go Up
Jump to: