soc calculation fixes
All checks were successful
EIVE/eive-obsw/pipeline/pr-main This commit looks good

This commit is contained in:
Marius Eggert 2023-09-27 16:36:09 +02:00
parent c486bb2cf3
commit 6a77635bfb
2 changed files with 11 additions and 8 deletions

View File

@ -162,8 +162,7 @@ void PowerController::calculateStateOfCharge() {
} }
// calculate total battery current // calculate total battery current
iBat = p60CoreHk.batteryCurrent.value + bpxBatteryHk.heaterCurrent.value + iBat = p60CoreHk.batteryCurrent.value + bpxBatteryHk.dischargeCurrent.value;
bpxBatteryHk.dischargeCurrent.value;
result = calculateOpenCircuitVoltageCharge(); result = calculateOpenCircuitVoltageCharge();
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
@ -193,7 +192,7 @@ void PowerController::calculateStateOfCharge() {
pwrCtrlCoreHk.totalBatteryCurrent.value = iBat; pwrCtrlCoreHk.totalBatteryCurrent.value = iBat;
pwrCtrlCoreHk.totalBatteryCurrent.setValid(true); pwrCtrlCoreHk.totalBatteryCurrent.setValid(true);
pwrCtrlCoreHk.openCircuitVoltageCharge.value = pwrCtrlCoreHk.openCircuitVoltageCharge.value =
charge2stateOfCharge(openCircuitVoltageCharge); charge2stateOfCharge(openCircuitVoltageCharge, false);
pwrCtrlCoreHk.openCircuitVoltageCharge.setValid(true); pwrCtrlCoreHk.openCircuitVoltageCharge.setValid(true);
pwrCtrlCoreHk.coulombCounterCharge.value = INVALID_SOC; pwrCtrlCoreHk.coulombCounterCharge.value = INVALID_SOC;
pwrCtrlCoreHk.coulombCounterCharge.setValid(false); pwrCtrlCoreHk.coulombCounterCharge.setValid(false);
@ -209,8 +208,9 @@ void PowerController::calculateStateOfCharge() {
PoolReadGuard pg(&pwrCtrlCoreHk); PoolReadGuard pg(&pwrCtrlCoreHk);
if (pg.getReadResult() == returnvalue::OK) { if (pg.getReadResult() == returnvalue::OK) {
pwrCtrlCoreHk.totalBatteryCurrent.value = iBat; pwrCtrlCoreHk.totalBatteryCurrent.value = iBat;
pwrCtrlCoreHk.openCircuitVoltageCharge.value = charge2stateOfCharge(openCircuitVoltageCharge); pwrCtrlCoreHk.openCircuitVoltageCharge.value =
pwrCtrlCoreHk.coulombCounterCharge.value = charge2stateOfCharge(coulombCounterCharge); charge2stateOfCharge(openCircuitVoltageCharge, false);
pwrCtrlCoreHk.coulombCounterCharge.value = charge2stateOfCharge(coulombCounterCharge, true);
pwrCtrlCoreHk.setValidity(true, true); pwrCtrlCoreHk.setValidity(true, true);
} }
} }
@ -286,8 +286,11 @@ ReturnValue_t PowerController::updateEpsData() {
return returnvalue::OK; return returnvalue::OK;
} }
float PowerController::charge2stateOfCharge(float capacity) { float PowerController::charge2stateOfCharge(float capacity, bool coulombCounter) {
return capacity / coulombCounterChargeUpperThreshold; if (coulombCounter) {
return capacity / coulombCounterChargeUpperThreshold;
}
return capacity / batteryMaximumCapacity;
} }
float PowerController::linearInterpolation(float x, float x0, float x1, float y0, float y1) { float PowerController::linearInterpolation(float x, float x0, float x1, float y0, float y1) {

View File

@ -47,7 +47,7 @@ class PowerController : public ExtendedControllerBase, public ReceivesParameterM
ReturnValue_t calculateOpenCircuitVoltageCharge(); ReturnValue_t calculateOpenCircuitVoltageCharge();
ReturnValue_t calculateCoulombCounterCharge(); ReturnValue_t calculateCoulombCounterCharge();
ReturnValue_t updateEpsData(); ReturnValue_t updateEpsData();
float charge2stateOfCharge(float capacity); float charge2stateOfCharge(float capacity, bool coulombCounter);
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(); ReturnValue_t calculateCoulombCounterChargeUpperThreshold();