aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/extras/adc_temperature.py
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2018-07-02 13:47:22 -0400
committerKevin O'Connor <kevin@koconnor.net>2018-07-02 13:56:34 -0400
commit0dbfa915de5495662102d17c7a11cea219354b91 (patch)
tree902109825fd2653ca7bd98a259e421522a69280c /klippy/extras/adc_temperature.py
parent5b3444c060a51b27fc19ec6386029f00385ba42a (diff)
downloadkutter-0dbfa915de5495662102d17c7a11cea219354b91.tar.gz
kutter-0dbfa915de5495662102d17c7a11cea219354b91.tar.xz
kutter-0dbfa915de5495662102d17c7a11cea219354b91.zip
adccmds: Add support for min/max temperature check filtering
Extend the ADC out of range check so that it is possible to sample multiple times before going into a shutdown state. This reduces the chance that measurement noise will cause an error. In an actual over temperature (or under temperature event) it is expected that the sensor will consistently report the problem, so extra checks for an additional second or two should not substantially increase risk. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/extras/adc_temperature.py')
-rw-r--r--klippy/extras/adc_temperature.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/klippy/extras/adc_temperature.py b/klippy/extras/adc_temperature.py
index 31c1ecce..1aea908b 100644
--- a/klippy/extras/adc_temperature.py
+++ b/klippy/extras/adc_temperature.py
@@ -8,6 +8,7 @@ import logging, bisect
SAMPLE_TIME = 0.001
SAMPLE_COUNT = 8
REPORT_TIME = 0.300
+RANGE_CHECK_COUNT = 4
# Linear style conversion chips calibrated with two temp measurements
class Linear:
@@ -50,7 +51,8 @@ class Linear:
def setup_minmax(self, min_temp, max_temp):
adc_range = [self.calc_adc(min_temp), self.calc_adc(max_temp)]
self.mcu_adc.setup_minmax(SAMPLE_TIME, SAMPLE_COUNT,
- minval=min(adc_range), maxval=max(adc_range))
+ minval=min(adc_range), maxval=max(adc_range),
+ range_check_count=RANGE_CHECK_COUNT)
def setup_callback(self, temperature_callback):
self.temperature_callback = temperature_callback
def get_report_time_delta(self):