PDA

View Full Version : Is there a more efficient way?



markedwards
- 22nd July 2005, 21:22
I know this is a brute force way to linearize a thermistor connected to an analog input. Is there a more efficient way? I only need about 30F range.

Thanks!

if AD0 >= 446 then RA = 67
if AD0 >= 450 then RA = 68
if AD0 >= 456 then RA = 69
if AD0 >= 461 then RA = 70
if AD0 >= 477 then RA = 71
if AD0 >= 473 then RA = 72
if AD0 >= 479 then RA = 73
if AD0 >= 486 then RA = 74
if AD0 >= 492 then RA = 75
if AD0 >= 499 then RA = 76
if AD0 >= 506 then RA = 77
if AD0 >= 513 then RA = 78
if AD0 >= 519 then RA = 79
if AD0 >= 526 then RA = 80
if AD0 >= 529 then RA = 81
if AD0 >= 535 then RA = 82
if AD0 >= 544 then RA = 83
if AD0 >= 548 then RA = 84
if AD0 >= 552 then RA = 85
if AD0 <= 438 then RA = 65

mister_e
- 23rd July 2005, 09:56
the use of LOOKUP, READ will be easier and faster... some home work to do but ... just an idea :)

Acetronics2
- 23rd July 2005, 10:07
Hi, Mark edwards

Considering the thermistor's value tolerance ( generally +/- 20%, 10% in the best cases ) , plus it's precision, linearity, and repeatability ...

on that a small range , a simple y = ax + b linéarisation will give a widely credible result !!!

Alain

Melanie
- 23rd July 2005, 10:13
I disagree. Banks of IF statements are real ugly and there are more elegant ways of doing the same thing, but those heaps of IF statements invariably outperform the more elegant solutions.

There is room for improvement, not in performance as in speed per se, but in resolution. You could almost interpolate steps of about a quarter of a degree (or better)... look...

if AD0 >= 446 then RA = 67
if AD0 >= 450 then RA = 68

You've got about four clicks or more...

if AD0 >= 535 then RA = 82
if AD0 >= 544 then RA = 83

between adjacent degrees... you have enough data to increase your resolution to beyond 1F. No, not with banks of IF statements this time, you need to be a little more creative with the math. If you can't figure it, come back and I'll show you how.

Acetronics2
- 23rd July 2005, 10:25
Hi, Mel

I Agree for the ( basic ...) maths.

As no sensor calibration is evoked ... the result could be, i.e.

70°F +/- 10°F ... ( remember the thermistor nominal value tolerance !!! )

what is the sense of the 1/4°F here ...

Ah, Yesssss, I see ... a smart looking gadget !!!

Not so easy, the precise measurements .... don't you think???

Alain

Melanie
- 23rd July 2005, 11:39
As long as it looks good and appears to function...

More than half the stuff you see for sale is total rubbish... however the secret of success is being fastest to market with your particular piece of land-fill...

mister_e
- 25th July 2005, 23:25
And now i agree :)

Many people think that because it's electronic it's more accurate ... well sometime !!!

NavMicroSystems
- 25th July 2005, 23:38
...Many people think that because it's electronic it's more accurate ...

...and the more decimals there are on the display the better it is...