diff --git a/Software/src/battery/TESLA-MODEL-3-BATTERY.cpp b/Software/src/battery/TESLA-MODEL-3-BATTERY.cpp index e29f1c55..23760e20 100644 --- a/Software/src/battery/TESLA-MODEL-3-BATTERY.cpp +++ b/Software/src/battery/TESLA-MODEL-3-BATTERY.cpp @@ -196,9 +196,11 @@ void update_values_tesla_model_3_battery() { //This function maps all the value //The allowed charge power behaves strangely. We instead estimate this value if (SOC == 10000) { - max_target_charge_power = 0; //When battery is 100% full, set allowed charge W to 0 - } else { - max_target_charge_power = 15000; //Otherwise we can push 15kW into the pack! + max_target_charge_power = 0; // When battery is 100% full, set allowed charge W to 0 + } else if (SOC >= 9500 && SOC <= 9999) { // When battery is between 95-99.99%, ramp the value between Max<->0 + max_target_charge_power = MAXCHARGEPOWERALLOWED * (1 - (SOC - 9500) / 500); + } else { // Outside the specified SOC range, set the charge power to the maximum + max_target_charge_power = MAXCHARGEPOWERALLOWED; } stat_batt_power = (volts * amps); //TODO: check if scaling is OK diff --git a/Software/src/battery/TESLA-MODEL-3-BATTERY.h b/Software/src/battery/TESLA-MODEL-3-BATTERY.h index 1d9081d0..15d207c8 100644 --- a/Software/src/battery/TESLA-MODEL-3-BATTERY.h +++ b/Software/src/battery/TESLA-MODEL-3-BATTERY.h @@ -7,7 +7,8 @@ #define ABSOLUTE_MAX_VOLTAGE \ 4030 // 403.0V,if battery voltage goes over this, charging is not possible (goes into forced discharge) -#define ABSOLUTE_MIN_VOLTAGE 2450 // 245.0V if battery voltage goes under this, discharging further is disabled +#define ABSOLUTE_MIN_VOLTAGE 2450 // 245.0V if battery voltage goes under this, discharging further is disabled +#define MAXCHARGEPOWERALLOWED 15000 // 15000W we use a define since the value supplied by Tesla is always 0 // These parameters need to be mapped for the Inverter extern uint16_t SOC;