Pārlūkot izejas kodu

Repair formula mangled by PR#1319 in Jan 2015

Richard Wackerbarth 9 gadus atpakaļ
vecāks
revīzija
7c94c83765
1 mainītis faili ar 5 papildinājumiem un 5 dzēšanām
  1. 5
    5
      Marlin/scripts/createTemperatureLookupMarlin.py

+ 5
- 5
Marlin/scripts/createTemperatureLookupMarlin.py Parādīt failu

1
 #!/usr/bin/python
1
 #!/usr/bin/python
2
 """Thermistor Value Lookup Table Generator
2
 """Thermistor Value Lookup Table Generator
3
 
3
 
4
-Generates lookup to temperature values for use in a microcontroller in C format based on: 
4
+Generates lookup to temperature values for use in a microcontroller in C format based on:
5
 http://en.wikipedia.org/wiki/Steinhart-Hart_equation
5
 http://en.wikipedia.org/wiki/Steinhart-Hart_equation
6
 
6
 
7
 The main use is for Arduino programs that read data from the circuit board described here:
7
 The main use is for Arduino programs that read data from the circuit board described here:
45
         c = (y - x) / ((l3 - l2) * (l1 + l2 + l3))
45
         c = (y - x) / ((l3 - l2) * (l1 + l2 + l3))
46
         b = x - c * (l1**2 + l2**2 + l1*l2)
46
         b = x - c * (l1**2 + l2**2 + l1*l2)
47
         a = y1 - (b + l1**2 *c)*l1
47
         a = y1 - (b + l1**2 *c)*l1
48
-        
48
+
49
         if c < 0:
49
         if c < 0:
50
             print "//////////////////////////////////////////////////////////////////////////////////////"
50
             print "//////////////////////////////////////////////////////////////////////////////////////"
51
             print "// WARNING: negative coefficient 'c'! Something may be wrong with the measurements! //"
51
             print "// WARNING: negative coefficient 'c'! Something may be wrong with the measurements! //"
73
     def temp(self, adc):
73
     def temp(self, adc):
74
         "Convert ADC reading into a temperature in Celcius"
74
         "Convert ADC reading into a temperature in Celcius"
75
         l = log(self.resist(adc))
75
         l = log(self.resist(adc))
76
-        Tinv = self.c1 + self.c2*l + self.c3* l**3) # inverse temperature
76
+        Tinv = self.c1 + self.c2*l + self.c3* l**3 # inverse temperature
77
         return (1/Tinv) - ZERO              # temperature
77
         return (1/Tinv) - ZERO              # temperature
78
 
78
 
79
     def adc(self, temp):
79
     def adc(self, temp):
80
         "Convert temperature into a ADC reading"
80
         "Convert temperature into a ADC reading"
81
         x = (self.c1 - (1.0 / (temp+ZERO))) / (2*self.c3)
81
         x = (self.c1 - (1.0 / (temp+ZERO))) / (2*self.c3)
82
-        y = sqrt((self.c2 / (3*self.c3)**3 + x**2)
82
+        y = sqrt((self.c2 / (3*self.c3))**3 + x**2)
83
         r = exp((y-x)**(1.0/3) - (y+x)**(1.0/3))
83
         r = exp((y-x)**(1.0/3) - (y+x)**(1.0/3))
84
         return (r / (self.rp + r)) * ARES
84
         return (r / (self.rp + r)) * ARES
85
 
85
 
93
     r3 = 226.15                             # resistance at high temperature (226.15 Ohm)
93
     r3 = 226.15                             # resistance at high temperature (226.15 Ohm)
94
     rp = 4700;                              # pull-up resistor (4.7 kOhm)
94
     rp = 4700;                              # pull-up resistor (4.7 kOhm)
95
     num_temps = 36;                         # number of entries for look-up table
95
     num_temps = 36;                         # number of entries for look-up table
96
-    
96
+
97
     try:
97
     try:
98
         opts, args = getopt.getopt(argv, "h", ["help", "rp=", "t1=", "t2=", "t3=", "num-temps="])
98
         opts, args = getopt.getopt(argv, "h", ["help", "rp=", "t1=", "t2=", "t3=", "num-temps="])
99
     except getopt.GetoptError as err:
99
     except getopt.GetoptError as err:

Notiek ielāde…
Atcelt
Saglabāt