From 7e01a9602efad0d7c6212df38ecc055ae1cd5fe7 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 10 Jul 2023 14:46:35 +0200 Subject: [PATCH 1/2] TCS improvements --- CHANGELOG.md | 4 +++ mission/controller/ThermalController.cpp | 36 ++++++------------------ mission/controller/ThermalController.h | 4 +-- 3 files changed, 14 insertions(+), 30 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 77862553..62b7a7c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,8 @@ will consitute of a breaking change warranting a new major release: ## Changed +- TCS: Remove OBC IF board thermal module, which is exactly identical to OBC module and therefore + obsolete. - Swapped PL and PS I2C, BPX battery and MGT are connected to PS I2C now for firmware versions 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 @@ -40,6 +42,8 @@ will consitute of a breaking change warranting a new major release: - TMP1075: Devices did not go to OFF mode when being set faulty. - Update PL PCDU 1 in TCS mode tree on the EM. - TMP1075: Possibly ignored health commands. +- TCS CTRL: Limit number of heater handler messages sent in case there are not sensors available + anymore. # Added diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 79f11785..b6b58946 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -1247,25 +1247,6 @@ void ThermalController::ctrlObc() { } } -void ThermalController::ctrlObcIfBoard() { - currThermalComponent = OBCIF_BOARD; - sensors[0].first = deviceTemperatures.q7s.isValid(); - sensors[0].second = deviceTemperatures.q7s.value; - sensors[1].first = sensorTemperatures.tmp1075Tcs0.isValid(); - sensors[1].second = sensorTemperatures.tmp1075Tcs0.value; - sensors[2].first = sensorTemperatures.tmp1075Tcs1.isValid(); - sensors[2].second = sensorTemperatures.tmp1075Tcs1.value; - numSensors = 3; - HeaterContext htrCtx(heater::HEATER_3_OBC_BRD, heater::HEATER_2_ACS_BRD, obcIfBoardLimits); - ctrlComponentTemperature(htrCtx); - if (componentAboveUpperLimit and not obcTooHotFlag) { - triggerEvent(tcsCtrl::OBC_OVERHEATING, tempFloatToU32()); - obcTooHotFlag = true; - } else if (not componentAboveUpperLimit) { - obcTooHotFlag = false; - } -} - void ThermalController::ctrlSBandTransceiver() { currThermalComponent = SBAND_TRANSCEIVER; sensors[0].first = deviceTemperatures.syrlinksPowerAmplifier.isValid(); @@ -1531,7 +1512,6 @@ void ThermalController::performThermalModuleCtrl(const HeaterSwitchStates& heate ctrlIfBoard(); ctrlTcsBoard(); ctrlObc(); - ctrlObcIfBoard(); ctrlSBandTransceiver(); ctrlPcduP60Board(); ctrlPcduAcu(); @@ -1599,9 +1579,11 @@ 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()) { - heaterSwitchHelper(htrCtx.switchNr, HeaterHandler::SwitchState::OFF, currThermalComponent); - } + // Also track the counter to prevent heater handler message spam. The heater handle can only + // process 2 messages per cycle. + if (heaterCtrlAllowed() and (thermalStates[currThermalComponent].noSensorAvailableCounter < 3)) { + heaterSwitchHelper(htrCtx.switchNr, HeaterHandler::SwitchState::OFF, currThermalComponent); + } } } resetSensorsArray(); @@ -1612,18 +1594,18 @@ bool ThermalController::selectAndReadSensorTemp(HeaterContext& htrCtx) { sensors[i].second > SANITY_LIMIT_LOWER_TEMP and sensors[i].second < SANITY_LIMIT_UPPER_TEMP) { sensorTemp = sensors[i].second; - thermalStates[currThermalComponent].errorCounter = 0; + thermalStates[currThermalComponent].noSensorAvailableCounter = 0; return true; } } - thermalStates[currThermalComponent].errorCounter++; + thermalStates[currThermalComponent].noSensorAvailableCounter++; if (currThermalComponent != RW and currThermalComponent != ACS_BOARD) { - if (thermalStates[currThermalComponent].errorCounter <= 3) { + if (thermalStates[currThermalComponent].noSensorAvailableCounter <= 3) { triggerEvent(tcsCtrl::NO_VALID_SENSOR_TEMPERATURE, currThermalComponent); } } else { - if (thermalStates[currThermalComponent].errorCounter <= 8) { + if (thermalStates[currThermalComponent].noSensorAvailableCounter <= 8) { triggerEvent(tcsCtrl::NO_VALID_SENSOR_TEMPERATURE, currThermalComponent); } } diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index b571b950..24a016c3 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -47,7 +47,7 @@ struct TempLimits { }; struct ThermalState { - uint8_t errorCounter; + uint8_t noSensorAvailableCounter; // Is heating on for that thermal module? bool heating = false; heater::Switch heaterSwitch = heater::Switch::NUMBER_OF_SWITCHES; @@ -74,7 +74,6 @@ enum ThermalComponents : uint8_t { IF_BOARD = 5, TCS_BOARD = 6, OBC = 7, - OBCIF_BOARD = 8, SBAND_TRANSCEIVER = 9, PCDUP60_BOARD = 10, PCDUACU = 11, @@ -331,7 +330,6 @@ class ThermalController : public ExtendedControllerBase { void ctrlIfBoard(); void ctrlTcsBoard(); void ctrlObc(); - void ctrlObcIfBoard(); void ctrlSBandTransceiver(); void ctrlPcduP60Board(); void ctrlPcduAcu(); From 7c4f98ec223618534edc03f135ed90ff95c6f61d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 10 Jul 2023 15:23:04 +0200 Subject: [PATCH 2/2] add back with other name and comment --- mission/controller/ThermalController.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index 24a016c3..9df9a7a0 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -74,6 +74,8 @@ enum ThermalComponents : uint8_t { IF_BOARD = 5, TCS_BOARD = 6, OBC = 7, + // Not used anymore, was identical to OBC module. + LEGACY_OBCIF_BOARD = 8, SBAND_TRANSCEIVER = 9, PCDUP60_BOARD = 10, PCDUACU = 11,