WIP: PL PCDU #142
@ -1170,15 +1170,6 @@ void ObjectFactory::createPlPcduComponents(LinuxLibgpioIF* gpioComIF, SpiComIF*
|
|||||||
gpio = new GpiodRegularByLineName(q7s::gpioNames::PL_PCDU_ENABLE_DRO, consumer, gpio::DIR_OUT,
|
gpio = new GpiodRegularByLineName(q7s::gpioNames::PL_PCDU_ENABLE_DRO, consumer, gpio::DIR_OUT,
|
||||||
gpio::Levels::LOW);
|
gpio::Levels::LOW);
|
||||||
plPcduGpios->addGpio(gpioIds::PLPCDU_ENB_DRO, gpio);
|
plPcduGpios->addGpio(gpioIds::PLPCDU_ENB_DRO, gpio);
|
||||||
consumer = "PLPCDU_ENB_HPA";
|
|
||||||
gpio = new GpiodRegularByLineName(q7s::gpioNames::PL_PCDU_ENABLE_HPA, consumer, gpio::DIR_OUT,
|
|
||||||
gpio::Levels::LOW);
|
|
||||||
plPcduGpios->addGpio(gpioIds::PLPCDU_ENB_HPA, gpio);
|
|
||||||
consumer = "PLPCDU_ENB_MPA";
|
|
||||||
gpio = new GpiodRegularByLineName(q7s::gpioNames::PL_PCDU_ENABLE_MPA, consumer, gpio::DIR_OUT,
|
|
||||||
gpio::Levels::LOW);
|
|
||||||
plPcduGpios->addGpio(gpioIds::PLPCDU_ENB_MPA, gpio);
|
|
||||||
|
|
||||||
consumer = "PLPCDU_ENB_X8";
|
consumer = "PLPCDU_ENB_X8";
|
||||||
gpio = new GpiodRegularByLineName(q7s::gpioNames::PL_PCDU_ENABLE_X8, consumer, gpio::DIR_OUT,
|
gpio = new GpiodRegularByLineName(q7s::gpioNames::PL_PCDU_ENABLE_X8, consumer, gpio::DIR_OUT,
|
||||||
gpio::Levels::LOW);
|
gpio::Levels::LOW);
|
||||||
@ -1187,6 +1178,14 @@ void ObjectFactory::createPlPcduComponents(LinuxLibgpioIF* gpioComIF, SpiComIF*
|
|||||||
gpio = new GpiodRegularByLineName(q7s::gpioNames::PL_PCDU_ENABLE_TX, consumer, gpio::DIR_OUT,
|
gpio = new GpiodRegularByLineName(q7s::gpioNames::PL_PCDU_ENABLE_TX, consumer, gpio::DIR_OUT,
|
||||||
gpio::Levels::LOW);
|
gpio::Levels::LOW);
|
||||||
plPcduGpios->addGpio(gpioIds::PLPCDU_ENB_TX, gpio);
|
plPcduGpios->addGpio(gpioIds::PLPCDU_ENB_TX, gpio);
|
||||||
|
consumer = "PLPCDU_ENB_MPA";
|
||||||
|
gpio = new GpiodRegularByLineName(q7s::gpioNames::PL_PCDU_ENABLE_MPA, consumer, gpio::DIR_OUT,
|
||||||
|
gpio::Levels::LOW);
|
||||||
|
plPcduGpios->addGpio(gpioIds::PLPCDU_ENB_MPA, gpio);
|
||||||
|
consumer = "PLPCDU_ENB_HPA";
|
||||||
|
gpio = new GpiodRegularByLineName(q7s::gpioNames::PL_PCDU_ENABLE_HPA, consumer, gpio::DIR_OUT,
|
||||||
|
gpio::Levels::LOW);
|
||||||
|
plPcduGpios->addGpio(gpioIds::PLPCDU_ENB_HPA, gpio);
|
||||||
|
|
||||||
// Chip select pin is active low
|
// Chip select pin is active low
|
||||||
consumer = "PLPCDU_ADC_CS";
|
consumer = "PLPCDU_ADC_CS";
|
||||||
|
@ -37,6 +37,7 @@ void PayloadPcduHandler::doStartUp() {
|
|||||||
// If necessary, check whether a certain amount of time has elapsed
|
// If necessary, check whether a certain amount of time has elapsed
|
||||||
if (transitionOk) {
|
if (transitionOk) {
|
||||||
transitionOk = false;
|
transitionOk = false;
|
||||||
|
state = States::ON_TRANS_ADC_CLOSE_ZERO;
|
||||||
// We are now in ON mode
|
// We are now in ON mode
|
||||||
startTransition(MODE_NORMAL, 0);
|
startTransition(MODE_NORMAL, 0);
|
||||||
adcCountdown.setTimeout(50);
|
adcCountdown.setTimeout(50);
|
||||||
@ -92,6 +93,9 @@ void PayloadPcduHandler::stateMachineToNormal() {
|
|||||||
params.getValue(PlPcduParameter::DRO_TO_X8_WAIT_TIME_K, waitTime);
|
params.getValue(PlPcduParameter::DRO_TO_X8_WAIT_TIME_K, waitTime);
|
||||||
countdown.setTimeout(std::round(waitTime * 1000));
|
countdown.setTimeout(std::round(waitTime * 1000));
|
||||||
countdown.resetTimer();
|
countdown.resetTimer();
|
||||||
|
#if OBSW_VERBOSE_LEVEL >= 1
|
||||||
|
sif::info << "Enabling PL PCDU DRO module" << std::endl;
|
||||||
|
#endif
|
||||||
// Switch on DRO and start monitoring for negative voltages
|
// Switch on DRO and start monitoring for negative voltages
|
||||||
gpioIF->pullHigh(gpioIds::PLPCDU_ENB_DRO);
|
gpioIF->pullHigh(gpioIds::PLPCDU_ENB_DRO);
|
||||||
adcCountdown.setTimeout(100);
|
adcCountdown.setTimeout(100);
|
||||||
@ -111,6 +115,9 @@ void PayloadPcduHandler::stateMachineToNormal() {
|
|||||||
params.getValue(PlPcduParameter::X8_TO_TX_WAIT_TIME_K, waitTime);
|
params.getValue(PlPcduParameter::X8_TO_TX_WAIT_TIME_K, waitTime);
|
||||||
countdown.setTimeout(std::round(waitTime * 1000));
|
countdown.setTimeout(std::round(waitTime * 1000));
|
||||||
countdown.resetTimer();
|
countdown.resetTimer();
|
||||||
|
#if OBSW_VERBOSE_LEVEL >= 1
|
||||||
|
sif::info << "Enabling PL PCDU X8 module" << std::endl;
|
||||||
|
#endif
|
||||||
// Switch on X8
|
// Switch on X8
|
||||||
gpioIF->pullHigh(gpioIds::PLPCDU_ENB_X8);
|
gpioIF->pullHigh(gpioIds::PLPCDU_ENB_X8);
|
||||||
adcCountdown.setTimeout(100);
|
adcCountdown.setTimeout(100);
|
||||||
@ -130,6 +137,9 @@ void PayloadPcduHandler::stateMachineToNormal() {
|
|||||||
params.getValue(PlPcduParameter::TX_TO_MPA_WAIT_TIME_K, waitTime);
|
params.getValue(PlPcduParameter::TX_TO_MPA_WAIT_TIME_K, waitTime);
|
||||||
countdown.setTimeout(std::round(waitTime * 1000));
|
countdown.setTimeout(std::round(waitTime * 1000));
|
||||||
countdown.resetTimer();
|
countdown.resetTimer();
|
||||||
|
#if OBSW_VERBOSE_LEVEL >= 1
|
||||||
|
sif::info << "Enabling PL PCDU TX module" << std::endl;
|
||||||
|
#endif
|
||||||
// Switch on TX
|
// Switch on TX
|
||||||
gpioIF->pullHigh(gpioIds::PLPCDU_ENB_TX);
|
gpioIF->pullHigh(gpioIds::PLPCDU_ENB_TX);
|
||||||
// Wait for 100 ms before checking ADC values
|
// Wait for 100 ms before checking ADC values
|
||||||
@ -150,6 +160,9 @@ void PayloadPcduHandler::stateMachineToNormal() {
|
|||||||
params.getValue(PlPcduParameter::MPA_TO_HPA_WAIT_TIME_K, waitTime);
|
params.getValue(PlPcduParameter::MPA_TO_HPA_WAIT_TIME_K, waitTime);
|
||||||
countdown.setTimeout(std::round(waitTime * 1000));
|
countdown.setTimeout(std::round(waitTime * 1000));
|
||||||
countdown.resetTimer();
|
countdown.resetTimer();
|
||||||
|
#if OBSW_VERBOSE_LEVEL >= 1
|
||||||
|
sif::info << "Enabling PL PCDU MPA module" << std::endl;
|
||||||
|
#endif
|
||||||
// Switch on MPA
|
// Switch on MPA
|
||||||
gpioIF->pullHigh(gpioIds::PLPCDU_ENB_MPA);
|
gpioIF->pullHigh(gpioIds::PLPCDU_ENB_MPA);
|
||||||
// Wait for 100 ms before checking ADC values
|
// Wait for 100 ms before checking ADC values
|
||||||
@ -168,6 +181,9 @@ void PayloadPcduHandler::stateMachineToNormal() {
|
|||||||
if (not commandExecuted) {
|
if (not commandExecuted) {
|
||||||
// Switch on HPA
|
// Switch on HPA
|
||||||
gpioIF->pullHigh(gpioIds::PLPCDU_ENB_HPA);
|
gpioIF->pullHigh(gpioIds::PLPCDU_ENB_HPA);
|
||||||
|
#if OBSW_VERBOSE_LEVEL >= 1
|
||||||
|
sif::info << "Enabling PL PCDU HPA module" << std::endl;
|
||||||
|
#endif
|
||||||
commandExecuted = true;
|
commandExecuted = true;
|
||||||
}
|
}
|
||||||
// ADC values are ok, 5 seconds have elapsed
|
// ADC values are ok, 5 seconds have elapsed
|
||||||
@ -212,6 +228,9 @@ ReturnValue_t PayloadPcduHandler::buildTransitionDeviceCommand(DeviceCommandId_t
|
|||||||
*id = plpcdu::SETUP_CMD;
|
*id = plpcdu::SETUP_CMD;
|
||||||
return buildCommandFromCommand(*id, nullptr, 0);
|
return buildCommandFromCommand(*id, nullptr, 0);
|
||||||
}
|
}
|
||||||
|
if (mode == _MODE_TO_NORMAL) {
|
||||||
|
return buildNormalDeviceCommand(id);
|
||||||
|
}
|
||||||
return NOTHING_TO_SEND;
|
return NOTHING_TO_SEND;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -479,6 +498,7 @@ void PayloadPcduHandler::checkAdcValues() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
transitionOk = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PayloadPcduHandler::checkJsonFileInit() {
|
void PayloadPcduHandler::checkJsonFileInit() {
|
||||||
@ -503,6 +523,7 @@ bool PayloadPcduHandler::checkVoltage(float val, float lowerBound, float upperBo
|
|||||||
uint32_t p2 = 0;
|
uint32_t p2 = 0;
|
||||||
serializeFloat(p2, val);
|
serializeFloat(p2, val);
|
||||||
triggerEvent(event, tooLarge, p2);
|
triggerEvent(event, tooLarge, p2);
|
||||||
|
transitionOk = false;
|
||||||
transitionBackToOff();
|
transitionBackToOff();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -514,12 +535,20 @@ bool PayloadPcduHandler::checkCurrent(float val, float upperBound, Event event)
|
|||||||
uint32_t p2 = 0;
|
uint32_t p2 = 0;
|
||||||
serializeFloat(p2, val);
|
serializeFloat(p2, val);
|
||||||
triggerEvent(event, true, p2);
|
triggerEvent(event, true, p2);
|
||||||
|
transitionOk = false;
|
||||||
transitionBackToOff();
|
transitionBackToOff();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ReturnValue_t PayloadPcduHandler::isModeCombinationValid(Mode_t mode, Submode_t submode) {
|
||||||
|
if (mode == MODE_NORMAL and submode <= 1) {
|
||||||
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
|
}
|
||||||
|
return DeviceHandlerBase::isModeCombinationValid(mode, submode);
|
||||||
|
}
|
||||||
|
|
||||||
ReturnValue_t PayloadPcduHandler::serializeFloat(uint32_t& param, float val) {
|
ReturnValue_t PayloadPcduHandler::serializeFloat(uint32_t& param, float val) {
|
||||||
size_t dummy = 0;
|
size_t dummy = 0;
|
||||||
return SerializeAdapter::serialize(&val, reinterpret_cast<uint8_t*>(¶m), &dummy, 4,
|
return SerializeAdapter::serialize(&val, reinterpret_cast<uint8_t*>(¶m), &dummy, 4,
|
||||||
|
@ -33,6 +33,7 @@ class SpiCookie;
|
|||||||
class PayloadPcduHandler : public DeviceHandlerBase {
|
class PayloadPcduHandler : public DeviceHandlerBase {
|
||||||
public:
|
public:
|
||||||
static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PL_PCDU_HANDLER;
|
static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PL_PCDU_HANDLER;
|
||||||
|
//! [EXPORT] : [COMMENT] Could not transition properly and went back to ALL OFF
|
||||||
static constexpr Event TRANSITION_BACK_TO_OFF =
|
static constexpr Event TRANSITION_BACK_TO_OFF =
|
||||||
event::makeEvent(SUBSYSTEM_ID, 0, severity::MEDIUM);
|
event::makeEvent(SUBSYSTEM_ID, 0, severity::MEDIUM);
|
||||||
//! [EXPORT] : [COMMENT] P1: 0 -> too low, 1 -> too high P2: Float value
|
//! [EXPORT] : [COMMENT] P1: 0 -> too low, 1 -> too high P2: Float value
|
||||||
@ -139,6 +140,8 @@ class PayloadPcduHandler : public DeviceHandlerBase {
|
|||||||
uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override;
|
uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override;
|
||||||
ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
|
ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
|
||||||
LocalDataPoolManager& poolManager) override;
|
LocalDataPoolManager& poolManager) override;
|
||||||
|
ReturnValue_t isModeCombinationValid(Mode_t mode, Submode_t submode) override;
|
||||||
|
|
||||||
void handleExtConvRead(const uint8_t* bufStart);
|
void handleExtConvRead(const uint8_t* bufStart);
|
||||||
void handlePrintout();
|
void handlePrintout();
|
||||||
void checkAdcValues();
|
void checkAdcValues();
|
||||||
|
@ -83,8 +83,8 @@ static constexpr float SCALE_CURRENT_DRO = MAX122X_SCALE / (GAIN_INA169 * R_SHUN
|
|||||||
|
|
||||||
// TODO: Make these configurable parameters using a JSON file
|
// TODO: Make these configurable parameters using a JSON file
|
||||||
// Upper bound of currents in milliamperes [mA]
|
// Upper bound of currents in milliamperes [mA]
|
||||||
static constexpr double NEG_V_LOWER_BOUND = -6.0;
|
static constexpr double NEG_V_LOWER_BOUND = -6.5;
|
||||||
static constexpr double NEG_V_UPPER_BOUND = -3.3;
|
static constexpr double NEG_V_UPPER_BOUND = -2.7;
|
||||||
|
|
||||||
static constexpr double DRO_U_LOWER_BOUND = 5.0;
|
static constexpr double DRO_U_LOWER_BOUND = 5.0;
|
||||||
static constexpr double DRO_U_UPPER_BOUND = 7.0;
|
static constexpr double DRO_U_UPPER_BOUND = 7.0;
|
||||||
|
2
tmtc
2
tmtc
@ -1 +1 @@
|
|||||||
Subproject commit 7e24589184bb7bbd427c66ed55b3c29bbeba927f
|
Subproject commit 1238df03834b0b9ddbe2a59565de493661f5476e
|
Loading…
Reference in New Issue
Block a user