Use of the Log Function to Calculate Temperature for an NTC Thermistor
' Program THERMIS_1.BAS
'
' Calculate the temperature of T_F at 25 equal intervals over the range of
' R_therm from 5.0K to 30.0K for a nominal 10K NTC thermistor.
'
' The primary intent of this routine was to experiment with the natural
' log function.
'
' This uses the classic two point thermistor model where;
'
' T_K = 1/(a + b*ln(R_therm))
'
' This will later be interfaced with an A/D converter so as to
' determine the thermistor's resistance and thus the temperature which
' may then be logged to the BasicX's EEPROM or an external 24LC256.
'
' Another technique for measuring the thermistor's resistance is the use
' of the RCtime command.
'
' copyright, Onya D. Barnes, Baltimore, MD, Sept, '99
Public Sub Main()
Const a as single = 0.000413200 ' thermistor constants
Const b as single = 0.000320135
Dim R_therm as single
Dim n as integer
Dim T_K as single
Dim T_C as single
Dim T_F as single
Call OpenSerialPort(2, 9600)
For n=0 to 25 ' Note the necessity to cast n as a float
R_Therm=5000.0 + 25000.0*(Csng(n)/25.0) ' generate an R_therm
T_K=1.0/(a+b*log(R_therm)) ' degrees Kelvin
' Call PutS(T_K) ' display the value - for debugging
' Call Putbyte(32)
T_C=T_K - 273.15 ' calculate degrees C
T_F=1.8*T_C + 32.0 ' degrees C
Call PutS(R_Therm) ' display R_therm and T_F
Call Putbyte(32)
Call PutS(T_F)
Call Newline()
Next
End Sub