From 1e98fcbbd597e6393b60cdb4d55877c28fcf41a9 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 6 Jul 2023 12:01:48 +0200 Subject: [PATCH 1/7] that really should not cause issues though.. --- mission/controller/ThermalController.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 53babbd5..7de3fc6c 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -1596,8 +1596,7 @@ void ThermalController::ctrlComponentTemperature(HeaterContext& htrCtx) { // No sensors available, so switch the heater off. We can not perform control tasks if we // are blind.. if (chooseHeater(htrCtx.switchNr, htrCtx.redSwitchNr)) { - if (heaterCtrlAllowed() and - (heaterHandler.getSwitchState(htrCtx.switchNr) == HeaterHandler::SwitchState::ON)) { + if (heaterCtrlAllowed()) { heaterSwitchHelper(htrCtx.switchNr, HeaterHandler::SwitchState::OFF, thermalComponent); } } @@ -1680,7 +1679,7 @@ void ThermalController::checkLimitsAndCtrlHeater(HeaterContext& htrCtx) { return; } - htrCtx.switchState = heaterHandler.getSwitchState(htrCtx.switchNr); + htrCtx.switchState = static_cast(heaterInfo.heaterSwitchState[htrCtx.switchNr]); // Heater off if (htrCtx.switchState == HeaterHandler::SwitchState::OFF) { if (sensorTemp < htrCtx.tempLimit.opLowerLimit and heaterCtrlAllowed()) { From 1d4b815452439d29d9c85478bab9c21504af2223 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 6 Jul 2023 12:04:36 +0200 Subject: [PATCH 2/7] this is better to read.. --- mission/controller/ThermalController.cpp | 3 ++- mission/tcs/HeaterHandler.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 7de3fc6c..dd0581af 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -1679,7 +1679,8 @@ void ThermalController::checkLimitsAndCtrlHeater(HeaterContext& htrCtx) { return; } - htrCtx.switchState = static_cast(heaterInfo.heaterSwitchState[htrCtx.switchNr]); + htrCtx.switchState = + static_cast(heaterInfo.heaterSwitchState[htrCtx.switchNr]); // Heater off if (htrCtx.switchState == HeaterHandler::SwitchState::OFF) { if (sensorTemp < htrCtx.tempLimit.opLowerLimit and heaterCtrlAllowed()) { diff --git a/mission/tcs/HeaterHandler.cpp b/mission/tcs/HeaterHandler.cpp index 8416a7f7..07e6f0eb 100644 --- a/mission/tcs/HeaterHandler.cpp +++ b/mission/tcs/HeaterHandler.cpp @@ -419,13 +419,13 @@ ReturnValue_t HeaterHandler::getAllSwitchStates(std::array& stat } bool HeaterHandler::allSwitchesOff() { - bool allSwitchesOrd = false; MutexGuard mg(handlerLock, LOCK_TYPE, LOCK_TIMEOUT, LOCK_CTX); - /* Or all switches. As soon one switch is on, allSwitchesOrd will be true */ for (power::Switch_t switchNr = 0; switchNr < heater::NUMBER_OF_SWITCHES; switchNr++) { - allSwitchesOrd = allSwitchesOrd || heaterVec.at(switchNr).switchState; + if (heaterVec.at(switchNr).switchState == SwitchState::ON) { + return false; + } } - return !allSwitchesOrd; + return true; } MessageQueueId_t HeaterHandler::getCommandQueue() const { return commandQueue->getId(); } From 12ff3654332ce61e82a89b06b8e8dc4e46b532bf Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 6 Jul 2023 19:57:23 +0200 Subject: [PATCH 3/7] 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 4/7] 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 5/7] 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 6/7] 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; } From 2bad2a142b1c0a72223b81fde145765c1e77a503 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 7 Jul 2023 10:58:42 +0200 Subject: [PATCH 7/7] changelog --- CHANGELOG.md | 2 ++ tmtc | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 40622385..d88cf5ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,8 @@ will consitute of a breaking change warranting a new major release: equal or above v4. However, this software version is compatible to both v3 and v4 of the firmware. - The firmware version variables are global statics inititalized early during the program runtime now. This makes it possible to check the firmware version earlier. +- The TCS controller will now always command heaters OFF when being blind for thermal + components (no sensors available), irrespective of current switch state. ## Fixed diff --git a/tmtc b/tmtc index 6d5bde40..069f84d2 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 6d5bde40db69534a8cea923f96145bdeb62b79af +Subproject commit 069f84d2207c03e8d334cfce3f7dd530babe17b0