From 7c94c83765e5db484f1543eed2ae884d05add50c Mon Sep 17 00:00:00 2001 From: Richard Wackerbarth Date: Wed, 16 Dec 2015 08:33:51 -0600 Subject: [PATCH] Repair formula mangled by PR#1319 in Jan 2015 --- Marlin/scripts/createTemperatureLookupMarlin.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Marlin/scripts/createTemperatureLookupMarlin.py b/Marlin/scripts/createTemperatureLookupMarlin.py index 4f54c2833..81747f7dd 100755 --- a/Marlin/scripts/createTemperatureLookupMarlin.py +++ b/Marlin/scripts/createTemperatureLookupMarlin.py @@ -1,7 +1,7 @@ #!/usr/bin/python """Thermistor Value Lookup Table Generator -Generates lookup to temperature values for use in a microcontroller in C format based on: +Generates lookup to temperature values for use in a microcontroller in C format based on: http://en.wikipedia.org/wiki/Steinhart-Hart_equation The main use is for Arduino programs that read data from the circuit board described here: @@ -45,7 +45,7 @@ class Thermistor: c = (y - x) / ((l3 - l2) * (l1 + l2 + l3)) b = x - c * (l1**2 + l2**2 + l1*l2) a = y1 - (b + l1**2 *c)*l1 - + if c < 0: print "//////////////////////////////////////////////////////////////////////////////////////" print "// WARNING: negative coefficient 'c'! Something may be wrong with the measurements! //" @@ -73,13 +73,13 @@ class Thermistor: def temp(self, adc): "Convert ADC reading into a temperature in Celcius" l = log(self.resist(adc)) - Tinv = self.c1 + self.c2*l + self.c3* l**3) # inverse temperature + Tinv = self.c1 + self.c2*l + self.c3* l**3 # inverse temperature return (1/Tinv) - ZERO # temperature def adc(self, temp): "Convert temperature into a ADC reading" x = (self.c1 - (1.0 / (temp+ZERO))) / (2*self.c3) - y = sqrt((self.c2 / (3*self.c3)**3 + x**2) + y = sqrt((self.c2 / (3*self.c3))**3 + x**2) r = exp((y-x)**(1.0/3) - (y+x)**(1.0/3)) return (r / (self.rp + r)) * ARES @@ -93,7 +93,7 @@ def main(argv): r3 = 226.15 # resistance at high temperature (226.15 Ohm) rp = 4700; # pull-up resistor (4.7 kOhm) num_temps = 36; # number of entries for look-up table - + try: opts, args = getopt.getopt(argv, "h", ["help", "rp=", "t1=", "t2=", "t3=", "num-temps="]) except getopt.GetoptError as err: