Thermistors: Generating the SPLat code
| In January 2012 we introduced the Thermistor hash command, which generates the code. Let SPLat/PC do all the hard work for you! |
Coding the SPLat program to make the conversion is easy … we’ve done it for you. The following is the conversion code, with a particular set of polynomial coefficients. What we have done is copy the whole equation as a comment, removed spaces between +/- signs and the numbers, and then manually copied and pasted the coefficients into the code. One floating point location (4-bytes of storage) is required to hold the intermediate and final result.
;y = -1.124166E-10x5 +1.014140E-07x4 -3.985487E-05x3
; +8.462339E-03x2 -1.219136E+00x +1.133853E+02
;Come here with a raw analog input value in X
Float
fStore Temperature
fLoadQ -1.124166E-10 ;<< X^5 coefficient
fMul
fLoadQ +1.014140E-07 ;<< X^4 coefficient
fAdd
fRecallQ Temperature
fMul
fLoadQ -3.985487E-05 ;<< X^3 coefficient
fAdd
fRecallQ Temperature
fMul
fLoadQ +8.462339E-03 ;<< X^2 coefficient
fAdd
fRecallQ Temperature
fMul
fLoadQ -1.219136E+00 ;<< X^1 coefficient
fAdd
fRecallQ Temperature
fMul
fLoadQ +1.133853E+02 ;<< X^0 coefficient
fAdd
fStore Temperature ;Final result
The only other thing you need to do is to ensure that the Vfeed voltage is initialized, if you are using a programmed voltage. The spreadsheet gives you the value to output to the analog output port in the case of MMi99 or SL99 (the AnOut value in the pink cell). For OEM36 you would always put out 255.