mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-06 03:50:13 +02:00
Merge pull request #199 from dalathegreat/feature/tesla-float-charge
Feature: Add top balancing for Tesla batteries
This commit is contained in:
commit
a2d493fe1a
2 changed files with 20 additions and 5 deletions
|
@ -156,9 +156,9 @@ static const char* hvilStatusState[] = {"NOT OK",
|
||||||
#define MIN_CELL_VOLTAGE_NCA_NCM 2950 //Battery is put into emergency stop if one cell goes below this value
|
#define MIN_CELL_VOLTAGE_NCA_NCM 2950 //Battery is put into emergency stop if one cell goes below this value
|
||||||
#define MAX_CELL_DEVIATION_NCA_NCM 500 //LED turns yellow on the board if mv delta exceeds this value
|
#define MAX_CELL_DEVIATION_NCA_NCM 500 //LED turns yellow on the board if mv delta exceeds this value
|
||||||
|
|
||||||
#define MAX_CELL_VOLTAGE_LFP 3520 //Battery is put into emergency stop if one cell goes over this value
|
#define MAX_CELL_VOLTAGE_LFP 3550 //Battery is put into emergency stop if one cell goes over this value
|
||||||
#define MIN_CELL_VOLTAGE_LFP 2800 //Battery is put into emergency stop if one cell goes below this value
|
#define MIN_CELL_VOLTAGE_LFP 2800 //Battery is put into emergency stop if one cell goes below this value
|
||||||
#define MAX_CELL_DEVIATION_LFP 150 //LED turns yellow on the board if mv delta exceeds this value
|
#define MAX_CELL_DEVIATION_LFP 200 //LED turns yellow on the board if mv delta exceeds this value
|
||||||
|
|
||||||
#define REASONABLE_ENERGYAMOUNT 20 //When the BMS stops making sense on some values, they are always <20
|
#define REASONABLE_ENERGYAMOUNT 20 //When the BMS stops making sense on some values, they are always <20
|
||||||
|
|
||||||
|
@ -200,10 +200,22 @@ void update_values_battery() { //This function maps all the values fetched via
|
||||||
}
|
}
|
||||||
|
|
||||||
//The allowed charge power behaves strangely. We instead estimate this value
|
//The allowed charge power behaves strangely. We instead estimate this value
|
||||||
if (system_scaled_SOC_pptt == 10000) { // When scaled SOC is 100%, set allowed charge power to 0
|
if (system_scaled_SOC_pptt == 10000) { // When scaled SOC is 100.00%, set allowed charge power to 0
|
||||||
system_max_charge_power_W = 0;
|
system_max_charge_power_W = 0;
|
||||||
} else if (soc_vi > 950) { // When real SOC is between 95-99.99%, ramp the value between Max<->0
|
} else if (soc_vi > 990) {
|
||||||
system_max_charge_power_W = MAXCHARGEPOWERALLOWED * (1 - (soc_vi - 950) / 50.0);
|
system_max_charge_power_W = FLOAT_MAX_POWER_W;
|
||||||
|
} else if (soc_vi > RAMPDOWN_SOC) { // When real SOC is between RAMPDOWN_SOC-99%, ramp the value between Max<->0
|
||||||
|
system_max_charge_power_W = MAXCHARGEPOWERALLOWED * (1 - (soc_vi - RAMPDOWN_SOC) / (1000.0 - RAMPDOWN_SOC));
|
||||||
|
//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 - FLOAT_START_MV)) {
|
||||||
|
system_max_charge_power_W = FLOAT_MAX_POWER_W;
|
||||||
|
}
|
||||||
|
} else { //NCM/A
|
||||||
|
if (cell_max_v > (MAX_CELL_VOLTAGE_NCA_NCM - FLOAT_START_MV)) {
|
||||||
|
system_max_charge_power_W = FLOAT_MAX_POWER_W;
|
||||||
|
}
|
||||||
|
}
|
||||||
} else { // No limits, max charging power allowed
|
} else { // No limits, max charging power allowed
|
||||||
system_max_charge_power_W = MAXCHARGEPOWERALLOWED;
|
system_max_charge_power_W = MAXCHARGEPOWERALLOWED;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,9 @@
|
||||||
|
|
||||||
#define BATTERY_SELECTED
|
#define BATTERY_SELECTED
|
||||||
|
|
||||||
|
#define RAMPDOWN_SOC 900 // 90.0 SOC% to start ramping down from max charge power towards 0 at 100.00%
|
||||||
|
#define FLOAT_MAX_POWER_W 200 // W, what power to allow for top balancing battery
|
||||||
|
#define FLOAT_START_MV 20 // mV, how many mV under overvoltage to start float charging
|
||||||
#define MAXCHARGEPOWERALLOWED 15000 // 15000W we use a define since the value supplied by Tesla is always 0
|
#define MAXCHARGEPOWERALLOWED 15000 // 15000W we use a define since the value supplied by Tesla is always 0
|
||||||
#define MAXDISCHARGEPOWERALLOWED \
|
#define MAXDISCHARGEPOWERALLOWED \
|
||||||
60000 // 60000W we need to cap this value to max 60kW, most inverters overflow otherwise
|
60000 // 60000W we need to cap this value to max 60kW, most inverters overflow otherwise
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue