From 0dbfa915de5495662102d17c7a11cea219354b91 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Mon, 2 Jul 2018 13:47:22 -0400 Subject: 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 --- klippy/extras/thermistor.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'klippy/extras/thermistor.py') diff --git a/klippy/extras/thermistor.py b/klippy/extras/thermistor.py index 3f96066d..c39ae66e 100644 --- a/klippy/extras/thermistor.py +++ b/klippy/extras/thermistor.py @@ -9,6 +9,7 @@ KELVIN_TO_CELCIUS = -273.15 SAMPLE_TIME = 0.001 SAMPLE_COUNT = 8 REPORT_TIME = 0.300 +RANGE_CHECK_COUNT = 4 # Analog voltage to temperature converter for thermistors class Thermistor: @@ -59,7 +60,8 @@ class Thermistor: 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): -- cgit v1.2.3-70-g09d2