fixed voltage bugs
Some checks failed
EIVE/eive-obsw/pipeline/pr-main There was a failure building this commit

This commit is contained in:
Marius Eggert 2023-09-22 10:08:04 +02:00
parent 654d9b1536
commit 6b9e191988
2 changed files with 5 additions and 2 deletions

View File

@ -211,7 +211,8 @@ void PowerController::watchStateOfCharge() {
}
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;
ReturnValue_t result = lookUpTableOcvIdxFinder(vBatCorrected, lookUpTableIdx);
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) {
if (voltage >= lookUpTableOcv[1][100]) {
if (voltage >= lookUpTableOcv[1][99]) {
triggerEvent(power::VOLTAGE_OUT_OF_BOUNDS, 0);
sif::error << "Power Controller::Voltage is too high" << std::endl;
return returnvalue::FAILED;

View File

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