A
A P P E N D I X
Determining the Steinhart-Hart Constants
STNHRT1b.BAS is a simple program for calculating the Steinhart-Hart constants.
5'
10 CLS
20 '
30 'Program is in GWBASIC 3.2 for IBM or compatible computers.
40 'Enter the data in the form: T1, R1, T2, R2, T3, R3
50 'where T, R are the measured temp. and resistance pairs.
60 'T is in degrees C, and R in ohms.
70 '
80 INPUT "T1, R1, T2, R2, T3, R3"; T1, R1, T2, R2, T3, R3
90 '
100 K = 273.15
110 T1=T1+K : T2=T2+K : T3=T3+K
120 A1=LOG (R1) : A2=LOG (R2) : A3=LOG (R3)
130 '
140 Z=A1-A2 : Y=A1-A3
150 X=1/T1-1/T2 : W=1/T1-1/T3
160 V=A1^3-A2^3 : U=A1^3-A3^3
170 '
180 'For simplicity, intermediate steps have been omitted.
190 '
200 C3=(X-Z*W/Y)/(V-Z*U/Y)
210 C2=(X-C3*V)/Z
220 C1=1/T1-C3*A1^3-C2*A1
230 '
240 PRINT "C1 = "; C1
250 PRINT "C2 = "; C2
260 PRINT "C3 = "; C3
270 PRINT
280 PRINT "If any of the values are negative, there was an error. Check"
290 PRINT "data and rerun the program."
300 END
Once the constants, C1, C2, and C3 have been determined (using this program or other means),
temperature can be calculated from resistance, or resistance calculated from temperature using the
RandT.BAS program below.
For more information on using the S-H equation, refer to ILX Lightwave Application Note #4.
Using the S-H Equation to Find Resistance or Temperature
20
LDT-5412
****************** STNHRT1b.BAS **************
'conversion factor for Kelvin
'convert to absolute temp.
'simplify variables
'combine elements of the equations to
'form 2 equations with 2 unknowns
'solve 1 unknown by substitution
'use C3 to solve for C2
'use C3 and C2 to solve for C1
'input data