|
@@ -18,6 +18,9 @@ Options:
|
18
|
18
|
--num-temps=... the number of temperature points to calculate (default: 36)
|
19
|
19
|
"""
|
20
|
20
|
|
|
21
|
+from __future__ import print_function
|
|
22
|
+from __future__ import division
|
|
23
|
+
|
21
|
24
|
from math import *
|
22
|
25
|
import sys
|
23
|
26
|
import getopt
|
|
@@ -47,9 +50,9 @@ class Thermistor:
|
47
|
50
|
a = y1 - (b + l1**2 *c)*l1
|
48
|
51
|
|
49
|
52
|
if c < 0:
|
50
|
|
- print "//////////////////////////////////////////////////////////////////////////////////////"
|
51
|
|
- print "// WARNING: negative coefficient 'c'! Something may be wrong with the measurements! //"
|
52
|
|
- print "//////////////////////////////////////////////////////////////////////////////////////"
|
|
53
|
+ print("//////////////////////////////////////////////////////////////////////////////////////")
|
|
54
|
+ print("// WARNING: negative coefficient 'c'! Something may be wrong with the measurements! //")
|
|
55
|
+ print("//////////////////////////////////////////////////////////////////////////////////////")
|
53
|
56
|
c = -c
|
54
|
57
|
self.c1 = a # Steinhart-Hart coefficients
|
55
|
58
|
self.c2 = b
|
|
@@ -97,7 +100,7 @@ def main(argv):
|
97
|
100
|
try:
|
98
|
101
|
opts, args = getopt.getopt(argv, "h", ["help", "rp=", "t1=", "t2=", "t3=", "num-temps="])
|
99
|
102
|
except getopt.GetoptError as err:
|
100
|
|
- print str(err)
|
|
103
|
+ print(str(err))
|
101
|
104
|
usage()
|
102
|
105
|
sys.exit(2)
|
103
|
106
|
|
|
@@ -129,27 +132,27 @@ def main(argv):
|
129
|
132
|
up_bound = t.temp(1);
|
130
|
133
|
min_temp = int(TMIN if TMIN > low_bound else low_bound)
|
131
|
134
|
max_temp = int(TMAX if TMAX < up_bound else up_bound)
|
132
|
|
- temps = range(max_temp, TMIN+step, step);
|
|
135
|
+ temps = list(range(max_temp, TMIN+step, step));
|
133
|
136
|
|
134
|
|
- print "// Thermistor lookup table for Marlin"
|
135
|
|
- print "// ./createTemperatureLookupMarlin.py --rp=%s --t1=%s:%s --t2=%s:%s --t3=%s:%s --num-temps=%s" % (rp, t1, r1, t2, r2, t3, r3, num_temps)
|
136
|
|
- print "// Steinhart-Hart Coefficients: a=%.15g, b=%.15g, c=%.15g " % (t.c1, t.c2, t.c3)
|
137
|
|
- print "// Theoretical limits of thermistor: %.2f to %.2f degC" % (low_bound, up_bound)
|
138
|
|
- print
|
139
|
|
- print "const short temptable[][2] PROGMEM = {"
|
|
137
|
+ print("// Thermistor lookup table for Marlin")
|
|
138
|
+ print("// ./createTemperatureLookupMarlin.py --rp=%s --t1=%s:%s --t2=%s:%s --t3=%s:%s --num-temps=%s" % (rp, t1, r1, t2, r2, t3, r3, num_temps))
|
|
139
|
+ print("// Steinhart-Hart Coefficients: a=%.15g, b=%.15g, c=%.15g " % (t.c1, t.c2, t.c3))
|
|
140
|
+ print("// Theoretical limits of thermistor: %.2f to %.2f degC" % (low_bound, up_bound))
|
|
141
|
+ print()
|
|
142
|
+ print("const short temptable[][2] PROGMEM = {")
|
140
|
143
|
|
141
|
144
|
for temp in temps:
|
142
|
145
|
adc = t.adc(temp)
|
143
|
|
- print " { OV(%7.2f), %4s }%s // v=%.3f\tr=%.3f\tres=%.3f degC/count" % (adc , temp, \
|
|
146
|
+ print(" { OV(%7.2f), %4s }%s // v=%.3f\tr=%.3f\tres=%.3f degC/count" % (adc , temp, \
|
144
|
147
|
',' if temp != temps[-1] else ' ', \
|
145
|
148
|
t.voltage(adc), \
|
146
|
149
|
t.resist( adc), \
|
147
|
150
|
t.resol( adc) \
|
148
|
|
- )
|
149
|
|
- print "};"
|
|
151
|
+ ))
|
|
152
|
+ print("};")
|
150
|
153
|
|
151
|
154
|
def usage():
|
152
|
|
- print __doc__
|
|
155
|
+ print(__doc__)
|
153
|
156
|
|
154
|
157
|
if __name__ == "__main__":
|
155
|
158
|
main(sys.argv[1:])
|