Steffen Vogel 10 lat temu
rodzic
commit
81363bc441
1 zmienionych plików z 15 dodań i 15 usunięć
  1. 15
    15
      Marlin/scripts/createTemperatureLookupMarlin.py

+ 15
- 15
Marlin/scripts/createTemperatureLookupMarlin.py Wyświetl plik

12
 Options:
12
 Options:
13
   -h, --help        show this help
13
   -h, --help        show this help
14
   --rp=...          pull-up resistor
14
   --rp=...          pull-up resistor
15
-  --t1=ttt:rrr      low temperature temperature:resistance point (around 25C)
16
-  --t2=ttt:rrr      middle temperature temperature:resistance point (around 150C)
17
-  --t3=ttt:rrr      high temperature temperature:resistance point (around 250C)
15
+  --t1=ttt:rrr      low temperature temperature:resistance point (around 25 degC)
16
+  --t2=ttt:rrr      middle temperature temperature:resistance point (around 150 degC)
17
+  --t3=ttt:rrr      high temperature temperature:resistance point (around 250 degC)
18
   --num-temps=...   the number of temperature points to calculate (default: 36)
18
   --num-temps=...   the number of temperature points to calculate (default: 36)
19
 """
19
 """
20
 
20
 
50
         self.c3 = c
50
         self.c3 = c
51
         self.rp = rp                        # pull-up resistance
51
         self.rp = rp                        # pull-up resistance
52
 
52
 
53
-    def res(self, adc):
53
+    def resol(self, adc):
54
         "Convert ADC reading into a resolution"
54
         "Convert ADC reading into a resolution"
55
         res = self.temp(adc)-self.temp(adc+1)
55
         res = self.temp(adc)-self.temp(adc+1)
56
         return res
56
         return res
57
 
57
 
58
-    def v(self, adc):
58
+    def voltage(self, adc):
59
         "Convert ADC reading into a Voltage"
59
         "Convert ADC reading into a Voltage"
60
         return adc * VSTEP                     # convert the 10 bit ADC value to a voltage
60
         return adc * VSTEP                     # convert the 10 bit ADC value to a voltage
61
 
61
 
62
-    def r(self, adc):
62
+    def resist(self, adc):
63
         "Convert ADC reading into a resistance in Ohms"
63
         "Convert ADC reading into a resistance in Ohms"
64
-        r = self.rp * self.v(adc) / (VCC - self.v(adc)) # resistance of thermistor
64
+        r = self.rp * self.voltage(adc) / (VCC - self.voltage(adc)) # resistance of thermistor
65
         return r
65
         return r
66
 
66
 
67
     def temp(self, adc):
67
     def temp(self, adc):
68
         "Convert ADC reading into a temperature in Celcius"
68
         "Convert ADC reading into a temperature in Celcius"
69
-        r = self.rp * self.v(adc) / (VCC - self.v(adc)) # resistance of thermistor
70
-        lnr = log(r)
71
-        Tinv = self.c1 + (self.c2*lnr) + (self.c3*pow(lnr,3))
69
+        l = log(self.resist(adc))
70
+        Tinv = self.c1 + self.c2*l + self.c3*pow(l,3) # inverse temperature
72
         return (1/Tinv) - ZERO              # temperature
71
         return (1/Tinv) - ZERO              # temperature
73
 
72
 
74
     def adc(self, temp):
73
     def adc(self, temp):
87
     t3 = 250                                # high temperature in Kelvin (250 degC)
86
     t3 = 250                                # high temperature in Kelvin (250 degC)
88
     r3 = 226.15                             # resistance at high temperature (226.15 Ohm)
87
     r3 = 226.15                             # resistance at high temperature (226.15 Ohm)
89
     rp = 4700;                              # pull-up resistor (4.7 kOhm)
88
     rp = 4700;                              # pull-up resistor (4.7 kOhm)
90
-    num_temps = int(36);                    # number of entries for look-up table
89
+    num_temps = 36;                         # number of entries for look-up table
91
     
90
     
92
     try:
91
     try:
93
         opts, args = getopt.getopt(argv, "h", ["help", "rp=", "t1=", "t2=", "t3=", "num-temps="])
92
         opts, args = getopt.getopt(argv, "h", ["help", "rp=", "t1=", "t2=", "t3=", "num-temps="])
130
     print "const short temptable[NUMTEMPS][2] PROGMEM = {"
129
     print "const short temptable[NUMTEMPS][2] PROGMEM = {"
131
 
130
 
132
     for temp in temps:
131
     for temp in temps:
133
-        print "    { (short) (%7.2f * OVERSAMPLENR ), %s\t}%s // v=%.3f\tr=%.3f\tres=%.3f degC/count" % ( t.adc(temp), temp, \
132
+        adc = t.adc(temp)
133
+        print "    { (short) (%7.2f * OVERSAMPLENR ), %4s }%s // v=%.3f\tr=%.3f\tres=%.3f degC/count" % (adc , temp, \
134
                         ',' if temp != temps[-1] else ' ', \
134
                         ',' if temp != temps[-1] else ' ', \
135
-                        t.v(  t.adc(temp)), \
136
-                        t.r(  t.adc(temp)), \
137
-                        t.res(t.adc(temp)) \
135
+                        t.voltage(adc), \
136
+                        t.resist( adc), \
137
+                        t.resol(  adc) \
138
                     )
138
                     )
139
     print "};"
139
     print "};"
140
 
140
 

Ładowanie…
Anuluj
Zapisz