"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.
<img src="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=1880&stc=1&d=118535245 1">
Converting the formula excel came up with to this...You should get these resultsCode:TempC VAR WORD ADval VAR WORD TempC = ADval * 396 TempC = DIV32 1000 TempC = 67 - TempC LCDOUT "Temp C = ", SDEC TempC," "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.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
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,





Bookmarks