From 043804b91b5a315d601f1d839793a561bb20b46b Mon Sep 17 00:00:00 2001 From: Frank Sinapi Date: Thu, 17 Nov 2022 12:08:08 -0500 Subject: [PATCH] feat(thermocycler-gen2): ignore thermistor uniformity checks below 7.5 degrees (#428) * Add some leniency to uniformity checks below 7.5 degrees C --- .../thermocycler-gen2/plate_control.hpp | 7 ++++++ .../thermocycler-gen2/src/plate_control.cpp | 3 ++- .../tests/test_plate_control.cpp | 22 +++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/stm32-modules/include/thermocycler-gen2/thermocycler-gen2/plate_control.hpp b/stm32-modules/include/thermocycler-gen2/thermocycler-gen2/plate_control.hpp index 75619cd0..d37ed567 100644 --- a/stm32-modules/include/thermocycler-gen2/thermocycler-gen2/plate_control.hpp +++ b/stm32-modules/include/thermocycler-gen2/thermocycler-gen2/plate_control.hpp @@ -100,6 +100,13 @@ class PlateControl { static constexpr double TARGET_ADJUST_FOR_COLD_TARGET = -5.0F; /** Extra factor to multiply the proportioal band by */ static constexpr double PROPORTIONAL_BAND_EXTRA_FACTOR = 2.0F; + /** + * When performing the thermistor drift check, this is the max point + * below which errors are ignored. This is added to prevent unnecesary + * error messages during long periods below 8ยบ where temperature may + * drift more than our normal spec BUT will not affect the samples. + */ + static constexpr double DRIFT_CHECK_IGNORE_MAX_TEMP = 7.5; PlateControl() = delete; /** diff --git a/stm32-modules/thermocycler-gen2/src/plate_control.cpp b/stm32-modules/thermocycler-gen2/src/plate_control.cpp index 40773148..5d83ccca 100644 --- a/stm32-modules/thermocycler-gen2/src/plate_control.cpp +++ b/stm32-modules/thermocycler-gen2/src/plate_control.cpp @@ -304,7 +304,8 @@ auto PlateControl::reset_control(thermal_general::HeatsinkFan &fan) -> void { min = std::min(temperature, min); max = std::max(temperature, max); } - return std::abs(max - min) <= THERMISTOR_DRIFT_MAX_C; + return (std::abs(max - min) <= THERMISTOR_DRIFT_MAX_C) || + (max <= DRIFT_CHECK_IGNORE_MAX_TEMP); } [[nodiscard]] auto PlateControl::get_peltier_temps() const diff --git a/stm32-modules/thermocycler-gen2/tests/test_plate_control.cpp b/stm32-modules/thermocycler-gen2/tests/test_plate_control.cpp index ff9d4a73..1a7f00e5 100644 --- a/stm32-modules/thermocycler-gen2/tests/test_plate_control.cpp +++ b/stm32-modules/thermocycler-gen2/tests/test_plate_control.cpp @@ -201,6 +201,28 @@ TEST_CASE("PlateControl drift error check") { THEN("the result is false") { REQUIRE(result == false); } } } + GIVEN("uniform cold temperature across thermistors") { + constexpr double target = 4; + set_temp(thermistors, target); + WHEN("checking for thermistor drift") { + auto result = plateControl.thermistor_drift_check(); + THEN("the result is true") { REQUIRE(result == true); } + } + AND_GIVEN("thermistors out of spec BUT under 7.5") { + thermistors.at(THERM_BACK_LEFT).temp_c = 0.5; + thermistors.at(THERM_BACK_RIGHT).temp_c = 7; + THEN("thermistor drift error does not occur") { + REQUIRE(plateControl.thermistor_drift_check()); + } + } + AND_GIVEN("thermistors out of spec and a resistor exceeds 7.5") { + thermistors.at(THERM_BACK_LEFT).temp_c = 0.5; + thermistors.at(THERM_BACK_RIGHT).temp_c = 8; + THEN("thermistor drift error occurs") { + REQUIRE(!plateControl.thermistor_drift_check()); + } + } + } } }