SoC Calculator #754
@ -150,6 +150,8 @@ void PowerController::calculateStateOfCharge() {
|
||||
pwrCtrlCoreHk.setValidity(false, true);
|
||||
}
|
||||
}
|
||||
// store time for next run
|
||||
oldTime = now;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -171,12 +173,12 @@ void PowerController::calculateStateOfCharge() {
|
||||
pwrCtrlCoreHk.coulombCounterCharge.setValid(false);
|
||||
}
|
||||
}
|
||||
// store time for next run
|
||||
oldTime = now;
|
||||
return;
|
||||
}
|
||||
|
||||
result = calculateCoulombCounterCharge();
|
||||
// store time for next run
|
||||
oldTime = now;
|
||||
if (result != returnvalue::OK) {
|
||||
// notifying events have already been triggered
|
||||
{
|
||||
@ -191,6 +193,8 @@ void PowerController::calculateStateOfCharge() {
|
||||
pwrCtrlCoreHk.coulombCounterCharge.setValid(false);
|
||||
}
|
||||
}
|
||||
// store time for next run
|
||||
oldTime = now;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -204,6 +208,8 @@ void PowerController::calculateStateOfCharge() {
|
||||
pwrCtrlCoreHk.setValidity(true, true);
|
||||
}
|
||||
}
|
||||
// store time for next run
|
||||
oldTime = now;
|
||||
}
|
||||
|
||||
void PowerController::watchStateOfCharge() {
|
||||
@ -231,13 +237,14 @@ ReturnValue_t PowerController::calculateCoulombCounterCharge() {
|
||||
sif::error << "Power Controller::Time delta too large for Coulomb Counter" << std::endl;
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
if ((not pwrCtrlCoreHk.coulombCounterCharge.isValid()) or
|
||||
(bpxBatteryHk.battVoltage.value > coulombCounterVoltageUpperThreshold and
|
||||
pwrCtrlCoreHk.coulombCounterCharge.value >= coulombCounterChargeUpperThreshold)) {
|
||||
if (not pwrCtrlCoreHk.coulombCounterCharge.isValid()) {
|
||||
coulombCounterCharge = openCircuitVoltageCharge;
|
||||
} else {
|
||||
coulombCounterCharge =
|
||||
coulombCounterCharge + iBat * CONVERT_FROM_MILLI * timeDiff * SECONDS_TO_HOURS;
|
||||
if (coulombCounterCharge >= coulombCounterChargeUpperThreshold) {
|
||||
coulombCounterCharge = coulombCounterChargeUpperThreshold;
|
||||
}
|
||||
}
|
||||
return returnvalue::OK;
|
||||
}
|
||||
@ -261,7 +268,7 @@ ReturnValue_t PowerController::updateEpsData() {
|
||||
}
|
||||
|
||||
float PowerController::charge2stateOfCharge(float capacity) {
|
||||
return capacity / batteryMaximumCapacity;
|
||||
return capacity / coulombCounterChargeUpperThreshold;
|
||||
}
|
||||
|
||||
float PowerController::linearInterpolation(float x, float x0, float x1, float y0, float y1) {
|
||||
|
@ -54,8 +54,7 @@ static constexpr Event DATASET_READ_FAILED = event::makeEvent(SUBSYSTEM_ID, 4, s
|
||||
//! P1: 1 too high, 0 too low
|
||||
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);
|
||||
static constexpr Event TIMEDELTA_OUT_OF_BOUNDS = event::makeEvent(SUBSYSTEM_ID, 6, severity::LOW);
|
||||
|
||||
enum class States { IDLE, SWITCHING_POWER, CHECKING_POWER, MODE_COMMANDING };
|
||||
enum class OpCodes { NONE, TO_OFF_DONE, TO_NOT_OFF_DONE, TIMEOUT_OCCURED };
|
||||
|
Loading…
Reference in New Issue
Block a user