Prusa MINI Firmware overview
createTemperatureLookupMarlin Namespace Reference

Classes

class  Thermistor
 

Functions

def main (argv)
 
def usage ()
 

Variables

float ZERO = 273.15
 
int VADC = 5
 
int VCC = 5
 
 ARES = pow(2,10)
 
int VSTEP = VADC / ARES
 
int TMIN = 0
 
int TMAX = 350
 

Detailed Description

Thermistor Value Lookup Table Generator

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:
http://reprap.org/wiki/Temperature_Sensor_v2.0

Usage: python createTemperatureLookupMarlin.py [options]

Options:
  -h, --help        show this help
  --rp=...          pull-up resistor
  --t1=ttt:rrr      low temperature temperature:resistance point (around 25 degC)
  --t2=ttt:rrr      middle temperature temperature:resistance point (around 150 degC)
  --t3=ttt:rrr      high temperature temperature:resistance point (around 250 degC)
  --num-temps=...   the number of temperature points to calculate (default: 36)

Function Documentation

◆ main()

def createTemperatureLookupMarlin.main (   argv)
89 def main(argv):
90  "Default values"
91  t1 = 25 # low temperature in Kelvin (25 degC)
92  r1 = 100000 # resistance at low temperature (10 kOhm)
93  t2 = 150 # middle temperature in Kelvin (150 degC)
94  r2 = 1641.9 # resistance at middle temperature (1.6 KOhm)
95  t3 = 250 # high temperature in Kelvin (250 degC)
96  r3 = 226.15 # resistance at high temperature (226.15 Ohm)
97  rp = 4700; # pull-up resistor (4.7 kOhm)
98  num_temps = 36; # number of entries for look-up table
99 
100  try:
101  opts, args = getopt.getopt(argv, "h", ["help", "rp=", "t1=", "t2=", "t3=", "num-temps="])
102  except getopt.GetoptError as err:
103  print(str(err))
104  usage()
105  sys.exit(2)
106 
107  for opt, arg in opts:
108  if opt in ("-h", "--help"):
109  usage()
110  sys.exit()
111  elif opt == "--rp":
112  rp = int(arg)
113  elif opt == "--t1":
114  arg = arg.split(':')
115  t1 = float(arg[0])
116  r1 = float(arg[1])
117  elif opt == "--t2":
118  arg = arg.split(':')
119  t2 = float(arg[0])
120  r2 = float(arg[1])
121  elif opt == "--t3":
122  arg = arg.split(':')
123  t3 = float(arg[0])
124  r3 = float(arg[1])
125  elif opt == "--num-temps":
126  num_temps = int(arg)
127 
128  t = Thermistor(rp, t1, r1, t2, r2, t3, r3)
129  increment = int((ARES-1)/(num_temps-1));
130  step = (TMIN-TMAX) / (num_temps-1)
131  low_bound = t.temp(ARES-1);
132  up_bound = t.temp(1);
133  min_temp = int(TMIN if TMIN > low_bound else low_bound)
134  max_temp = int(TMAX if TMAX < up_bound else up_bound)
135  temps = list(range(max_temp, TMIN+step, step));
136 
137  print("// Thermistor lookup table for Marlin")
138  print("// ./createTemperatureLookupMarlin.py --rp=%s --t1=%s:%s --t2=%s:%s --t3=%s:%s --num-temps=%s" % (rp, t1, r1, t2, r2, t3, r3, num_temps))
139  print("// Steinhart-Hart Coefficients: a=%.15g, b=%.15g, c=%.15g " % (t.c1, t.c2, t.c3))
140  print("// Theoretical limits of thermistor: %.2f to %.2f degC" % (low_bound, up_bound))
141  print()
142  print("const short temptable[][2] PROGMEM = {")
143 
144  for temp in temps:
145  adc = t.adc(temp)
146  print(" { OV(%7.2f), %4s }%s // v=%.3f\tr=%.3f\tres=%.3f degC/count" % (adc , temp, \
147  ',' if temp != temps[-1] else ' ', \
148  t.voltage(adc), \
149  t.resist( adc), \
150  t.resol( adc) \
151  ))
152  print("};")
153 
Here is the call graph for this function:
Here is the caller graph for this function:

◆ usage()

def createTemperatureLookupMarlin.usage ( )
154 def usage():
155  print(__doc__)
156 
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ ZERO

float createTemperatureLookupMarlin.ZERO = 273.15

◆ VADC

int createTemperatureLookupMarlin.VADC = 5

◆ VCC

int createTemperatureLookupMarlin.VCC = 5

◆ ARES

createTemperatureLookupMarlin.ARES = pow(2,10)

◆ VSTEP

int createTemperatureLookupMarlin.VSTEP = VADC / ARES

◆ TMIN

int createTemperatureLookupMarlin.TMIN = 0

◆ TMAX

int createTemperatureLookupMarlin.TMAX = 350
createTemperatureLookupMarlin.usage
def usage()
Definition: createTemperatureLookupMarlin.py:154
main
int main(void)
The application entry point.
Definition: main.c:161
createSpeedLookupTable.int
int
Definition: createSpeedLookupTable.py:15