From b44442b282a39794180b311607a06e689b02a33e Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 3 Mar 2022 19:34:52 +0100 Subject: [PATCH] some fixes for pl pcdu --- linux/devices/startracker/StrHelper.cpp | 2 +- mission/devices/PayloadPcduHandler.cpp | 17 +++++++++++------ mission/devices/PayloadPcduHandler.h | 3 ++- .../devicedefinitions/payloadPcduDefinitions.h | 5 +++-- mission/utility/ProgressPrinter.cpp | 4 ++-- tmtc | 2 +- 6 files changed, 20 insertions(+), 13 deletions(-) diff --git a/linux/devices/startracker/StrHelper.cpp b/linux/devices/startracker/StrHelper.cpp index cab99a1a..599b706f 100644 --- a/linux/devices/startracker/StrHelper.cpp +++ b/linux/devices/startracker/StrHelper.cpp @@ -6,8 +6,8 @@ #include "OBSWConfig.h" #include "fsfw/timemanager/Countdown.h" #include "linux/devices/devicedefinitions/StarTrackerDefinitions.h" -#include "mission/utility/Timestamp.h" #include "mission/utility/ProgressPrinter.h" +#include "mission/utility/Timestamp.h" StrHelper::StrHelper(object_id_t objectId) : SystemObject(objectId) {} diff --git a/mission/devices/PayloadPcduHandler.cpp b/mission/devices/PayloadPcduHandler.cpp index c5bad0bf..bd07827c 100644 --- a/mission/devices/PayloadPcduHandler.cpp +++ b/mission/devices/PayloadPcduHandler.cpp @@ -204,7 +204,7 @@ void PayloadPcduHandler::doTransition(Mode_t modeFrom, Submode_t subModeFrom) { } } -void PayloadPcduHandler::doShutDown() { transitionBackToOff(); } +void PayloadPcduHandler::doShutDown() { transitionBackToOff(false); } ReturnValue_t PayloadPcduHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { switch (adcState) { @@ -388,7 +388,7 @@ void PayloadPcduHandler::enablePeriodicPrintout(bool enable, uint8_t divider) { opDivider.setDivider(divider); } -void PayloadPcduHandler::transitionBackToOff() { +void PayloadPcduHandler::transitionBackToOff(bool notifyFdir) { States currentState = state; gpioIF->pullLow(gpioIds::PLPCDU_ENB_HPA); gpioIF->pullLow(gpioIds::PLPCDU_ENB_MPA); @@ -401,8 +401,9 @@ void PayloadPcduHandler::transitionBackToOff() { state = States::PCDU_OFF; adcState = AdcStates::OFF; setMode(MODE_OFF); - // Notify FDIR - triggerEvent(TRANSITION_BACK_TO_OFF, static_cast(currentState)); + if (notifyFdir) { + triggerEvent(TRANSITION_BACK_TO_OFF, static_cast(currentState)); + } } void PayloadPcduHandler::checkAdcValues() { @@ -443,6 +444,10 @@ void PayloadPcduHandler::checkAdcValues() { } params.getValue(PlPcduParameter::DRO_I_UPPER_BOUND_K, upperBound); if (not checkCurrent(adcSet.processed[I_DRO], upperBound, I_DRO_OUT_OF_BOUNDS)) { +#if OBSW_VERBOSE_LEVEL >= 1 + sif::warning << "Detected out of bounds current for DRO: " << adcSet.processed[I_DRO] + << ", Raw: " << adcSet.channels[I_DRO] << std::endl; +#endif return; } } @@ -524,7 +529,7 @@ bool PayloadPcduHandler::checkVoltage(float val, float lowerBound, float upperBo serializeFloat(p2, val); triggerEvent(event, tooLarge, p2); transitionOk = false; - transitionBackToOff(); + transitionBackToOff(true); return false; } return true; @@ -536,7 +541,7 @@ bool PayloadPcduHandler::checkCurrent(float val, float upperBound, Event event) serializeFloat(p2, val); triggerEvent(event, true, p2); transitionOk = false; - transitionBackToOff(); + transitionBackToOff(true); return false; } return true; diff --git a/mission/devices/PayloadPcduHandler.h b/mission/devices/PayloadPcduHandler.h index 519cc795..76260595 100644 --- a/mission/devices/PayloadPcduHandler.h +++ b/mission/devices/PayloadPcduHandler.h @@ -128,7 +128,7 @@ class PayloadPcduHandler : public DeviceHandlerBase { void doStartUp() override; void doShutDown() override; // Main FDIR function which goes from any PL PCDU state back to all off - void transitionBackToOff(); + void transitionBackToOff(bool notifyFdir); ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t* id) override; ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t* id) override; void fillCommandAndReplyMap() override; @@ -145,6 +145,7 @@ class PayloadPcduHandler : public DeviceHandlerBase { void handleExtConvRead(const uint8_t* bufStart); void handlePrintout(); void checkAdcValues(); + void handleOutOfBoundsPrintout(); void checkJsonFileInit(); void stateMachineToNormal(); bool checkVoltage(float val, float lowerBound, float upperBound, Event event); diff --git a/mission/devices/devicedefinitions/payloadPcduDefinitions.h b/mission/devices/devicedefinitions/payloadPcduDefinitions.h index f97c31b5..a5883191 100644 --- a/mission/devices/devicedefinitions/payloadPcduDefinitions.h +++ b/mission/devices/devicedefinitions/payloadPcduDefinitions.h @@ -70,7 +70,7 @@ static constexpr float R_SHUNT_HPA = 0.008; static constexpr float R_SHUNT_MPA = 0.015; static constexpr float R_SHUNT_TX = 0.05; static constexpr float R_SHUNT_X8 = 0.015; -static constexpr float R_SHUNT_DRO = 0.022; +static constexpr float R_SHUNT_DRO = 0.22; static constexpr float V_POS = 3.3; static constexpr float VOLTAGE_DIV_U_NEG = (49.9 + 27.4) / 27.4; static constexpr float MAX122X_SCALE = MAX122X_VREF / MAX122X_BIT; @@ -88,7 +88,8 @@ static constexpr double NEG_V_UPPER_BOUND = -2.7; static constexpr double DRO_U_LOWER_BOUND = 5.0; static constexpr double DRO_U_UPPER_BOUND = 7.0; -static constexpr double DRO_I_UPPER_BOUND = 40.0; +// Max Current DRO + Max Current Neg V | 40 + 15 +static constexpr double DRO_I_UPPER_BOUND = 55.0; static constexpr double X8_U_LOWER_BOUND = 2.6; static constexpr double X8_U_UPPER_BOUND = 4.0; diff --git a/mission/utility/ProgressPrinter.cpp b/mission/utility/ProgressPrinter.cpp index c3a8e3f6..16a0f148 100644 --- a/mission/utility/ProgressPrinter.cpp +++ b/mission/utility/ProgressPrinter.cpp @@ -1,11 +1,11 @@ #include "ProgressPrinter.h" + #include "fsfw/serviceinterface/ServiceInterfaceStream.h" ProgressPrinter::ProgressPrinter(std::string name, uint32_t numSteps) : name(name), numSteps(numSteps) {} -ProgressPrinter::~ProgressPrinter() { -} +ProgressPrinter::~ProgressPrinter() {} void ProgressPrinter::print(uint32_t currentStep) { float progressInPercent = static_cast(currentStep) / static_cast(numSteps) * 100; diff --git a/tmtc b/tmtc index 37c1a68d..9a487c74 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 37c1a68da1b465514e84403b06ce40d035e4ad88 +Subproject commit 9a487c7407eb450e3d07e1ddf3649a267ced99c2