aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/heater.py
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2017-03-06 15:19:52 -0500
committerKevin O'Connor <kevin@koconnor.net>2017-03-13 00:44:53 -0400
commit4388a294a4151c8e0db6f08bc751763098bc3916 (patch)
treedc142a95ecc9e0b2d871a9dbee76b42a69ba4430 /klippy/heater.py
parentd21b9280f029f1c65d3dac9310eb00090dd8c531 (diff)
downloadkutter-4388a294a4151c8e0db6f08bc751763098bc3916.tar.gz
kutter-4388a294a4151c8e0db6f08bc751763098bc3916.tar.xz
kutter-4388a294a4151c8e0db6f08bc751763098bc3916.zip
heater: Handle case where min adc value is less than max adc value
When using a sensor that isn't a thermisistor, the maximum and minimum adc values may be swapped - handle that case. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/heater.py')
-rw-r--r--klippy/heater.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/klippy/heater.py b/klippy/heater.py
index d008ca54..d41055e2 100644
--- a/klippy/heater.py
+++ b/klippy/heater.py
@@ -10,7 +10,7 @@ Thermistors = {
"EPCOS 100K B57560G104F": (
0.000722136308968056, 0.000216766566488498, 8.92935804531095e-08),
"ATC Semitec 104GT-2": (
- 0.000809651054275124, 0.000211636030735685, 7.07420883993973e-08),
+ 0.000809651054275124, 0.000211636030735685, 7.07420883993973e-08),
}
SAMPLE_TIME = 0.001
@@ -52,10 +52,9 @@ class PrinterHeater:
self.mcu_pwm = printer.mcu.create_pwm(
heater_pin, PWM_CYCLE_TIME, 0, MAX_HEAT_TIME)
self.mcu_adc = printer.mcu.create_adc(thermistor_pin)
- min_adc = self.calc_adc(self.max_temp)
- max_adc = self.calc_adc(self.min_temp)
- self.mcu_adc.set_minmax(
- SAMPLE_TIME, SAMPLE_COUNT, minval=min_adc, maxval=max_adc)
+ adc_range = [self.calc_adc(self.min_temp), self.calc_adc(self.max_temp)]
+ self.mcu_adc.set_minmax(SAMPLE_TIME, SAMPLE_COUNT,
+ minval=min(adc_range), maxval=max(adc_range))
self.mcu_adc.set_adc_callback(REPORT_TIME, self.adc_callback)
self.control = algo(self, config)
# pwm caching