Fix ramp function overflow

This commit is contained in:
Daniel 2024-02-25 12:45:23 +02:00
parent ae7bfa2d36
commit 2d83c9c029

View file

@ -202,8 +202,11 @@ void update_values_battery() { //This function maps all the values fetched via
//The allowed charge power behaves strangely. We instead estimate this value
if (system_scaled_SOC_pptt == 10000) { // When scaled SOC is 100.00%, set allowed charge power to 0
system_max_charge_power_W = 0;
} else if (soc_vi > RAMPDOWNSOC) { // When real SOC is between RAMPDOWNSOC-99.99%, ramp the value between Max<->0
system_max_charge_power_W = MAXCHARGEPOWERALLOWED * (1 - (soc_vi - RAMPDOWNSOC) / 50.0);
}
if (soc_vi > 990) {
system_max_charge_power_W = FLOATPOWERMAX;
} else if (soc_vi > RAMPDOWNSOC) { // When real SOC is between RAMPDOWNSOC-99%, ramp the value between Max<->0
system_max_charge_power_W = MAXCHARGEPOWERALLOWED * (1 - (soc_vi - RAMPDOWNSOC) / (1000.0 - RAMPDOWNSOC));
//If the cellvoltages start to reach overvoltage, only allow a small amount of power in
if (system_LFP_Chemistry) {
if (cell_max_v > (MAX_CELL_VOLTAGE_LFP - MILLIVOLTFLOAT)) {