Quote Originally Posted by Darrel Taylor View Post
"Almost" is a relative term, and I guess it depends on how much "Almost" your application can tolerate.

From this excel graph you can see there's quite a bit of "curve" to it. But it may not be that bad.

Converting the formula excel came up with to this...
Code:
TempC  VAR WORD
ADval  VAR WORD

TempC  = ADval * 396
TempC  = DIV32 1000
TempC  = 67 - TempC  

LCDOUT "Temp C = ", SDEC TempC,"  "
You should get these results
Code:
       8-bit
Volts	A/D	Temp	PIC reads
-----	---	-----	---------
3.45	175	0	-2
2.84	144	10	10
2.3	117	20	21
1.81	92	30	31
1.36	69	40	40
1.02	52	49	47
It's off by 2 degrees at the top and bottom of the scale, 1 degree in the middle, and is very close in the areas of 10 and 40 deg.

If that's not within the "Almost" for your program, then Sayzer's idea of a Stepped Linear Interpolation using Select or Lookup/down, will get you closer.

HTH,
It is not necessary in my application a 'perfect' result OF temperature. As the excel show, it is ''almost'' linear and it is a good solution. Maybe it will be necessary to get a 'perfect result' measuring another signal in this application and I think that this signal is not 'almost' linear. Then I will try the lookup/down....Thanks Sayzer by helping.

Darrel, thanks for the attention and solution. The result is very satisfatory and I will use it.

Now, I got another doubt. What would be the difference if you change the TempC = DIV32 1000 for this: TempC = TempC / 1000 ?

Thank you very much..!

Regards

Sylvio