SoC Calculator #754

Merged
muellerr merged 74 commits from soc-calculator into main 2023-10-11 10:50:48 +02:00
2 changed files with 5 additions and 2 deletions
Showing only changes of commit 6b9e191988 - Show all commits

View File

@ -211,7 +211,8 @@ void PowerController::watchStateOfCharge() {
} }
ReturnValue_t PowerController::calculateOpenCircuitVoltageCharge() { ReturnValue_t PowerController::calculateOpenCircuitVoltageCharge() {
float vBatCorrected = bpxBatteryHk.battVoltage.value - iBat * batteryInternalResistance; float vBatCorrected =
(bpxBatteryHk.battVoltage.value - iBat * batteryInternalResistance) * MILLIVOLT2VOLT;
uint8_t lookUpTableIdx = LOOK_UP_TABLE_MAX_IDX; uint8_t lookUpTableIdx = LOOK_UP_TABLE_MAX_IDX;
ReturnValue_t result = lookUpTableOcvIdxFinder(vBatCorrected, lookUpTableIdx); ReturnValue_t result = lookUpTableOcvIdxFinder(vBatCorrected, lookUpTableIdx);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
@ -267,7 +268,7 @@ float PowerController::linearInterpolation(float x, float x0, float x1, float y0
} }
ReturnValue_t PowerController::lookUpTableOcvIdxFinder(float voltage, uint8_t &idx) { ReturnValue_t PowerController::lookUpTableOcvIdxFinder(float voltage, uint8_t &idx) {
if (voltage >= lookUpTableOcv[1][100]) { if (voltage >= lookUpTableOcv[1][99]) {
triggerEvent(power::VOLTAGE_OUT_OF_BOUNDS, 0); triggerEvent(power::VOLTAGE_OUT_OF_BOUNDS, 0);
sif::error << "Power Controller::Voltage is too high" << std::endl; sif::error << "Power Controller::Voltage is too high" << std::endl;
return returnvalue::FAILED; return returnvalue::FAILED;

View File

@ -105,6 +105,8 @@ class PowerController : public ExtendedControllerBase, public ReceivesParameterM
float coulombCounterCharge = 0; // [mC] float coulombCounterCharge = 0; // [mC]
float coulombCounterChargeUpperThreshold = 0.0; // [mC] float coulombCounterChargeUpperThreshold = 0.0; // [mC]
static constexpr float MILLIVOLT2VOLT = 1e-3;
static constexpr int16_t INVALID_TOTAL_BATTERY_CURRENT = 0; static constexpr int16_t INVALID_TOTAL_BATTERY_CURRENT = 0;
static constexpr float INVALID_SOC = -1; static constexpr float INVALID_SOC = -1;