Skip to content
Snippets Groups Projects
Commit 7c94c837 authored by Richard Wackerbarth's avatar Richard Wackerbarth
Browse files

Repair formula mangled by PR#1319 in Jan 2015

parent 29326026
No related branches found
No related tags found
No related merge requests found
...@@ -73,13 +73,13 @@ class Thermistor: ...@@ -73,13 +73,13 @@ class Thermistor:
def temp(self, adc): def temp(self, adc):
"Convert ADC reading into a temperature in Celcius" "Convert ADC reading into a temperature in Celcius"
l = log(self.resist(adc)) 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 return (1/Tinv) - ZERO # temperature
def adc(self, temp): def adc(self, temp):
"Convert temperature into a ADC reading" "Convert temperature into a ADC reading"
x = (self.c1 - (1.0 / (temp+ZERO))) / (2*self.c3) 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)) r = exp((y-x)**(1.0/3) - (y+x)**(1.0/3))
return (r / (self.rp + r)) * ARES return (r / (self.rp + r)) * ARES
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment