PDA

View Full Version : Math Problem



erice1984
- 21st April 2009, 20:57
I need to figure out how to convert the non-linear AD Value to something more linear as far as the conversion goes.

I figured out by reading a little on NTC thermistors, with the little data I have, I came up with resistance values that I believe are accurate within 1ohm

Anyways, here is a link to the spreadsheet
www.drivearu.com/Electronics/ntc%20thermistor.xls

I am stumped!

erice1984
- 21st April 2009, 20:59
Ah, forgot that it needs to be the temperature range 100-250 degrees F

When o I get the ability to edit my posts?

rsocor01
- 21st April 2009, 23:05
Erice1984,

You can do a linear approximation but you are going to loose accuracy. Try doing a polynomial or exponential approximation. In EXCEL go to help and see how to add a trendline (it varies with the different versions of EXCEL). Obtaining the trendline is very simple. The trendline is going to give you a formula in the form of Y(X), X being the temperature and Y being the Resistance. Try with different options and settings until you get a good approximation. Then, you can use the resulting formula in your PBP program. That is with any value X (temperature) you can calculate a value Y (resistance).

You should get the whole temperature range 100-250 degrees F in your graph before doing an approximation, so you get better results.

This is one way to do it, which is very accurate. It all depends on the accuracy that you want for the resistance reading.

Hope that this helps.

Robert

erice1984
- 21st April 2009, 23:47
Thank you very much!

Wow, that was really easy!

I lost accuracy but its in the place I don't care about!

mister_e
- 21st April 2009, 23:49
I already used the following with good results.

Curve Expert
http://userpages.xfoneusa.net/~dhyams/cmain.htm

erice1984
- 22nd April 2009, 00:45
It all works, just wondering how I will try to make exponents happen..

mister_e
- 22nd April 2009, 01:37
What's your current formula?

A third degree polynomial didn't fit?

erice1984
- 22nd April 2009, 04:27
f(x) = 5167.68(0.98^x)

mister_e
- 22nd April 2009, 04:47
could be more simple than you think
http://en.wikipedia.org/wiki/Exponentiation

mister_e
- 22nd April 2009, 04:49
Nope, bad link...

erice1984
- 22nd April 2009, 05:13
well, I changed it up and am using three diff power curves to keep everything within 1 degree +/-

only thing that is trouble is negative exponents.. tryin to figure out how to simplify it out so pbp can do it, but im am sucking on figuring this out. lol

mister_e
- 22nd April 2009, 05:15
You could still build a lookup table and use some interpolation between some points, that should do the trick and way easy to implement.

Acetronics2
- 22nd April 2009, 12:59
Hi, Folks

I knew something REALLY simple was available ... but Where ???

http://www1.produktinfo.conrad.com/datenblaetter/500000-524999/500622-da-01-en-Heissleiter_B57164_K164_10K_5Prozent.pdf

In the Application notes section ( You must scroll down ... the left side menu doesn't work !!! )

Alain

erice1984
- 22nd April 2009, 14:27
Wow, you mention that and I look at the gauge that the sender was supposed to work with and they did that!

erice1984
- 22nd April 2009, 14:35
So I looked at the resistor that was used, its 510

It brings the change in resistance per degree down to
3 ohm from 100-150
2 ohm from 151-200
1 ohm from 201-250

Isnt that crazy.

erice1984
- 22nd April 2009, 18:24
I am going to use an op amp to get me full range of my 0-5v scale instead of this 0-1v stuff... would that limit the signal from "bouncing" around?

mister_e
- 22nd April 2009, 18:30
You could filter your signal in hardware, or in software (averaging results). I tend to use hardware in many case as it's just a matter to add a capacitor or any kind of Low-Pass filter. On the other hand, a combination of both is also good depending how fancy you want it.

erice1984
- 22nd April 2009, 19:40
interesting, I have heard about the capacitor trick. How would it be done "averaging" in software?

rsocor01
- 23rd April 2009, 01:25
Erice1984,
Looking at the EXCEL graph that you have posted it seems like a second degree polinomial will fit nicely. A formula of the form Y(X)=a*(X^2) + b will work. The EXCEL trendline will give a value for a and b in the above formula. Then, round this numbers up and you should have a good approximation for your graph. I am writing this reply from my cell phone so I don't have EXCEL with me at this moment to show you what it might look like.
Give it a try. If you have any problems, let us know.

Robert

Darrel Taylor
- 23rd April 2009, 02:55
How would it be done "averaging" in software?

Here's one possible way.
http://www.picbasic.co.uk/forum/showthread.php?p=13267#post13267

Although I never did hear back from ANYONE.
I have used it myself since that post.
No problems found.

It's based on my original Averaging routines ...

Averaging 16 bit values without using 32 bit math?
http://www.pbpgroup.com/modules/wfsection/article.php?articleid=7

HTH,

erice1984
- 23rd April 2009, 03:45
I updated the spreadsheet, feel free to take a look

www.drivearu.com/Electronics/ntc%20thermistor.xls

I am pretty confidant in this one, no exponents which is nice, and I looked at other automotive temperature gauges and they are showing +/- 7 degrees on theirs.