Prusa MINI Firmware overview
createTemperatureLookupMarlin.Thermistor Class Reference

Public Member Functions

def __init__ (self, rp, t1, r1, t2, r2, t3, r3)
 
def resol (self, adc)
 
def voltage (self, adc)
 
def resist (self, adc)
 
def temp (self, adc)
 
def adc (self, temp)
 

Public Attributes

 c1
 
 c2
 
 c3
 
 rp
 

Constructor & Destructor Documentation

◆ __init__()

def createTemperatureLookupMarlin.Thermistor.__init__ (   self,
  rp,
  t1,
  r1,
  t2,
  r2,
  t3,
  r3 
)
39  def __init__(self, rp, t1, r1, t2, r2, t3, r3):
40  l1 = log(r1)
41  l2 = log(r2)
42  l3 = log(r3)
43  y1 = 1.0 / (t1 + ZERO) # adjust scale
44  y2 = 1.0 / (t2 + ZERO)
45  y3 = 1.0 / (t3 + ZERO)
46  x = (y2 - y1) / (l2 - l1)
47  y = (y3 - y1) / (l3 - l1)
48  c = (y - x) / ((l3 - l2) * (l1 + l2 + l3))
49  b = x - c * (l1**2 + l2**2 + l1*l2)
50  a = y1 - (b + l1**2 *c)*l1
51 
52  if c < 0:
53  print("//////////////////////////////////////////////////////////////////////////////////////")
54  print("// WARNING: negative coefficient 'c'! Something may be wrong with the measurements! //")
55  print("//////////////////////////////////////////////////////////////////////////////////////")
56  c = -c
57  self.c1 = a # Steinhart-Hart coefficients
58  self.c2 = b
59  self.c3 = c
60  self.rp = rp # pull-up resistance
61 

Member Function Documentation

◆ resol()

def createTemperatureLookupMarlin.Thermistor.resol (   self,
  adc 
)
62  def resol(self, adc):
63  "Convert ADC reading into a resolution"
64  res = self.temp(adc)-self.temp(adc+1)
65  return res
66 
Here is the call graph for this function:

◆ voltage()

def createTemperatureLookupMarlin.Thermistor.voltage (   self,
  adc 
)
67  def voltage(self, adc):
68  "Convert ADC reading into a Voltage"
69  return adc * VSTEP # convert the 10 bit ADC value to a voltage
70 
Here is the caller graph for this function:

◆ resist()

def createTemperatureLookupMarlin.Thermistor.resist (   self,
  adc 
)
71  def resist(self, adc):
72  "Convert ADC reading into a resistance in Ohms"
73  r = self.rp * self.voltage(adc) / (VCC - self.voltage(adc)) # resistance of thermistor
74  return r
75 
Here is the call graph for this function:
Here is the caller graph for this function:

◆ temp()

def createTemperatureLookupMarlin.Thermistor.temp (   self,
  adc 
)
76  def temp(self, adc):
77  "Convert ADC reading into a temperature in Celcius"
78  l = log(self.resist(adc))
79  Tinv = self.c1 + self.c2*l + self.c3* l**3 # inverse temperature
80  return (1/Tinv) - ZERO # temperature
81 
Here is the call graph for this function:
Here is the caller graph for this function:

◆ adc()

def createTemperatureLookupMarlin.Thermistor.adc (   self,
  temp 
)
82  def adc(self, temp):
83  "Convert temperature into a ADC reading"
84  x = (self.c1 - (1.0 / (temp+ZERO))) / (2*self.c3)
85  y = sqrt((self.c2 / (3*self.c3))**3 + x**2)
86  r = exp((y-x)**(1.0/3) - (y+x)**(1.0/3))
87  return (r / (self.rp + r)) * ARES
88 

Member Data Documentation

◆ c1

createTemperatureLookupMarlin.Thermistor.c1

◆ c2

createTemperatureLookupMarlin.Thermistor.c2

◆ c3

createTemperatureLookupMarlin.Thermistor.c3

◆ rp

createTemperatureLookupMarlin.Thermistor.rp