what if everyone was a returnvalue
All checks were successful
EIVE/eive-obsw/pipeline/pr-main This commit looks good
All checks were successful
EIVE/eive-obsw/pipeline/pr-main This commit looks good
This commit is contained in:
parent
bc9bb06f2d
commit
40ee5ddade
@ -158,7 +158,26 @@ void PowerController::calculateStateOfCharge() {
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
calculateCoulombCounterCharge();
|
|
||||||
|
result = calculateCoulombCounterCharge();
|
||||||
|
// store time for next run
|
||||||
|
oldTime = now;
|
||||||
|
if (result != returnvalue::OK) {
|
||||||
|
// notifying events have already been triggered
|
||||||
|
{
|
||||||
|
PoolReadGuard pg(&pwrCtrlCoreHk);
|
||||||
|
if (pg.getReadResult() == returnvalue::OK) {
|
||||||
|
pwrCtrlCoreHk.totalBatteryCurrent.value = iBat;
|
||||||
|
pwrCtrlCoreHk.totalBatteryCurrent.setValid(true);
|
||||||
|
pwrCtrlCoreHk.openCircuitVoltageCharge.value =
|
||||||
|
charge2stateOfCharge(openCircuitVoltageCharge);
|
||||||
|
pwrCtrlCoreHk.openCircuitVoltageCharge.setValid(true);
|
||||||
|
pwrCtrlCoreHk.coulombCounterCharge.value = INVALID_SOC;
|
||||||
|
pwrCtrlCoreHk.coulombCounterCharge.setValid(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// commit to dataset
|
// commit to dataset
|
||||||
{
|
{
|
||||||
@ -170,9 +189,6 @@ void PowerController::calculateStateOfCharge() {
|
|||||||
pwrCtrlCoreHk.setValidity(true, true);
|
pwrCtrlCoreHk.setValidity(true, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// store time for next run
|
|
||||||
oldTime = now;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t PowerController::calculateOpenCircuitVoltageCharge() {
|
ReturnValue_t PowerController::calculateOpenCircuitVoltageCharge() {
|
||||||
@ -189,21 +205,20 @@ ReturnValue_t PowerController::calculateOpenCircuitVoltageCharge() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t PowerController::calculateCoulombCounterCharge() {
|
ReturnValue_t PowerController::calculateCoulombCounterCharge() {
|
||||||
if ((pwrCtrlCoreHk.coulombCounterCharge.value == 0) or
|
double timeDiff = timevalOperations::toDouble(now - oldTime);
|
||||||
|
if (timeDiff > maxAllowedTimeDiff) {
|
||||||
|
triggerEvent(power::TIMEDELTA_OUT_OF_BOUNDS);
|
||||||
|
sif::error << "Power Controller::Time delta too large for Coulomb Counter" << std::endl;
|
||||||
|
return returnvalue::FAILED;
|
||||||
|
}
|
||||||
|
if ((not pwrCtrlCoreHk.coulombCounterCharge.isValid()) or
|
||||||
(p60CoreHk.batteryVoltage.value > coulombCounterVoltageUpperThreshold and
|
(p60CoreHk.batteryVoltage.value > coulombCounterVoltageUpperThreshold and
|
||||||
pwrCtrlCoreHk.coulombCounterCharge.value >= coulombCounterChargeUpperThreshold)) {
|
pwrCtrlCoreHk.coulombCounterCharge.value >= coulombCounterChargeUpperThreshold)) {
|
||||||
coulombCounterCharge = openCircuitVoltageCharge;
|
coulombCounterCharge = openCircuitVoltageCharge;
|
||||||
return returnvalue::OK;
|
} else {
|
||||||
}
|
|
||||||
|
|
||||||
else {
|
|
||||||
double timeDiff = timevalOperations::toDouble(now - oldTime);
|
|
||||||
if (timeDiff < maxAllowedTimeDiff) {
|
|
||||||
coulombCounterCharge = pwrCtrlCoreHk.coulombCounterCharge.value + iBat * timeDiff;
|
coulombCounterCharge = pwrCtrlCoreHk.coulombCounterCharge.value + iBat * timeDiff;
|
||||||
|
}
|
||||||
return returnvalue::OK;
|
return returnvalue::OK;
|
||||||
}
|
|
||||||
}
|
|
||||||
return returnvalue::FAILED;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t PowerController::updateEpsData() {
|
ReturnValue_t PowerController::updateEpsData() {
|
||||||
@ -259,3 +274,17 @@ ReturnValue_t PowerController::lookUpTableOcvIdxFinder(float voltage, uint8_t &i
|
|||||||
}
|
}
|
||||||
return returnvalue::OK;
|
return returnvalue::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ReturnValue_t PowerController::calculateCoulombCounterChargeUpperThreshold() {
|
||||||
|
uint8_t lookUpTableIdx = 99;
|
||||||
|
ReturnValue_t result =
|
||||||
|
lookUpTableOcvIdxFinder(coulombCounterVoltageUpperThreshold, lookUpTableIdx);
|
||||||
|
if (result != returnvalue::OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
coulombCounterChargeUpperThreshold =
|
||||||
|
linearInterpolation(coulombCounterVoltageUpperThreshold, lookUpTableOcv[1][lookUpTableIdx],
|
||||||
|
lookUpTableOcv[1][lookUpTableIdx + 1], lookUpTableOcv[0][lookUpTableIdx],
|
||||||
|
lookUpTableOcv[0][lookUpTableIdx + 1]);
|
||||||
|
return returnvalue::OK;
|
||||||
|
}
|
||||||
|
@ -49,6 +49,7 @@ class PowerController : public ExtendedControllerBase, public ReceivesParameterM
|
|||||||
float charge2stateOfCharge(float capacity);
|
float charge2stateOfCharge(float capacity);
|
||||||
ReturnValue_t lookUpTableOcvIdxFinder(float voltage, uint8_t& idx);
|
ReturnValue_t lookUpTableOcvIdxFinder(float voltage, uint8_t& idx);
|
||||||
float linearInterpolation(float x, float x0, float x1, float y0, float y1);
|
float linearInterpolation(float x, float x0, float x1, float y0, float y1);
|
||||||
|
ReturnValue_t calculateCoulombCounterChargeUpperThreshold();
|
||||||
|
|
||||||
// Parameters
|
// Parameters
|
||||||
float batteryInternalResistance = 70.0 / 2.0 / 1000.0; // [Ohm]
|
float batteryInternalResistance = 70.0 / 2.0 / 1000.0; // [Ohm]
|
||||||
|
@ -53,6 +53,9 @@ static constexpr Event DATASET_READ_FAILED = event::makeEvent(SUBSYSTEM_ID, 4, s
|
|||||||
//! be.
|
//! be.
|
||||||
//! P1: 1 too high, 0 too low
|
//! P1: 1 too high, 0 too low
|
||||||
static constexpr Event VOLTAGE_OUT_OF_BOUNDS = event::makeEvent(SUBSYSTEM_ID, 5, severity::HIGH);
|
static constexpr Event VOLTAGE_OUT_OF_BOUNDS = event::makeEvent(SUBSYSTEM_ID, 5, severity::HIGH);
|
||||||
|
//! [EXPORT] : [COMMENT] Time difference for Coulomb Counter was too large.
|
||||||
|
static constexpr Event TIMEDELTA_OUT_OF_BOUNDS =
|
||||||
|
event::makeEvent(SUBSYSTEM_ID, 6, severity::MEDIUM);
|
||||||
|
|
||||||
enum class States { IDLE, SWITCHING_POWER, CHECKING_POWER, MODE_COMMANDING };
|
enum class States { IDLE, SWITCHING_POWER, CHECKING_POWER, MODE_COMMANDING };
|
||||||
enum class OpCodes { NONE, TO_OFF_DONE, TO_NOT_OFF_DONE, TIMEOUT_OCCURED };
|
enum class OpCodes { NONE, TO_OFF_DONE, TO_NOT_OFF_DONE, TIMEOUT_OCCURED };
|
||||||
|
Loading…
Reference in New Issue
Block a user