From 12ff3654332ce61e82a89b06b8e8dc4e46b532bf Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 6 Jul 2023 19:57:23 +0200 Subject: [PATCH 1/4] TCS ctrl bugfix --- CHANGELOG.md | 3 +++ mission/controller/ThermalController.cpp | 13 ++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 08f904a9..50471069 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,9 @@ will consitute of a breaking change warranting a new major release: - TMP1075: Set dataset invalid on shutdown explicitely - Small fixes for TMP1075 FDIR: Use strange and missed reply counters. +- TCS controller: A helper member to track the elapsed heater control cycles was not reset + properly, which could lead to switch transitions being completed immediately. This can + lead to weird bugs like switched being commanded on twice. # [v6.0.0] 2023-07-02 diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index fca71acc..5a544b3c 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -1687,8 +1687,9 @@ void ThermalController::checkLimitsAndCtrlHeater(HeaterContext& htrCtx) { // Heater off if (htrCtx.switchState == HeaterHandler::SwitchState::OFF) { if (sensorTemp < htrCtx.tempLimit.opLowerLimit and heaterCtrlAllowed()) { - sif::info << "TCS: Heater " << static_cast(thermalComponent) << " ON" << std::endl; - heaterSwitchHelper(htrCtx.switchNr, HeaterHandler::SwitchState::ON, thermalComponent); + sif::info << "TCS: Heater " << (int)htrCtx.switchNr << " for component " + << static_cast(currThermalComponent) << " ON" << std::endl; + heaterSwitchHelper(htrCtx.switchNr, HeaterHandler::SwitchState::ON, currThermalComponent); heaterStates[htrCtx.switchNr].switchTransition = true; heaterStates[htrCtx.switchNr].target = HeaterHandler::SwitchState::ON; } else { @@ -1704,8 +1705,9 @@ void ThermalController::checkLimitsAndCtrlHeater(HeaterContext& htrCtx) { if (thermalStates[thermalComponent].heating) { // We are already in a heating cycle, so need to check whether heating task is complete. if (sensorTemp >= htrCtx.tempLimit.opLowerLimit + TEMP_OFFSET and heaterCtrlAllowed()) { - sif::info << "TCS: Heater " << static_cast(thermalComponent) << " OFF" << std::endl; - heaterSwitchHelper(htrCtx.switchNr, HeaterHandler::SwitchState::OFF, thermalComponent); + sif::info << "TCS: Heater " << (int)htrCtx.switchNr << " for component " + << static_cast(currThermalComponent) << " OFF" << std::endl; + heaterSwitchHelper(htrCtx.switchNr, HeaterHandler::SwitchState::OFF, currThermalComponent); heaterStates[htrCtx.switchNr].switchTransition = true; heaterStates[htrCtx.switchNr].target = HeaterHandler::SwitchState::OFF; } @@ -1755,9 +1757,10 @@ void ThermalController::heaterTransitionControl(const HeaterSwitchStates& curren if (heaterStates[i].switchTransition) { if (currentHeaterStates[i] == heaterStates[i].target) { heaterStates[i].switchTransition = false; + heaterStates[i].heaterSwitchControlCycles = 0; continue; } - if (heaterStates[i].heaterSwitchControlCycles > 3) { + if (heaterStates[i].heaterSwitchControlCycles > 5) { heaterStates[i].switchTransition = false; heaterStates[i].heaterSwitchControlCycles = 0; } From 64ca329d5acba5ebb8c65d459c295fac8dc40dc8 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 6 Jul 2023 19:58:24 +0200 Subject: [PATCH 2/4] update changelog --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 50471069..021ceedd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,7 +29,8 @@ will consitute of a breaking change warranting a new major release: - Small fixes for TMP1075 FDIR: Use strange and missed reply counters. - TCS controller: A helper member to track the elapsed heater control cycles was not reset properly, which could lead to switch transitions being completed immediately. This can - lead to weird bugs like switched being commanded on twice. + lead to weird bugs like heaters being commanded ON twice and can potentially lead to + other bugs. # [v6.0.0] 2023-07-02 From 3e92d175d50a18c5da9f71af79c156b2ca98fe9f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 6 Jul 2023 20:01:57 +0200 Subject: [PATCH 3/4] form fix --- mission/controller/ThermalController.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 5a544b3c..e873d638 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -1687,7 +1687,7 @@ void ThermalController::checkLimitsAndCtrlHeater(HeaterContext& htrCtx) { // Heater off if (htrCtx.switchState == HeaterHandler::SwitchState::OFF) { if (sensorTemp < htrCtx.tempLimit.opLowerLimit and heaterCtrlAllowed()) { - sif::info << "TCS: Heater " << (int)htrCtx.switchNr << " for component " + sif::info << "TCS: Heater " << static_cast(htrCtx.switchNr) << " for component " << static_cast(currThermalComponent) << " ON" << std::endl; heaterSwitchHelper(htrCtx.switchNr, HeaterHandler::SwitchState::ON, currThermalComponent); heaterStates[htrCtx.switchNr].switchTransition = true; @@ -1705,7 +1705,7 @@ void ThermalController::checkLimitsAndCtrlHeater(HeaterContext& htrCtx) { if (thermalStates[thermalComponent].heating) { // We are already in a heating cycle, so need to check whether heating task is complete. if (sensorTemp >= htrCtx.tempLimit.opLowerLimit + TEMP_OFFSET and heaterCtrlAllowed()) { - sif::info << "TCS: Heater " << (int)htrCtx.switchNr << " for component " + sif::info << "TCS: Heater " << static_cast(htrCtx.switchNr) << " for component " << static_cast(currThermalComponent) << " OFF" << std::endl; heaterSwitchHelper(htrCtx.switchNr, HeaterHandler::SwitchState::OFF, currThermalComponent); heaterStates[htrCtx.switchNr].switchTransition = true; From faffca0c2c85abed8233cf3c54c62c3d3e940f30 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 6 Jul 2023 20:19:05 +0200 Subject: [PATCH 4/4] compile fix --- mission/controller/ThermalController.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index e873d638..3cbd5d4d 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -1688,8 +1688,8 @@ void ThermalController::checkLimitsAndCtrlHeater(HeaterContext& htrCtx) { if (htrCtx.switchState == HeaterHandler::SwitchState::OFF) { if (sensorTemp < htrCtx.tempLimit.opLowerLimit and heaterCtrlAllowed()) { sif::info << "TCS: Heater " << static_cast(htrCtx.switchNr) << " for component " - << static_cast(currThermalComponent) << " ON" << std::endl; - heaterSwitchHelper(htrCtx.switchNr, HeaterHandler::SwitchState::ON, currThermalComponent); + << static_cast(thermalComponent) << " ON" << std::endl; + heaterSwitchHelper(htrCtx.switchNr, HeaterHandler::SwitchState::ON, thermalComponent); heaterStates[htrCtx.switchNr].switchTransition = true; heaterStates[htrCtx.switchNr].target = HeaterHandler::SwitchState::ON; } else { @@ -1706,8 +1706,8 @@ void ThermalController::checkLimitsAndCtrlHeater(HeaterContext& htrCtx) { // We are already in a heating cycle, so need to check whether heating task is complete. if (sensorTemp >= htrCtx.tempLimit.opLowerLimit + TEMP_OFFSET and heaterCtrlAllowed()) { sif::info << "TCS: Heater " << static_cast(htrCtx.switchNr) << " for component " - << static_cast(currThermalComponent) << " OFF" << std::endl; - heaterSwitchHelper(htrCtx.switchNr, HeaterHandler::SwitchState::OFF, currThermalComponent); + << static_cast(thermalComponent) << " OFF" << std::endl; + heaterSwitchHelper(htrCtx.switchNr, HeaterHandler::SwitchState::OFF, thermalComponent); heaterStates[htrCtx.switchNr].switchTransition = true; heaterStates[htrCtx.switchNr].target = HeaterHandler::SwitchState::OFF; }