Skip to content

Commit

Permalink
Add ramped charge value for Tesla
Browse files Browse the repository at this point in the history
  • Loading branch information
dalathegreat committed Nov 19, 2023
1 parent 179b8ee commit 3aa3d8e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
8 changes: 5 additions & 3 deletions Software/src/battery/TESLA-MODEL-3-BATTERY.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion Software/src/battery/TESLA-MODEL-3-BATTERY.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 3aa3d8e

Please sign in to comment.