From ae7bfa2d3699127c5a63453298ba0d1d4c0dd1aa Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 21 Feb 2024 21:57:04 +0200 Subject: [PATCH 01/31] Add float power algoritm for tesla --- Software/src/battery/TESLA-MODEL-3-BATTERY.cpp | 16 +++++++++++++--- Software/src/battery/TESLA-MODEL-3-BATTERY.h | 3 +++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Software/src/battery/TESLA-MODEL-3-BATTERY.cpp b/Software/src/battery/TESLA-MODEL-3-BATTERY.cpp index fc07d99d..4fde48fb 100644 --- a/Software/src/battery/TESLA-MODEL-3-BATTERY.cpp +++ b/Software/src/battery/TESLA-MODEL-3-BATTERY.cpp @@ -200,10 +200,20 @@ 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%, 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; - } else if (soc_vi > 950) { // When real SOC is between 95-99.99%, ramp the value between Max<->0 - system_max_charge_power_W = MAXCHARGEPOWERALLOWED * (1 - (soc_vi - 950) / 50.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 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)) { + system_max_charge_power_W = FLOATPOWERMAX; + } + } else { //NCM/A + if (cell_max_v > (MAX_CELL_VOLTAGE_NCA_NCM - MILLIVOLTFLOAT)) { + system_max_charge_power_W = FLOATPOWERMAX; + } + } } else { // No limits, max charging power allowed system_max_charge_power_W = MAXCHARGEPOWERALLOWED; } diff --git a/Software/src/battery/TESLA-MODEL-3-BATTERY.h b/Software/src/battery/TESLA-MODEL-3-BATTERY.h index 86e68f94..6ed383b9 100644 --- a/Software/src/battery/TESLA-MODEL-3-BATTERY.h +++ b/Software/src/battery/TESLA-MODEL-3-BATTERY.h @@ -7,6 +7,9 @@ #define BATTERY_SELECTED +#define RAMPDOWNSOC 900 // 90.0 SOC% to start ramping down from max charge power towards 0 at 100.00% +#define FLOATPOWERMAX 200 // W, what power to allow for top balancing battery +#define MILLIVOLTFLOAT 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 MAXDISCHARGEPOWERALLOWED \ 60000 // 60000W we need to cap this value to max 60kW, most inverters overflow otherwise From 25abe9f6b790e7b42347ad393aedf9ec61df3b92 Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 21 Feb 2024 22:33:29 +0200 Subject: [PATCH 02/31] Fix u32 Wh values getting corrupted --- Software/src/battery/SERIAL-LINK-RECEIVER-FROM-BATTERY.cpp | 4 ++-- Software/src/inverter/SERIAL-LINK-TRANSMITTER-INVERTER.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Software/src/battery/SERIAL-LINK-RECEIVER-FROM-BATTERY.cpp b/Software/src/battery/SERIAL-LINK-RECEIVER-FROM-BATTERY.cpp index 8e6e5dc7..49c5b0b6 100644 --- a/Software/src/battery/SERIAL-LINK-RECEIVER-FROM-BATTERY.cpp +++ b/Software/src/battery/SERIAL-LINK-RECEIVER-FROM-BATTERY.cpp @@ -32,8 +32,8 @@ void __getData() { system_SOH_pptt = (uint16_t)dataLinkReceive.getReceivedData(1); system_battery_voltage_dV = (uint16_t)dataLinkReceive.getReceivedData(2); system_battery_current_dA = (int16_t)dataLinkReceive.getReceivedData(3); - system_capacity_Wh = (uint32_t)dataLinkReceive.getReceivedData(4); - system_remaining_capacity_Wh = (uint32_t)dataLinkReceive.getReceivedData(5); + system_capacity_Wh = (uint32_t)(dataLinkReceive.getReceivedData(4) * 10); //add back missing decimal + system_remaining_capacity_Wh = (uint32_t)(dataLinkReceive.getReceivedData(5) * 10); //add back missing decimal system_max_discharge_power_W = (uint16_t)dataLinkReceive.getReceivedData(6); system_max_charge_power_W = (uint16_t)dataLinkReceive.getReceivedData(7); uint16_t _system_bms_status = (uint16_t)dataLinkReceive.getReceivedData(8); diff --git a/Software/src/inverter/SERIAL-LINK-TRANSMITTER-INVERTER.cpp b/Software/src/inverter/SERIAL-LINK-TRANSMITTER-INVERTER.cpp index fba7d84e..f673783b 100644 --- a/Software/src/inverter/SERIAL-LINK-TRANSMITTER-INVERTER.cpp +++ b/Software/src/inverter/SERIAL-LINK-TRANSMITTER-INVERTER.cpp @@ -133,8 +133,8 @@ void manageSerialLinkTransmitter() { dataLinkTransmit.updateData(1, system_SOH_pptt); dataLinkTransmit.updateData(2, system_battery_voltage_dV); dataLinkTransmit.updateData(3, system_battery_current_dA); - dataLinkTransmit.updateData(4, system_capacity_Wh); - dataLinkTransmit.updateData(5, system_remaining_capacity_Wh); + dataLinkTransmit.updateData(4, system_capacity_Wh / 10); //u32, remove .0 to fit 16bit + dataLinkTransmit.updateData(5, system_remaining_capacity_Wh / 10); //u32, remove .0 to fit 16bit dataLinkTransmit.updateData(6, system_max_discharge_power_W); dataLinkTransmit.updateData(7, system_max_charge_power_W); dataLinkTransmit.updateData(8, system_bms_status); From 2f6f166280b69520c0a76bb34bbd2c4500e4c59b Mon Sep 17 00:00:00 2001 From: Brett Christensen Date: Thu, 22 Feb 2024 08:49:16 +1100 Subject: [PATCH 03/31] Update mqtt.cpp fix SOC real in mqtt --- Software/src/devboard/mqtt/mqtt.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Software/src/devboard/mqtt/mqtt.cpp b/Software/src/devboard/mqtt/mqtt.cpp index 89a37123..de098edb 100644 --- a/Software/src/devboard/mqtt/mqtt.cpp +++ b/Software/src/devboard/mqtt/mqtt.cpp @@ -101,7 +101,8 @@ struct SensorConfig { }; SensorConfig sensorConfigs[] = { - {"SOC", "Battery Emulator SOC", "{{ value_json.SOC }}", "%", "battery"}, + {"SOC", "Battery Emulator SOC (scaled)", "{{ value_json.SOC }}", "%", "battery"}, + {"SOC_real", "Battery Emulator SOC (real)", "{{ value_json.SOC_real }}", "%", "battery"}, {"state_of_health", "Battery Emulator State Of Health", "{{ value_json.state_of_health }}", "%", "battery"}, {"temperature_min", "Battery Emulator Temperature Min", "{{ value_json.temperature_min }}", "°C", "temperature"}, {"temperature_max", "Battery Emulator Temperature Max", "{{ value_json.temperature_max }}", "°C", "temperature"}, From 2d83c9c029843fb03ea63ab957dbc96c49d3b8d2 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sun, 25 Feb 2024 12:45:23 +0200 Subject: [PATCH 04/31] Fix ramp function overflow --- Software/src/battery/TESLA-MODEL-3-BATTERY.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Software/src/battery/TESLA-MODEL-3-BATTERY.cpp b/Software/src/battery/TESLA-MODEL-3-BATTERY.cpp index 4fde48fb..e3541261 100644 --- a/Software/src/battery/TESLA-MODEL-3-BATTERY.cpp +++ b/Software/src/battery/TESLA-MODEL-3-BATTERY.cpp @@ -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)) { From 99a85e8c16e08e85b08034f571fb5f484224ee63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20=C3=96ster?= Date: Sun, 25 Feb 2024 13:11:23 +0200 Subject: [PATCH 05/31] Increase cellvoltagearray for 800V --- Software/Software.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Software/Software.ino b/Software/Software.ino index d238f3aa..f8d3b065 100644 --- a/Software/Software.ino +++ b/Software/Software.ino @@ -71,7 +71,7 @@ uint16_t system_max_discharge_power_W = 0; //Watts, 0 to 65535 uint16_t system_max_charge_power_W = 4312; //Watts, 0 to 65535 uint16_t system_cell_max_voltage_mV = 3700; //mV, 0-5000 , Stores the highest cell millivolt value uint16_t system_cell_min_voltage_mV = 3700; //mV, 0-5000, Stores the minimum cell millivolt value -uint16_t system_cellvoltages_mV[120]; //Array with all cell voltages in mV. Oversized to accomodate all setups +uint16_t system_cellvoltages_mV[192]; //Array with all cell voltages in mV. Oversized to accomodate all setups uint8_t system_bms_status = ACTIVE; //ACTIVE - [0..5]<>[STANDBY,INACTIVE,DARKSTART,ACTIVE,FAULT,UPDATING] uint8_t system_number_of_cells = 0; //Total number of cell voltages, set by each battery bool system_LFP_Chemistry = false; //Set to true or false depending on cell chemistry From 97e35b2478e745fb80fc219767e6906f9a430a68 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sun, 25 Feb 2024 13:16:58 +0200 Subject: [PATCH 06/31] Increase all references to 192 --- Software/src/battery/BMW-I3-BATTERY.h | 2 +- Software/src/battery/CHADEMO-BATTERY.h | 2 +- Software/src/battery/IMIEV-CZERO-ION-BATTERY.h | 2 +- Software/src/battery/KIA-HYUNDAI-64-BATTERY.h | 2 +- Software/src/battery/NISSAN-LEAF-BATTERY.h | 2 +- Software/src/battery/RENAULT-KANGOO-BATTERY.h | 2 +- Software/src/battery/RENAULT-ZOE-BATTERY.h | 2 +- Software/src/battery/SANTA-FE-PHEV-BATTERY.h | 2 +- Software/src/battery/TESLA-MODEL-3-BATTERY.h | 2 +- Software/src/battery/TEST-FAKE-BATTERY.h | 2 +- Software/src/devboard/mqtt/mqtt.h | 2 +- Software/src/devboard/webserver/cellmonitor_html.cpp | 2 +- Software/src/devboard/webserver/cellmonitor_html.h | 2 +- Software/src/devboard/webserver/webserver.h | 2 +- Software/src/inverter/BYD-CAN.h | 2 +- Software/src/inverter/LUNA2000-MODBUS.h | 2 +- Software/src/inverter/PYLON-CAN.h | 2 +- Software/src/inverter/SMA-CAN.h | 2 +- Software/src/inverter/SMA-TRIPOWER-CAN.h | 2 +- Software/src/inverter/SOFAR-CAN.h | 2 +- Software/src/inverter/SOLAX-CAN.h | 2 +- 21 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Software/src/battery/BMW-I3-BATTERY.h b/Software/src/battery/BMW-I3-BATTERY.h index 63203187..c855da90 100644 --- a/Software/src/battery/BMW-I3-BATTERY.h +++ b/Software/src/battery/BMW-I3-BATTERY.h @@ -24,7 +24,7 @@ extern uint16_t system_max_discharge_power_W; //W, 0-65000 extern uint16_t system_max_charge_power_W; //W, 0-65000 extern uint16_t system_cell_max_voltage_mV; //mV, 0-5000, Stores the highest cell millivolt value extern uint16_t system_cell_min_voltage_mV; //mV, 0-5000, Stores the minimum cell millivolt value -extern uint16_t system_cellvoltages_mV[120]; //Array with all cell voltages in mV +extern uint16_t system_cellvoltages_mV[192]; //Array with all cell voltages in mV extern uint8_t system_number_of_cells; //Total number of cell voltages, set by each battery extern uint8_t system_bms_status; //Enum 0-5 extern bool batteryAllowsContactorClosing; //Bool, true/false diff --git a/Software/src/battery/CHADEMO-BATTERY.h b/Software/src/battery/CHADEMO-BATTERY.h index 7675ad30..06ddecba 100644 --- a/Software/src/battery/CHADEMO-BATTERY.h +++ b/Software/src/battery/CHADEMO-BATTERY.h @@ -24,7 +24,7 @@ extern uint16_t system_max_discharge_power_W; //W, 0-65000 extern uint16_t system_max_charge_power_W; //W, 0-65000 extern uint16_t system_cell_max_voltage_mV; //mV, 0-5000, Stores the highest cell millivolt value extern uint16_t system_cell_min_voltage_mV; //mV, 0-5000, Stores the minimum cell millivolt value -extern uint16_t system_cellvoltages_mV[120]; //Array with all cell voltages in mV +extern uint16_t system_cellvoltages_mV[192]; //Array with all cell voltages in mV extern uint8_t system_number_of_cells; //Total number of cell voltages, set by each battery extern uint8_t system_bms_status; //Enum 0-5 extern bool batteryAllowsContactorClosing; //Bool, true/false diff --git a/Software/src/battery/IMIEV-CZERO-ION-BATTERY.h b/Software/src/battery/IMIEV-CZERO-ION-BATTERY.h index c035a208..6bd3cd56 100644 --- a/Software/src/battery/IMIEV-CZERO-ION-BATTERY.h +++ b/Software/src/battery/IMIEV-CZERO-ION-BATTERY.h @@ -24,7 +24,7 @@ extern uint16_t system_max_discharge_power_W; //W, 0-65000 extern uint16_t system_max_charge_power_W; //W, 0-65000 extern uint16_t system_cell_max_voltage_mV; //mV, 0-5000, Stores the highest cell millivolt value extern uint16_t system_cell_min_voltage_mV; //mV, 0-5000, Stores the minimum cell millivolt value -extern uint16_t system_cellvoltages_mV[120]; //Array with all cell voltages in mV +extern uint16_t system_cellvoltages_mV[192]; //Array with all cell voltages in mV extern uint8_t system_number_of_cells; //Total number of cell voltages, set by each battery extern uint8_t system_bms_status; //Enum 0-5 extern bool batteryAllowsContactorClosing; //Bool, true/false diff --git a/Software/src/battery/KIA-HYUNDAI-64-BATTERY.h b/Software/src/battery/KIA-HYUNDAI-64-BATTERY.h index 0029b0f0..e00c4abf 100644 --- a/Software/src/battery/KIA-HYUNDAI-64-BATTERY.h +++ b/Software/src/battery/KIA-HYUNDAI-64-BATTERY.h @@ -27,7 +27,7 @@ extern uint16_t system_max_discharge_power_W; //W, 0-65000 extern uint16_t system_max_charge_power_W; //W, 0-65000 extern uint16_t system_cell_max_voltage_mV; //mV, 0-5000, Stores the highest cell millivolt value extern uint16_t system_cell_min_voltage_mV; //mV, 0-5000, Stores the minimum cell millivolt value -extern uint16_t system_cellvoltages_mV[120]; //Array with all cell voltages in mV +extern uint16_t system_cellvoltages_mV[192]; //Array with all cell voltages in mV extern uint8_t system_number_of_cells; //Total number of cell voltages, set by each battery extern uint8_t system_bms_status; //Enum 0-5 extern bool batteryAllowsContactorClosing; //Bool, true/false diff --git a/Software/src/battery/NISSAN-LEAF-BATTERY.h b/Software/src/battery/NISSAN-LEAF-BATTERY.h index d437ed73..7ae28a3f 100644 --- a/Software/src/battery/NISSAN-LEAF-BATTERY.h +++ b/Software/src/battery/NISSAN-LEAF-BATTERY.h @@ -24,7 +24,7 @@ extern uint16_t system_max_discharge_power_W; //W, 0-65000 extern uint16_t system_max_charge_power_W; //W, 0-65000 extern uint16_t system_cell_max_voltage_mV; //mV, 0-5000, Stores the highest cell millivolt value extern uint16_t system_cell_min_voltage_mV; //mV, 0-5000, Stores the minimum cell millivolt value -extern uint16_t system_cellvoltages_mV[120]; //Array with all cell voltages in mV +extern uint16_t system_cellvoltages_mV[192]; //Array with all cell voltages in mV extern uint8_t system_number_of_cells; //Total number of cell voltages, set by each battery extern uint8_t system_bms_status; //Enum 0-5 extern bool batteryAllowsContactorClosing; //Bool, true/false diff --git a/Software/src/battery/RENAULT-KANGOO-BATTERY.h b/Software/src/battery/RENAULT-KANGOO-BATTERY.h index 69e3f207..7c347d8a 100644 --- a/Software/src/battery/RENAULT-KANGOO-BATTERY.h +++ b/Software/src/battery/RENAULT-KANGOO-BATTERY.h @@ -30,7 +30,7 @@ extern uint16_t system_max_discharge_power_W; //W, 0-65000 extern uint16_t system_max_charge_power_W; //W, 0-65000 extern uint16_t system_cell_max_voltage_mV; //mV, 0-5000, Stores the highest cell millivolt value extern uint16_t system_cell_min_voltage_mV; //mV, 0-5000, Stores the minimum cell millivolt value -extern uint16_t system_cellvoltages_mV[120]; //Array with all cell voltages in mV +extern uint16_t system_cellvoltages_mV[192]; //Array with all cell voltages in mV extern uint8_t system_number_of_cells; //Total number of cell voltages, set by each battery extern uint8_t system_bms_status; //Enum 0-5 extern bool batteryAllowsContactorClosing; //Bool, true/false diff --git a/Software/src/battery/RENAULT-ZOE-BATTERY.h b/Software/src/battery/RENAULT-ZOE-BATTERY.h index 853e9b42..91bcd7d6 100644 --- a/Software/src/battery/RENAULT-ZOE-BATTERY.h +++ b/Software/src/battery/RENAULT-ZOE-BATTERY.h @@ -30,7 +30,7 @@ extern uint16_t system_max_discharge_power_W; //W, 0-65000 extern uint16_t system_max_charge_power_W; //W, 0-65000 extern uint16_t system_cell_max_voltage_mV; //mV, 0-5000, Stores the highest cell millivolt value extern uint16_t system_cell_min_voltage_mV; //mV, 0-5000, Stores the minimum cell millivolt value -extern uint16_t system_cellvoltages_mV[120]; //Array with all cell voltages in mV +extern uint16_t system_cellvoltages_mV[192]; //Array with all cell voltages in mV extern uint8_t system_number_of_cells; //Total number of cell voltages, set by each battery extern uint8_t system_bms_status; //Enum 0-5 extern bool batteryAllowsContactorClosing; //Bool, true/false diff --git a/Software/src/battery/SANTA-FE-PHEV-BATTERY.h b/Software/src/battery/SANTA-FE-PHEV-BATTERY.h index da01cda1..127ca90d 100644 --- a/Software/src/battery/SANTA-FE-PHEV-BATTERY.h +++ b/Software/src/battery/SANTA-FE-PHEV-BATTERY.h @@ -24,7 +24,7 @@ extern uint16_t system_max_discharge_power_W; //W, 0-65000 extern uint16_t system_max_charge_power_W; //W, 0-65000 extern uint16_t system_cell_max_voltage_mV; //mV, 0-5000, Stores the highest cell millivolt value extern uint16_t system_cell_min_voltage_mV; //mV, 0-5000, Stores the minimum cell millivolt value -extern uint16_t system_cellvoltages_mV[120]; //Array with all cell voltages in mV +extern uint16_t system_cellvoltages_mV[192]; //Array with all cell voltages in mV extern uint8_t system_number_of_cells; //Total number of cell voltages, set by each battery extern uint8_t system_bms_status; //Enum 0-5 extern bool batteryAllowsContactorClosing; //Bool, true/false diff --git a/Software/src/battery/TESLA-MODEL-3-BATTERY.h b/Software/src/battery/TESLA-MODEL-3-BATTERY.h index 86e68f94..51481057 100644 --- a/Software/src/battery/TESLA-MODEL-3-BATTERY.h +++ b/Software/src/battery/TESLA-MODEL-3-BATTERY.h @@ -28,7 +28,7 @@ extern uint16_t system_max_discharge_power_W; //W, 0-65000 extern uint16_t system_max_charge_power_W; //W, 0-65000 extern uint16_t system_cell_max_voltage_mV; //mV, 0-5000, Stores the highest cell millivolt value extern uint16_t system_cell_min_voltage_mV; //mV, 0-5000, Stores the minimum cell millivolt value -extern uint16_t system_cellvoltages_mV[120]; //Array with all cell voltages in mV +extern uint16_t system_cellvoltages_mV[192]; //Array with all cell voltages in mV extern uint8_t system_number_of_cells; //Total number of cell voltages, set by each battery extern uint8_t system_bms_status; //Enum 0-5 extern bool batteryAllowsContactorClosing; //Bool, 1=true, 0=false diff --git a/Software/src/battery/TEST-FAKE-BATTERY.h b/Software/src/battery/TEST-FAKE-BATTERY.h index 70c5b642..549ea92f 100644 --- a/Software/src/battery/TEST-FAKE-BATTERY.h +++ b/Software/src/battery/TEST-FAKE-BATTERY.h @@ -24,7 +24,7 @@ extern uint16_t system_max_discharge_power_W; //W, 0-65000 extern uint16_t system_max_charge_power_W; //W, 0-65000 extern uint16_t system_cell_max_voltage_mV; //mV, 0-5000, Stores the highest cell millivolt value extern uint16_t system_cell_min_voltage_mV; //mV, 0-5000, Stores the minimum cell millivolt value -extern uint16_t system_cellvoltages_mV[120]; //Array with all cell voltages in mV +extern uint16_t system_cellvoltages_mV[192]; //Array with all cell voltages in mV extern uint8_t system_number_of_cells; //Total number of cell voltages, set by each battery extern uint8_t system_bms_status; //Enum 0-5 extern bool batteryAllowsContactorClosing; //Bool, true/false diff --git a/Software/src/devboard/mqtt/mqtt.h b/Software/src/devboard/mqtt/mqtt.h index 4eeb307c..60d0924f 100644 --- a/Software/src/devboard/mqtt/mqtt.h +++ b/Software/src/devboard/mqtt/mqtt.h @@ -51,7 +51,7 @@ extern uint16_t system_real_SOC_pptt; //SOC%, 0-100.00 (0-10000) extern uint16_t system_SOH_pptt; //SOH%, 0-100.00 (0-10000) extern uint16_t system_cell_max_voltage_mV; //mV, 0-5000 , Stores the highest cell millivolt value extern uint16_t system_cell_min_voltage_mV; //mV, 0-5000, Stores the minimum cell millivolt value -extern uint16_t system_cellvoltages_mV[120]; //Array with all cell voltages in mV +extern uint16_t system_cellvoltages_mV[192]; //Array with all cell voltages in mV extern uint8_t system_number_of_cells; //Total number of cell voltages, set by each battery extern const char* mqtt_user; diff --git a/Software/src/devboard/webserver/cellmonitor_html.cpp b/Software/src/devboard/webserver/cellmonitor_html.cpp index 627fef3d..32c0ab41 100644 --- a/Software/src/devboard/webserver/cellmonitor_html.cpp +++ b/Software/src/devboard/webserver/cellmonitor_html.cpp @@ -26,7 +26,7 @@ String cellmonitor_processor(const String& var) { // Visualize the populated cells in forward order using flexbox with conditional text color content += "
"; - for (int i = 0; i < 120; ++i) { + for (int i = 0; i < 192; ++i) { // Skip empty values if (system_cellvoltages_mV[i] == 0) { continue; diff --git a/Software/src/devboard/webserver/cellmonitor_html.h b/Software/src/devboard/webserver/cellmonitor_html.h index 17b81b69..9a1a0bd7 100644 --- a/Software/src/devboard/webserver/cellmonitor_html.h +++ b/Software/src/devboard/webserver/cellmonitor_html.h @@ -6,7 +6,7 @@ extern uint16_t system_cell_max_voltage_mV; //mV, 0-5000, Stores the highest cell millivolt value extern uint16_t system_cell_min_voltage_mV; //mV, 0-5000, Stores the minimum cell millivolt value -extern uint16_t system_cellvoltages_mV[120]; //Array with all cell voltages in mV +extern uint16_t system_cellvoltages_mV[192]; //Array with all cell voltages in mV /** * @brief Replaces placeholder with content section in web page diff --git a/Software/src/devboard/webserver/webserver.h b/Software/src/devboard/webserver/webserver.h index 1ccbe686..84735e46 100644 --- a/Software/src/devboard/webserver/webserver.h +++ b/Software/src/devboard/webserver/webserver.h @@ -33,7 +33,7 @@ extern uint16_t system_max_discharge_power_W; //W, 0-65000 extern uint16_t system_max_charge_power_W; //W, 0-65000 extern uint16_t system_cell_max_voltage_mV; //mV, 0-5000 , Stores the highest cell millivolt value extern uint16_t system_cell_min_voltage_mV; //mV, 0-5000, Stores the minimum cell millivolt value -extern uint16_t system_cellvoltages_mV[120]; //Array with all cell voltages in mV +extern uint16_t system_cellvoltages_mV[192]; //Array with all cell voltages in mV extern uint8_t system_number_of_cells; //Total number of cell voltages, set by each battery extern uint8_t system_bms_status; //Enum 0-5 extern uint8_t LEDcolor; //Enum, 0-10 diff --git a/Software/src/inverter/BYD-CAN.h b/Software/src/inverter/BYD-CAN.h index 521c2b52..30264bab 100644 --- a/Software/src/inverter/BYD-CAN.h +++ b/Software/src/inverter/BYD-CAN.h @@ -22,7 +22,7 @@ extern uint16_t system_max_discharge_power_W; //W, 0-65000 extern uint16_t system_max_charge_power_W; //W, 0-65000 extern uint16_t system_cell_max_voltage_mV; //mV, 0-5000, Stores the highest cell millivolt value extern uint16_t system_cell_min_voltage_mV; //mV, 0-5000, Stores the minimum cell millivolt value -extern uint16_t system_cellvoltages_mV[120]; //Array with all cell voltages in mV +extern uint16_t system_cellvoltages_mV[192]; //Array with all cell voltages in mV extern uint8_t system_number_of_cells; //Total number of cell voltages, set by each battery extern uint8_t system_bms_status; //Enum 0-5 extern bool batteryAllowsContactorClosing; //Bool, true/false diff --git a/Software/src/inverter/LUNA2000-MODBUS.h b/Software/src/inverter/LUNA2000-MODBUS.h index 4d2d4bf8..dc856556 100644 --- a/Software/src/inverter/LUNA2000-MODBUS.h +++ b/Software/src/inverter/LUNA2000-MODBUS.h @@ -22,7 +22,7 @@ extern uint16_t system_max_discharge_power_W; //W, 0-65000 extern uint16_t system_max_charge_power_W; //W, 0-65000 extern uint16_t system_cell_max_voltage_mV; //mV, 0-5000, Stores the highest cell millivolt value extern uint16_t system_cell_min_voltage_mV; //mV, 0-5000, Stores the minimum cell millivolt value -extern uint16_t system_cellvoltages_mV[120]; //Array with all cell voltages in mV +extern uint16_t system_cellvoltages_mV[192]; //Array with all cell voltages in mV extern uint8_t system_number_of_cells; //Total number of cell voltages, set by each battery extern uint8_t system_bms_status; //Enum 0-5 extern bool batteryAllowsContactorClosing; //Bool, true/false diff --git a/Software/src/inverter/PYLON-CAN.h b/Software/src/inverter/PYLON-CAN.h index 85beeba8..b8fcfcb4 100644 --- a/Software/src/inverter/PYLON-CAN.h +++ b/Software/src/inverter/PYLON-CAN.h @@ -21,7 +21,7 @@ extern uint16_t system_max_discharge_power_W; //W, 0-65000 extern uint16_t system_max_charge_power_W; //W, 0-65000 extern uint16_t system_cell_max_voltage_mV; //mV, 0-5000, Stores the highest cell millivolt value extern uint16_t system_cell_min_voltage_mV; //mV, 0-5000, Stores the minimum cell millivolt value -extern uint16_t system_cellvoltages_mV[120]; //Array with all cell voltages in mV +extern uint16_t system_cellvoltages_mV[192]; //Array with all cell voltages in mV extern uint8_t system_number_of_cells; //Total number of cell voltages, set by each battery extern uint8_t system_bms_status; //Enum 0-5 extern bool batteryAllowsContactorClosing; //Bool, true/false diff --git a/Software/src/inverter/SMA-CAN.h b/Software/src/inverter/SMA-CAN.h index bb7c7599..0bc85601 100644 --- a/Software/src/inverter/SMA-CAN.h +++ b/Software/src/inverter/SMA-CAN.h @@ -21,7 +21,7 @@ extern uint16_t system_max_discharge_power_W; //W, 0-65000 extern uint16_t system_max_charge_power_W; //W, 0-65000 extern uint16_t system_cell_max_voltage_mV; //mV, 0-5000, Stores the highest cell millivolt value extern uint16_t system_cell_min_voltage_mV; //mV, 0-5000, Stores the minimum cell millivolt value -extern uint16_t system_cellvoltages_mV[120]; //Array with all cell voltages in mV +extern uint16_t system_cellvoltages_mV[192]; //Array with all cell voltages in mV extern uint8_t system_number_of_cells; //Total number of cell voltages, set by each battery extern uint8_t system_bms_status; //Enum 0-5 extern bool batteryAllowsContactorClosing; //Bool, true/false diff --git a/Software/src/inverter/SMA-TRIPOWER-CAN.h b/Software/src/inverter/SMA-TRIPOWER-CAN.h index 51b94171..2b1755c1 100644 --- a/Software/src/inverter/SMA-TRIPOWER-CAN.h +++ b/Software/src/inverter/SMA-TRIPOWER-CAN.h @@ -21,7 +21,7 @@ extern uint16_t system_max_discharge_power_W; //W, 0-65000 extern uint16_t system_max_charge_power_W; //W, 0-65000 extern uint16_t system_cell_max_voltage_mV; //mV, 0-5000, Stores the highest cell millivolt value extern uint16_t system_cell_min_voltage_mV; //mV, 0-5000, Stores the minimum cell millivolt value -extern uint16_t system_cellvoltages_mV[120]; //Array with all cell voltages in mV +extern uint16_t system_cellvoltages_mV[192]; //Array with all cell voltages in mV extern uint8_t system_number_of_cells; //Total number of cell voltages, set by each battery extern uint8_t system_bms_status; //Enum 0-5 extern bool batteryAllowsContactorClosing; //Bool, true/false diff --git a/Software/src/inverter/SOFAR-CAN.h b/Software/src/inverter/SOFAR-CAN.h index 1575491e..e974e7b1 100644 --- a/Software/src/inverter/SOFAR-CAN.h +++ b/Software/src/inverter/SOFAR-CAN.h @@ -22,7 +22,7 @@ extern uint16_t system_max_discharge_power_W; //W, 0-65000 extern uint16_t system_max_charge_power_W; //W, 0-65000 extern uint16_t system_cell_max_voltage_mV; //mV, 0-5000, Stores the highest cell millivolt value extern uint16_t system_cell_min_voltage_mV; //mV, 0-5000, Stores the minimum cell millivolt value -extern uint16_t system_cellvoltages_mV[120]; //Array with all cell voltages in mV +extern uint16_t system_cellvoltages_mV[192]; //Array with all cell voltages in mV extern uint8_t system_number_of_cells; //Total number of cell voltages, set by each battery extern uint8_t system_bms_status; //Enum 0-5 extern bool batteryAllowsContactorClosing; //Bool, true/false diff --git a/Software/src/inverter/SOLAX-CAN.h b/Software/src/inverter/SOLAX-CAN.h index b0237d37..9727d153 100644 --- a/Software/src/inverter/SOLAX-CAN.h +++ b/Software/src/inverter/SOLAX-CAN.h @@ -24,7 +24,7 @@ extern uint16_t system_max_discharge_power_W; //W, 0-65000 extern uint16_t system_max_charge_power_W; //W, 0-65000 extern uint16_t system_cell_max_voltage_mV; //mV, 0-5000, Stores the highest cell millivolt value extern uint16_t system_cell_min_voltage_mV; //mV, 0-5000, Stores the minimum cell millivolt value -extern uint16_t system_cellvoltages_mV[120]; //Array with all cell voltages in mV +extern uint16_t system_cellvoltages_mV[192]; //Array with all cell voltages in mV extern uint8_t system_number_of_cells; //Total number of cell voltages, set by each battery extern uint8_t system_bms_status; //Enum 0-5 extern bool batteryAllowsContactorClosing; //Bool, true/false From 5d3cc341c8da1c5da011d3e5907e9a9d0612fa04 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sun, 25 Feb 2024 22:52:17 +0200 Subject: [PATCH 07/31] Make cellarray definition --- Software/Software.ino | 8 ++-- Software/src/battery/BMW-I3-BATTERY.h | 40 ++++++++-------- Software/src/battery/CHADEMO-BATTERY.h | 40 ++++++++-------- .../src/battery/IMIEV-CZERO-ION-BATTERY.h | 42 ++++++++--------- Software/src/battery/KIA-HYUNDAI-64-BATTERY.h | 42 ++++++++--------- Software/src/battery/NISSAN-LEAF-BATTERY.h | 40 ++++++++-------- Software/src/battery/RENAULT-KANGOO-BATTERY.h | 42 ++++++++--------- Software/src/battery/RENAULT-ZOE-BATTERY.h | 42 ++++++++--------- Software/src/battery/SANTA-FE-PHEV-BATTERY.h | 40 ++++++++-------- Software/src/battery/TESLA-MODEL-3-BATTERY.h | 44 +++++++++--------- Software/src/battery/TEST-FAKE-BATTERY.h | 42 ++++++++--------- Software/src/devboard/config.h | 3 ++ Software/src/devboard/mqtt/mqtt.h | 24 +++++----- .../devboard/webserver/cellmonitor_html.cpp | 2 +- .../src/devboard/webserver/cellmonitor_html.h | 6 +-- Software/src/devboard/webserver/webserver.h | 46 +++++++++---------- Software/src/inverter/BYD-CAN.h | 42 ++++++++--------- Software/src/inverter/LUNA2000-MODBUS.h | 42 ++++++++--------- Software/src/inverter/PYLON-CAN.h | 42 ++++++++--------- Software/src/inverter/SMA-CAN.h | 42 ++++++++--------- Software/src/inverter/SMA-TRIPOWER-CAN.h | 42 ++++++++--------- Software/src/inverter/SOFAR-CAN.h | 42 ++++++++--------- Software/src/inverter/SOLAX-CAN.h | 42 ++++++++--------- 23 files changed, 400 insertions(+), 397 deletions(-) diff --git a/Software/Software.ino b/Software/Software.ino index f8d3b065..881aaf71 100644 --- a/Software/Software.ino +++ b/Software/Software.ino @@ -71,10 +71,10 @@ uint16_t system_max_discharge_power_W = 0; //Watts, 0 to 65535 uint16_t system_max_charge_power_W = 4312; //Watts, 0 to 65535 uint16_t system_cell_max_voltage_mV = 3700; //mV, 0-5000 , Stores the highest cell millivolt value uint16_t system_cell_min_voltage_mV = 3700; //mV, 0-5000, Stores the minimum cell millivolt value -uint16_t system_cellvoltages_mV[192]; //Array with all cell voltages in mV. Oversized to accomodate all setups -uint8_t system_bms_status = ACTIVE; //ACTIVE - [0..5]<>[STANDBY,INACTIVE,DARKSTART,ACTIVE,FAULT,UPDATING] -uint8_t system_number_of_cells = 0; //Total number of cell voltages, set by each battery -bool system_LFP_Chemistry = false; //Set to true or false depending on cell chemistry +uint16_t system_cellvoltages_mV[MAX_AMOUNT_CELLS]; //Array with all cell voltages. Oversized to accomodate all setups +uint8_t system_bms_status = ACTIVE; //ACTIVE - [0..5]<>[STANDBY,INACTIVE,DARKSTART,ACTIVE,FAULT,UPDATING] +uint8_t system_number_of_cells = 0; //Total number of cell voltages, set by each battery +bool system_LFP_Chemistry = false; //Set to true or false depending on cell chemistry // Common charger parameters volatile float charger_setpoint_HV_VDC = 0.0f; diff --git a/Software/src/battery/BMW-I3-BATTERY.h b/Software/src/battery/BMW-I3-BATTERY.h index c855da90..8c0d7145 100644 --- a/Software/src/battery/BMW-I3-BATTERY.h +++ b/Software/src/battery/BMW-I3-BATTERY.h @@ -8,26 +8,26 @@ #define BATTERY_SELECTED // These parameters need to be mapped for the inverter -extern uint32_t system_capacity_Wh; //Wh, 0-150000Wh -extern uint32_t system_remaining_capacity_Wh; //Wh, 0-150000Wh -extern int16_t system_temperature_min_dC; //C+1, -50.0 - 50.0 -extern int16_t system_temperature_max_dC; //C+1, -50.0 - 50.0 -extern int16_t system_active_power_W; //W, -32000 to 32000 -extern int16_t system_battery_current_dA; //A+1, -1000 - 1000 -extern uint16_t system_battery_voltage_dV; //V+1, 0-500.0 (0-5000) -extern uint16_t system_max_design_voltage_dV; //V+1, 0-500.0 (0-5000) -extern uint16_t system_min_design_voltage_dV; //V+1, 0-500.0 (0-5000) -extern uint16_t system_scaled_SOC_pptt; //SOC%, 0-100.00 (0-10000) -extern uint16_t system_real_SOC_pptt; //SOC%, 0-100.00 (0-10000) -extern uint16_t system_SOH_pptt; //SOH%, 0-100.00 (0-10000) -extern uint16_t system_max_discharge_power_W; //W, 0-65000 -extern uint16_t system_max_charge_power_W; //W, 0-65000 -extern uint16_t system_cell_max_voltage_mV; //mV, 0-5000, Stores the highest cell millivolt value -extern uint16_t system_cell_min_voltage_mV; //mV, 0-5000, Stores the minimum cell millivolt value -extern uint16_t system_cellvoltages_mV[192]; //Array with all cell voltages in mV -extern uint8_t system_number_of_cells; //Total number of cell voltages, set by each battery -extern uint8_t system_bms_status; //Enum 0-5 -extern bool batteryAllowsContactorClosing; //Bool, true/false +extern uint32_t system_capacity_Wh; //Wh, 0-150000Wh +extern uint32_t system_remaining_capacity_Wh; //Wh, 0-150000Wh +extern int16_t system_temperature_min_dC; //C+1, -50.0 - 50.0 +extern int16_t system_temperature_max_dC; //C+1, -50.0 - 50.0 +extern int16_t system_active_power_W; //W, -32000 to 32000 +extern int16_t system_battery_current_dA; //A+1, -1000 - 1000 +extern uint16_t system_battery_voltage_dV; //V+1, 0-500.0 (0-5000) +extern uint16_t system_max_design_voltage_dV; //V+1, 0-500.0 (0-5000) +extern uint16_t system_min_design_voltage_dV; //V+1, 0-500.0 (0-5000) +extern uint16_t system_scaled_SOC_pptt; //SOC%, 0-100.00 (0-10000) +extern uint16_t system_real_SOC_pptt; //SOC%, 0-100.00 (0-10000) +extern uint16_t system_SOH_pptt; //SOH%, 0-100.00 (0-10000) +extern uint16_t system_max_discharge_power_W; //W, 0-65000 +extern uint16_t system_max_charge_power_W; //W, 0-65000 +extern uint16_t system_cell_max_voltage_mV; //mV, 0-5000, Stores the highest cell millivolt value +extern uint16_t system_cell_min_voltage_mV; //mV, 0-5000, Stores the minimum cell millivolt value +extern uint16_t system_cellvoltages_mV[MAX_AMOUNT_CELLS]; //Array with all cell voltages in mV +extern uint8_t system_number_of_cells; //Total number of cell voltages, set by each battery +extern uint8_t system_bms_status; //Enum 0-5 +extern bool batteryAllowsContactorClosing; //Bool, true/false void setup_battery(void); diff --git a/Software/src/battery/CHADEMO-BATTERY.h b/Software/src/battery/CHADEMO-BATTERY.h index 06ddecba..9af21b66 100644 --- a/Software/src/battery/CHADEMO-BATTERY.h +++ b/Software/src/battery/CHADEMO-BATTERY.h @@ -8,26 +8,26 @@ #define BATTERY_SELECTED // These parameters need to be mapped for the inverter -extern uint32_t system_capacity_Wh; //Wh, 0-150000Wh -extern uint32_t system_remaining_capacity_Wh; //Wh, 0-150000Wh -extern int16_t system_temperature_min_dC; //C+1, -50.0 - 50.0 -extern int16_t system_temperature_max_dC; //C+1, -50.0 - 50.0 -extern int16_t system_active_power_W; //W, -32000 to 32000 -extern int16_t system_battery_current_dA; //A+1, -1000 - 1000 -extern uint16_t system_battery_voltage_dV; //V+1, 0-500.0 (0-5000) -extern uint16_t system_max_design_voltage_dV; //V+1, 0-500.0 (0-5000) -extern uint16_t system_min_design_voltage_dV; //V+1, 0-500.0 (0-5000) -extern uint16_t system_scaled_SOC_pptt; //SOC%, 0-100.00 (0-10000) -extern uint16_t system_real_SOC_pptt; //SOC%, 0-100.00 (0-10000) -extern uint16_t system_SOH_pptt; //SOH%, 0-100.00 (0-10000) -extern uint16_t system_max_discharge_power_W; //W, 0-65000 -extern uint16_t system_max_charge_power_W; //W, 0-65000 -extern uint16_t system_cell_max_voltage_mV; //mV, 0-5000, Stores the highest cell millivolt value -extern uint16_t system_cell_min_voltage_mV; //mV, 0-5000, Stores the minimum cell millivolt value -extern uint16_t system_cellvoltages_mV[192]; //Array with all cell voltages in mV -extern uint8_t system_number_of_cells; //Total number of cell voltages, set by each battery -extern uint8_t system_bms_status; //Enum 0-5 -extern bool batteryAllowsContactorClosing; //Bool, true/false +extern uint32_t system_capacity_Wh; //Wh, 0-150000Wh +extern uint32_t system_remaining_capacity_Wh; //Wh, 0-150000Wh +extern int16_t system_temperature_min_dC; //C+1, -50.0 - 50.0 +extern int16_t system_temperature_max_dC; //C+1, -50.0 - 50.0 +extern int16_t system_active_power_W; //W, -32000 to 32000 +extern int16_t system_battery_current_dA; //A+1, -1000 - 1000 +extern uint16_t system_battery_voltage_dV; //V+1, 0-500.0 (0-5000) +extern uint16_t system_max_design_voltage_dV; //V+1, 0-500.0 (0-5000) +extern uint16_t system_min_design_voltage_dV; //V+1, 0-500.0 (0-5000) +extern uint16_t system_scaled_SOC_pptt; //SOC%, 0-100.00 (0-10000) +extern uint16_t system_real_SOC_pptt; //SOC%, 0-100.00 (0-10000) +extern uint16_t system_SOH_pptt; //SOH%, 0-100.00 (0-10000) +extern uint16_t system_max_discharge_power_W; //W, 0-65000 +extern uint16_t system_max_charge_power_W; //W, 0-65000 +extern uint16_t system_cell_max_voltage_mV; //mV, 0-5000, Stores the highest cell millivolt value +extern uint16_t system_cell_min_voltage_mV; //mV, 0-5000, Stores the minimum cell millivolt value +extern uint16_t system_cellvoltages_mV[MAX_AMOUNT_CELLS]; //Array with all cell voltages in mV +extern uint8_t system_number_of_cells; //Total number of cell voltages, set by each battery +extern uint8_t system_bms_status; //Enum 0-5 +extern bool batteryAllowsContactorClosing; //Bool, true/false void setup_battery(void); diff --git a/Software/src/battery/IMIEV-CZERO-ION-BATTERY.h b/Software/src/battery/IMIEV-CZERO-ION-BATTERY.h index 6bd3cd56..9b88b506 100644 --- a/Software/src/battery/IMIEV-CZERO-ION-BATTERY.h +++ b/Software/src/battery/IMIEV-CZERO-ION-BATTERY.h @@ -8,27 +8,27 @@ #define BATTERY_SELECTED // These parameters need to be mapped for the inverter -extern uint32_t system_capacity_Wh; //Wh, 0-150000Wh -extern uint32_t system_remaining_capacity_Wh; //Wh, 0-150000Wh -extern int16_t system_temperature_min_dC; //C+1, -50.0 - 50.0 -extern int16_t system_temperature_max_dC; //C+1, -50.0 - 50.0 -extern int16_t system_active_power_W; //W, -32000 to 32000 -extern int16_t system_battery_current_dA; //A+1, -1000 - 1000 -extern uint16_t system_battery_voltage_dV; //V+1, 0-500.0 (0-5000) -extern uint16_t system_max_design_voltage_dV; //V+1, 0-500.0 (0-5000) -extern uint16_t system_min_design_voltage_dV; //V+1, 0-500.0 (0-5000) -extern uint16_t system_scaled_SOC_pptt; //SOC%, 0-100.00 (0-10000) -extern uint16_t system_real_SOC_pptt; //SOC%, 0-100.00 (0-10000) -extern uint16_t system_SOH_pptt; //SOH%, 0-100.00 (0-10000) -extern uint16_t system_max_discharge_power_W; //W, 0-65000 -extern uint16_t system_max_charge_power_W; //W, 0-65000 -extern uint16_t system_cell_max_voltage_mV; //mV, 0-5000, Stores the highest cell millivolt value -extern uint16_t system_cell_min_voltage_mV; //mV, 0-5000, Stores the minimum cell millivolt value -extern uint16_t system_cellvoltages_mV[192]; //Array with all cell voltages in mV -extern uint8_t system_number_of_cells; //Total number of cell voltages, set by each battery -extern uint8_t system_bms_status; //Enum 0-5 -extern bool batteryAllowsContactorClosing; //Bool, true/false -extern bool inverterAllowsContactorClosing; //Bool, 1=true, 0=false +extern uint32_t system_capacity_Wh; //Wh, 0-150000Wh +extern uint32_t system_remaining_capacity_Wh; //Wh, 0-150000Wh +extern int16_t system_temperature_min_dC; //C+1, -50.0 - 50.0 +extern int16_t system_temperature_max_dC; //C+1, -50.0 - 50.0 +extern int16_t system_active_power_W; //W, -32000 to 32000 +extern int16_t system_battery_current_dA; //A+1, -1000 - 1000 +extern uint16_t system_battery_voltage_dV; //V+1, 0-500.0 (0-5000) +extern uint16_t system_max_design_voltage_dV; //V+1, 0-500.0 (0-5000) +extern uint16_t system_min_design_voltage_dV; //V+1, 0-500.0 (0-5000) +extern uint16_t system_scaled_SOC_pptt; //SOC%, 0-100.00 (0-10000) +extern uint16_t system_real_SOC_pptt; //SOC%, 0-100.00 (0-10000) +extern uint16_t system_SOH_pptt; //SOH%, 0-100.00 (0-10000) +extern uint16_t system_max_discharge_power_W; //W, 0-65000 +extern uint16_t system_max_charge_power_W; //W, 0-65000 +extern uint16_t system_cell_max_voltage_mV; //mV, 0-5000, Stores the highest cell millivolt value +extern uint16_t system_cell_min_voltage_mV; //mV, 0-5000, Stores the minimum cell millivolt value +extern uint16_t system_cellvoltages_mV[MAX_AMOUNT_CELLS]; //Array with all cell voltages in mV +extern uint8_t system_number_of_cells; //Total number of cell voltages, set by each battery +extern uint8_t system_bms_status; //Enum 0-5 +extern bool batteryAllowsContactorClosing; //Bool, true/false +extern bool inverterAllowsContactorClosing; //Bool, 1=true, 0=false void setup_battery(void); diff --git a/Software/src/battery/KIA-HYUNDAI-64-BATTERY.h b/Software/src/battery/KIA-HYUNDAI-64-BATTERY.h index e00c4abf..58508222 100644 --- a/Software/src/battery/KIA-HYUNDAI-64-BATTERY.h +++ b/Software/src/battery/KIA-HYUNDAI-64-BATTERY.h @@ -11,27 +11,27 @@ #define MAXDISCHARGEPOWERALLOWED 10000 // These parameters need to be mapped for the inverter -extern uint32_t system_capacity_Wh; //Wh, 0-150000Wh -extern uint32_t system_remaining_capacity_Wh; //Wh, 0-150000Wh -extern int16_t system_temperature_min_dC; //C+1, -50.0 - 50.0 -extern int16_t system_temperature_max_dC; //C+1, -50.0 - 50.0 -extern int16_t system_active_power_W; //W, -32000 to 32000 -extern int16_t system_battery_current_dA; //A+1, -1000 - 1000 -extern uint16_t system_battery_voltage_dV; //V+1, 0-500.0 (0-5000) -extern uint16_t system_max_design_voltage_dV; //V+1, 0-500.0 (0-5000) -extern uint16_t system_min_design_voltage_dV; //V+1, 0-500.0 (0-5000) -extern uint16_t system_scaled_SOC_pptt; //SOC%, 0-100.00 (0-10000) -extern uint16_t system_real_SOC_pptt; //SOC%, 0-100.00 (0-10000) -extern uint16_t system_SOH_pptt; //SOH%, 0-100.00 (0-10000) -extern uint16_t system_max_discharge_power_W; //W, 0-65000 -extern uint16_t system_max_charge_power_W; //W, 0-65000 -extern uint16_t system_cell_max_voltage_mV; //mV, 0-5000, Stores the highest cell millivolt value -extern uint16_t system_cell_min_voltage_mV; //mV, 0-5000, Stores the minimum cell millivolt value -extern uint16_t system_cellvoltages_mV[192]; //Array with all cell voltages in mV -extern uint8_t system_number_of_cells; //Total number of cell voltages, set by each battery -extern uint8_t system_bms_status; //Enum 0-5 -extern bool batteryAllowsContactorClosing; //Bool, true/false -extern bool inverterAllowsContactorClosing; //Bool, 1=true, 0=false +extern uint32_t system_capacity_Wh; //Wh, 0-150000Wh +extern uint32_t system_remaining_capacity_Wh; //Wh, 0-150000Wh +extern int16_t system_temperature_min_dC; //C+1, -50.0 - 50.0 +extern int16_t system_temperature_max_dC; //C+1, -50.0 - 50.0 +extern int16_t system_active_power_W; //W, -32000 to 32000 +extern int16_t system_battery_current_dA; //A+1, -1000 - 1000 +extern uint16_t system_battery_voltage_dV; //V+1, 0-500.0 (0-5000) +extern uint16_t system_max_design_voltage_dV; //V+1, 0-500.0 (0-5000) +extern uint16_t system_min_design_voltage_dV; //V+1, 0-500.0 (0-5000) +extern uint16_t system_scaled_SOC_pptt; //SOC%, 0-100.00 (0-10000) +extern uint16_t system_real_SOC_pptt; //SOC%, 0-100.00 (0-10000) +extern uint16_t system_SOH_pptt; //SOH%, 0-100.00 (0-10000) +extern uint16_t system_max_discharge_power_W; //W, 0-65000 +extern uint16_t system_max_charge_power_W; //W, 0-65000 +extern uint16_t system_cell_max_voltage_mV; //mV, 0-5000, Stores the highest cell millivolt value +extern uint16_t system_cell_min_voltage_mV; //mV, 0-5000, Stores the minimum cell millivolt value +extern uint16_t system_cellvoltages_mV[MAX_AMOUNT_CELLS]; //Array with all cell voltages in mV +extern uint8_t system_number_of_cells; //Total number of cell voltages, set by each battery +extern uint8_t system_bms_status; //Enum 0-5 +extern bool batteryAllowsContactorClosing; //Bool, true/false +extern bool inverterAllowsContactorClosing; //Bool, 1=true, 0=false void setup_battery(void); diff --git a/Software/src/battery/NISSAN-LEAF-BATTERY.h b/Software/src/battery/NISSAN-LEAF-BATTERY.h index 7ae28a3f..506781cc 100644 --- a/Software/src/battery/NISSAN-LEAF-BATTERY.h +++ b/Software/src/battery/NISSAN-LEAF-BATTERY.h @@ -8,26 +8,26 @@ #define BATTERY_SELECTED // These parameters need to be mapped for the inverter -extern uint32_t system_capacity_Wh; //Wh, 0-150000Wh -extern uint32_t system_remaining_capacity_Wh; //Wh, 0-150000Wh -extern int16_t system_temperature_min_dC; //C+1, -50.0 - 50.0 -extern int16_t system_temperature_max_dC; //C+1, -50.0 - 50.0 -extern int16_t system_active_power_W; //W, -32000 to 32000 -extern int16_t system_battery_current_dA; //A+1, -1000 - 1000 -extern uint16_t system_battery_voltage_dV; //V+1, 0-500.0 (0-5000) -extern uint16_t system_max_design_voltage_dV; //V+1, 0-500.0 (0-5000) -extern uint16_t system_min_design_voltage_dV; //V+1, 0-500.0 (0-5000) -extern uint16_t system_scaled_SOC_pptt; //SOC%, 0-100.00 (0-10000) -extern uint16_t system_real_SOC_pptt; //SOC%, 0-100.00 (0-10000) -extern uint16_t system_SOH_pptt; //SOH%, 0-100.00 (0-10000) -extern uint16_t system_max_discharge_power_W; //W, 0-65000 -extern uint16_t system_max_charge_power_W; //W, 0-65000 -extern uint16_t system_cell_max_voltage_mV; //mV, 0-5000, Stores the highest cell millivolt value -extern uint16_t system_cell_min_voltage_mV; //mV, 0-5000, Stores the minimum cell millivolt value -extern uint16_t system_cellvoltages_mV[192]; //Array with all cell voltages in mV -extern uint8_t system_number_of_cells; //Total number of cell voltages, set by each battery -extern uint8_t system_bms_status; //Enum 0-5 -extern bool batteryAllowsContactorClosing; //Bool, true/false +extern uint32_t system_capacity_Wh; //Wh, 0-150000Wh +extern uint32_t system_remaining_capacity_Wh; //Wh, 0-150000Wh +extern int16_t system_temperature_min_dC; //C+1, -50.0 - 50.0 +extern int16_t system_temperature_max_dC; //C+1, -50.0 - 50.0 +extern int16_t system_active_power_W; //W, -32000 to 32000 +extern int16_t system_battery_current_dA; //A+1, -1000 - 1000 +extern uint16_t system_battery_voltage_dV; //V+1, 0-500.0 (0-5000) +extern uint16_t system_max_design_voltage_dV; //V+1, 0-500.0 (0-5000) +extern uint16_t system_min_design_voltage_dV; //V+1, 0-500.0 (0-5000) +extern uint16_t system_scaled_SOC_pptt; //SOC%, 0-100.00 (0-10000) +extern uint16_t system_real_SOC_pptt; //SOC%, 0-100.00 (0-10000) +extern uint16_t system_SOH_pptt; //SOH%, 0-100.00 (0-10000) +extern uint16_t system_max_discharge_power_W; //W, 0-65000 +extern uint16_t system_max_charge_power_W; //W, 0-65000 +extern uint16_t system_cell_max_voltage_mV; //mV, 0-5000, Stores the highest cell millivolt value +extern uint16_t system_cell_min_voltage_mV; //mV, 0-5000, Stores the minimum cell millivolt value +extern uint16_t system_cellvoltages_mV[MAX_AMOUNT_CELLS]; //Array with all cell voltages in mV +extern uint8_t system_number_of_cells; //Total number of cell voltages, set by each battery +extern uint8_t system_bms_status; //Enum 0-5 +extern bool batteryAllowsContactorClosing; //Bool, true/false uint16_t Temp_fromRAW_to_F(uint16_t temperature); bool is_message_corrupt(CAN_frame_t rx_frame); diff --git a/Software/src/battery/RENAULT-KANGOO-BATTERY.h b/Software/src/battery/RENAULT-KANGOO-BATTERY.h index 7c347d8a..c2c5e7a5 100644 --- a/Software/src/battery/RENAULT-KANGOO-BATTERY.h +++ b/Software/src/battery/RENAULT-KANGOO-BATTERY.h @@ -14,27 +14,27 @@ #define MAX_CELL_DEVIATION_MV 500 //LED turns yellow on the board if mv delta exceeds this value // These parameters need to be mapped for the inverter -extern uint32_t system_capacity_Wh; //Wh, 0-150000Wh -extern uint32_t system_remaining_capacity_Wh; //Wh, 0-150000Wh -extern int16_t system_temperature_min_dC; //C+1, -50.0 - 50.0 -extern int16_t system_temperature_max_dC; //C+1, -50.0 - 50.0 -extern int16_t system_active_power_W; //W, -32000 to 32000 -extern int16_t system_battery_current_dA; //A+1, -1000 - 1000 -extern uint16_t system_battery_voltage_dV; //V+1, 0-500.0 (0-5000) -extern uint16_t system_max_design_voltage_dV; //V+1, 0-500.0 (0-5000) -extern uint16_t system_min_design_voltage_dV; //V+1, 0-500.0 (0-5000) -extern uint16_t system_scaled_SOC_pptt; //SOC%, 0-100.00 (0-10000) -extern uint16_t system_real_SOC_pptt; //SOC%, 0-100.00 (0-10000) -extern uint16_t system_SOH_pptt; //SOH%, 0-100.00 (0-10000) -extern uint16_t system_max_discharge_power_W; //W, 0-65000 -extern uint16_t system_max_charge_power_W; //W, 0-65000 -extern uint16_t system_cell_max_voltage_mV; //mV, 0-5000, Stores the highest cell millivolt value -extern uint16_t system_cell_min_voltage_mV; //mV, 0-5000, Stores the minimum cell millivolt value -extern uint16_t system_cellvoltages_mV[192]; //Array with all cell voltages in mV -extern uint8_t system_number_of_cells; //Total number of cell voltages, set by each battery -extern uint8_t system_bms_status; //Enum 0-5 -extern bool batteryAllowsContactorClosing; //Bool, true/false -extern bool inverterAllowsContactorClosing; //Bool, true/false +extern uint32_t system_capacity_Wh; //Wh, 0-150000Wh +extern uint32_t system_remaining_capacity_Wh; //Wh, 0-150000Wh +extern int16_t system_temperature_min_dC; //C+1, -50.0 - 50.0 +extern int16_t system_temperature_max_dC; //C+1, -50.0 - 50.0 +extern int16_t system_active_power_W; //W, -32000 to 32000 +extern int16_t system_battery_current_dA; //A+1, -1000 - 1000 +extern uint16_t system_battery_voltage_dV; //V+1, 0-500.0 (0-5000) +extern uint16_t system_max_design_voltage_dV; //V+1, 0-500.0 (0-5000) +extern uint16_t system_min_design_voltage_dV; //V+1, 0-500.0 (0-5000) +extern uint16_t system_scaled_SOC_pptt; //SOC%, 0-100.00 (0-10000) +extern uint16_t system_real_SOC_pptt; //SOC%, 0-100.00 (0-10000) +extern uint16_t system_SOH_pptt; //SOH%, 0-100.00 (0-10000) +extern uint16_t system_max_discharge_power_W; //W, 0-65000 +extern uint16_t system_max_charge_power_W; //W, 0-65000 +extern uint16_t system_cell_max_voltage_mV; //mV, 0-5000, Stores the highest cell millivolt value +extern uint16_t system_cell_min_voltage_mV; //mV, 0-5000, Stores the minimum cell millivolt value +extern uint16_t system_cellvoltages_mV[MAX_AMOUNT_CELLS]; //Array with all cell voltages in mV +extern uint8_t system_number_of_cells; //Total number of cell voltages, set by each battery +extern uint8_t system_bms_status; //Enum 0-5 +extern bool batteryAllowsContactorClosing; //Bool, true/false +extern bool inverterAllowsContactorClosing; //Bool, true/false void setup_battery(void); diff --git a/Software/src/battery/RENAULT-ZOE-BATTERY.h b/Software/src/battery/RENAULT-ZOE-BATTERY.h index 91bcd7d6..83ef9a8f 100644 --- a/Software/src/battery/RENAULT-ZOE-BATTERY.h +++ b/Software/src/battery/RENAULT-ZOE-BATTERY.h @@ -14,27 +14,27 @@ #define MAX_CELL_DEVIATION_MV 500 //LED turns yellow on the board if mv delta exceeds this value // These parameters need to be mapped for the inverter -extern uint32_t system_capacity_Wh; //Wh, 0-150000Wh -extern uint32_t system_remaining_capacity_Wh; //Wh, 0-150000Wh -extern int16_t system_temperature_min_dC; //C+1, -50.0 - 50.0 -extern int16_t system_temperature_max_dC; //C+1, -50.0 - 50.0 -extern int16_t system_active_power_W; //W, -32000 to 32000 -extern int16_t system_battery_current_dA; //A+1, -1000 - 1000 -extern uint16_t system_battery_voltage_dV; //V+1, 0-500.0 (0-5000) -extern uint16_t system_max_design_voltage_dV; //V+1, 0-500.0 (0-5000) -extern uint16_t system_min_design_voltage_dV; //V+1, 0-500.0 (0-5000) -extern uint16_t system_scaled_SOC_pptt; //SOC%, 0-100.00 (0-10000) -extern uint16_t system_real_SOC_pptt; //SOC%, 0-100.00 (0-10000) -extern uint16_t system_SOH_pptt; //SOH%, 0-100.00 (0-10000) -extern uint16_t system_max_discharge_power_W; //W, 0-65000 -extern uint16_t system_max_charge_power_W; //W, 0-65000 -extern uint16_t system_cell_max_voltage_mV; //mV, 0-5000, Stores the highest cell millivolt value -extern uint16_t system_cell_min_voltage_mV; //mV, 0-5000, Stores the minimum cell millivolt value -extern uint16_t system_cellvoltages_mV[192]; //Array with all cell voltages in mV -extern uint8_t system_number_of_cells; //Total number of cell voltages, set by each battery -extern uint8_t system_bms_status; //Enum 0-5 -extern bool batteryAllowsContactorClosing; //Bool, true/false -extern bool inverterAllowsContactorClosing; //Bool, 1=true, 0=false +extern uint32_t system_capacity_Wh; //Wh, 0-150000Wh +extern uint32_t system_remaining_capacity_Wh; //Wh, 0-150000Wh +extern int16_t system_temperature_min_dC; //C+1, -50.0 - 50.0 +extern int16_t system_temperature_max_dC; //C+1, -50.0 - 50.0 +extern int16_t system_active_power_W; //W, -32000 to 32000 +extern int16_t system_battery_current_dA; //A+1, -1000 - 1000 +extern uint16_t system_battery_voltage_dV; //V+1, 0-500.0 (0-5000) +extern uint16_t system_max_design_voltage_dV; //V+1, 0-500.0 (0-5000) +extern uint16_t system_min_design_voltage_dV; //V+1, 0-500.0 (0-5000) +extern uint16_t system_scaled_SOC_pptt; //SOC%, 0-100.00 (0-10000) +extern uint16_t system_real_SOC_pptt; //SOC%, 0-100.00 (0-10000) +extern uint16_t system_SOH_pptt; //SOH%, 0-100.00 (0-10000) +extern uint16_t system_max_discharge_power_W; //W, 0-65000 +extern uint16_t system_max_charge_power_W; //W, 0-65000 +extern uint16_t system_cell_max_voltage_mV; //mV, 0-5000, Stores the highest cell millivolt value +extern uint16_t system_cell_min_voltage_mV; //mV, 0-5000, Stores the minimum cell millivolt value +extern uint16_t system_cellvoltages_mV[MAX_AMOUNT_CELLS]; //Array with all cell voltages in mV +extern uint8_t system_number_of_cells; //Total number of cell voltages, set by each battery +extern uint8_t system_bms_status; //Enum 0-5 +extern bool batteryAllowsContactorClosing; //Bool, true/false +extern bool inverterAllowsContactorClosing; //Bool, 1=true, 0=false void setup_battery(void); diff --git a/Software/src/battery/SANTA-FE-PHEV-BATTERY.h b/Software/src/battery/SANTA-FE-PHEV-BATTERY.h index 127ca90d..8d4e13cb 100644 --- a/Software/src/battery/SANTA-FE-PHEV-BATTERY.h +++ b/Software/src/battery/SANTA-FE-PHEV-BATTERY.h @@ -8,26 +8,26 @@ #define BATTERY_SELECTED // These parameters need to be mapped for the inverter -extern uint32_t system_capacity_Wh; //Wh, 0-150000Wh -extern uint32_t system_remaining_capacity_Wh; //Wh, 0-150000Wh -extern int16_t system_temperature_min_dC; //C+1, -50.0 - 50.0 -extern int16_t system_temperature_max_dC; //C+1, -50.0 - 50.0 -extern int16_t system_active_power_W; //W, -32000 to 32000 -extern int16_t system_battery_current_dA; //A+1, -1000 - 1000 -extern uint16_t system_battery_voltage_dV; //V+1, 0-500.0 (0-5000) -extern uint16_t system_max_design_voltage_dV; //V+1, 0-500.0 (0-5000) -extern uint16_t system_min_design_voltage_dV; //V+1, 0-500.0 (0-5000) -extern uint16_t system_scaled_SOC_pptt; //SOC%, 0-100.00 (0-10000) -extern uint16_t system_real_SOC_pptt; //SOC%, 0-100.00 (0-10000) -extern uint16_t system_SOH_pptt; //SOH%, 0-100.00 (0-10000) -extern uint16_t system_max_discharge_power_W; //W, 0-65000 -extern uint16_t system_max_charge_power_W; //W, 0-65000 -extern uint16_t system_cell_max_voltage_mV; //mV, 0-5000, Stores the highest cell millivolt value -extern uint16_t system_cell_min_voltage_mV; //mV, 0-5000, Stores the minimum cell millivolt value -extern uint16_t system_cellvoltages_mV[192]; //Array with all cell voltages in mV -extern uint8_t system_number_of_cells; //Total number of cell voltages, set by each battery -extern uint8_t system_bms_status; //Enum 0-5 -extern bool batteryAllowsContactorClosing; //Bool, true/false +extern uint32_t system_capacity_Wh; //Wh, 0-150000Wh +extern uint32_t system_remaining_capacity_Wh; //Wh, 0-150000Wh +extern int16_t system_temperature_min_dC; //C+1, -50.0 - 50.0 +extern int16_t system_temperature_max_dC; //C+1, -50.0 - 50.0 +extern int16_t system_active_power_W; //W, -32000 to 32000 +extern int16_t system_battery_current_dA; //A+1, -1000 - 1000 +extern uint16_t system_battery_voltage_dV; //V+1, 0-500.0 (0-5000) +extern uint16_t system_max_design_voltage_dV; //V+1, 0-500.0 (0-5000) +extern uint16_t system_min_design_voltage_dV; //V+1, 0-500.0 (0-5000) +extern uint16_t system_scaled_SOC_pptt; //SOC%, 0-100.00 (0-10000) +extern uint16_t system_real_SOC_pptt; //SOC%, 0-100.00 (0-10000) +extern uint16_t system_SOH_pptt; //SOH%, 0-100.00 (0-10000) +extern uint16_t system_max_discharge_power_W; //W, 0-65000 +extern uint16_t system_max_charge_power_W; //W, 0-65000 +extern uint16_t system_cell_max_voltage_mV; //mV, 0-5000, Stores the highest cell millivolt value +extern uint16_t system_cell_min_voltage_mV; //mV, 0-5000, Stores the minimum cell millivolt value +extern uint16_t system_cellvoltages_mV[MAX_AMOUNT_CELLS]; //Array with all cell voltages in mV +extern uint8_t system_number_of_cells; //Total number of cell voltages, set by each battery +extern uint8_t system_bms_status; //Enum 0-5 +extern bool batteryAllowsContactorClosing; //Bool, true/false uint8_t CalculateCRC8(CAN_frame_t rx_frame); void setup_battery(void); diff --git a/Software/src/battery/TESLA-MODEL-3-BATTERY.h b/Software/src/battery/TESLA-MODEL-3-BATTERY.h index 51481057..c9c3718d 100644 --- a/Software/src/battery/TESLA-MODEL-3-BATTERY.h +++ b/Software/src/battery/TESLA-MODEL-3-BATTERY.h @@ -12,28 +12,28 @@ 60000 // 60000W we need to cap this value to max 60kW, most inverters overflow otherwise // These parameters need to be mapped for the inverter -extern uint32_t system_capacity_Wh; //Wh, 0-150000Wh -extern uint32_t system_remaining_capacity_Wh; //Wh, 0-150000Wh -extern int16_t system_temperature_min_dC; //C+1, -50.0 - 50.0 -extern int16_t system_temperature_max_dC; //C+1, -50.0 - 50.0 -extern int16_t system_active_power_W; //W, -32000 to 32000 -extern int16_t system_battery_current_dA; //A+1, -1000 - 1000 -extern uint16_t system_battery_voltage_dV; //V+1, 0-500.0 (0-5000) -extern uint16_t system_max_design_voltage_dV; //V+1, 0-500.0 (0-5000) -extern uint16_t system_min_design_voltage_dV; //V+1, 0-500.0 (0-5000) -extern uint16_t system_scaled_SOC_pptt; //SOC%, 0-100.00 (0-10000) -extern uint16_t system_real_SOC_pptt; //SOC%, 0-100.00 (0-10000) -extern uint16_t system_SOH_pptt; //SOH%, 0-100.00 (0-10000) -extern uint16_t system_max_discharge_power_W; //W, 0-65000 -extern uint16_t system_max_charge_power_W; //W, 0-65000 -extern uint16_t system_cell_max_voltage_mV; //mV, 0-5000, Stores the highest cell millivolt value -extern uint16_t system_cell_min_voltage_mV; //mV, 0-5000, Stores the minimum cell millivolt value -extern uint16_t system_cellvoltages_mV[192]; //Array with all cell voltages in mV -extern uint8_t system_number_of_cells; //Total number of cell voltages, set by each battery -extern uint8_t system_bms_status; //Enum 0-5 -extern bool batteryAllowsContactorClosing; //Bool, 1=true, 0=false -extern bool inverterAllowsContactorClosing; //Bool, 1=true, 0=false -extern bool system_LFP_Chemistry; //Bool, 1=true, 0=false +extern uint32_t system_capacity_Wh; //Wh, 0-150000Wh +extern uint32_t system_remaining_capacity_Wh; //Wh, 0-150000Wh +extern int16_t system_temperature_min_dC; //C+1, -50.0 - 50.0 +extern int16_t system_temperature_max_dC; //C+1, -50.0 - 50.0 +extern int16_t system_active_power_W; //W, -32000 to 32000 +extern int16_t system_battery_current_dA; //A+1, -1000 - 1000 +extern uint16_t system_battery_voltage_dV; //V+1, 0-500.0 (0-5000) +extern uint16_t system_max_design_voltage_dV; //V+1, 0-500.0 (0-5000) +extern uint16_t system_min_design_voltage_dV; //V+1, 0-500.0 (0-5000) +extern uint16_t system_scaled_SOC_pptt; //SOC%, 0-100.00 (0-10000) +extern uint16_t system_real_SOC_pptt; //SOC%, 0-100.00 (0-10000) +extern uint16_t system_SOH_pptt; //SOH%, 0-100.00 (0-10000) +extern uint16_t system_max_discharge_power_W; //W, 0-65000 +extern uint16_t system_max_charge_power_W; //W, 0-65000 +extern uint16_t system_cell_max_voltage_mV; //mV, 0-5000, Stores the highest cell millivolt value +extern uint16_t system_cell_min_voltage_mV; //mV, 0-5000, Stores the minimum cell millivolt value +extern uint16_t system_cellvoltages_mV[MAX_AMOUNT_CELLS]; //Array with all cell voltages in mV +extern uint8_t system_number_of_cells; //Total number of cell voltages, set by each battery +extern uint8_t system_bms_status; //Enum 0-5 +extern bool batteryAllowsContactorClosing; //Bool, 1=true, 0=false +extern bool inverterAllowsContactorClosing; //Bool, 1=true, 0=false +extern bool system_LFP_Chemistry; //Bool, 1=true, 0=false void printFaultCodesIfActive(); void printDebugIfActive(uint8_t symbol, const char* message); diff --git a/Software/src/battery/TEST-FAKE-BATTERY.h b/Software/src/battery/TEST-FAKE-BATTERY.h index 549ea92f..f0c868ca 100644 --- a/Software/src/battery/TEST-FAKE-BATTERY.h +++ b/Software/src/battery/TEST-FAKE-BATTERY.h @@ -8,27 +8,27 @@ #define BATTERY_SELECTED // These parameters need to be mapped for the inverter -extern uint32_t system_capacity_Wh; //Wh, 0-150000Wh -extern uint32_t system_remaining_capacity_Wh; //Wh, 0-150000Wh -extern int16_t system_temperature_min_dC; //C+1, -50.0 - 50.0 -extern int16_t system_temperature_max_dC; //C+1, -50.0 - 50.0 -extern int16_t system_active_power_W; //W, -32000 to 32000 -extern int16_t system_battery_current_dA; //A+1, -1000 - 1000 -extern uint16_t system_battery_voltage_dV; //V+1, 0-500.0 (0-5000) -extern uint16_t system_max_design_voltage_dV; //V+1, 0-500.0 (0-5000) -extern uint16_t system_min_design_voltage_dV; //V+1, 0-500.0 (0-5000) -extern uint16_t system_scaled_SOC_pptt; //SOC%, 0-100.00 (0-10000) -extern uint16_t system_real_SOC_pptt; //SOC%, 0-100.00 (0-10000) -extern uint16_t system_SOH_pptt; //SOH%, 0-100.00 (0-10000) -extern uint16_t system_max_discharge_power_W; //W, 0-65000 -extern uint16_t system_max_charge_power_W; //W, 0-65000 -extern uint16_t system_cell_max_voltage_mV; //mV, 0-5000, Stores the highest cell millivolt value -extern uint16_t system_cell_min_voltage_mV; //mV, 0-5000, Stores the minimum cell millivolt value -extern uint16_t system_cellvoltages_mV[192]; //Array with all cell voltages in mV -extern uint8_t system_number_of_cells; //Total number of cell voltages, set by each battery -extern uint8_t system_bms_status; //Enum 0-5 -extern bool batteryAllowsContactorClosing; //Bool, true/false -extern bool inverterAllowsContactorClosing; //Bool, true/false +extern uint32_t system_capacity_Wh; //Wh, 0-150000Wh +extern uint32_t system_remaining_capacity_Wh; //Wh, 0-150000Wh +extern int16_t system_temperature_min_dC; //C+1, -50.0 - 50.0 +extern int16_t system_temperature_max_dC; //C+1, -50.0 - 50.0 +extern int16_t system_active_power_W; //W, -32000 to 32000 +extern int16_t system_battery_current_dA; //A+1, -1000 - 1000 +extern uint16_t system_battery_voltage_dV; //V+1, 0-500.0 (0-5000) +extern uint16_t system_max_design_voltage_dV; //V+1, 0-500.0 (0-5000) +extern uint16_t system_min_design_voltage_dV; //V+1, 0-500.0 (0-5000) +extern uint16_t system_scaled_SOC_pptt; //SOC%, 0-100.00 (0-10000) +extern uint16_t system_real_SOC_pptt; //SOC%, 0-100.00 (0-10000) +extern uint16_t system_SOH_pptt; //SOH%, 0-100.00 (0-10000) +extern uint16_t system_max_discharge_power_W; //W, 0-65000 +extern uint16_t system_max_charge_power_W; //W, 0-65000 +extern uint16_t system_cell_max_voltage_mV; //mV, 0-5000, Stores the highest cell millivolt value +extern uint16_t system_cell_min_voltage_mV; //mV, 0-5000, Stores the minimum cell millivolt value +extern uint16_t system_cellvoltages_mV[MAX_AMOUNT_CELLS]; //Array with all cell voltages in mV +extern uint8_t system_number_of_cells; //Total number of cell voltages, set by each battery +extern uint8_t system_bms_status; //Enum 0-5 +extern bool batteryAllowsContactorClosing; //Bool, true/false +extern bool inverterAllowsContactorClosing; //Bool, true/false void setup_battery(void); diff --git a/Software/src/devboard/config.h b/Software/src/devboard/config.h index ff4b2f7b..9db44760 100644 --- a/Software/src/devboard/config.h +++ b/Software/src/devboard/config.h @@ -49,4 +49,7 @@ #define DISCHARGING 1 #define CHARGING 2 +// Common definitions +#define MAX_AMOUNT_CELLS 192 + #endif diff --git a/Software/src/devboard/mqtt/mqtt.h b/Software/src/devboard/mqtt/mqtt.h index 60d0924f..b39b56be 100644 --- a/Software/src/devboard/mqtt/mqtt.h +++ b/Software/src/devboard/mqtt/mqtt.h @@ -41,18 +41,18 @@ extern const char* version_number; // The current software version, used for mqtt -extern int16_t system_temperature_min_dC; //C+1, -50.0 - 50.0 -extern int16_t system_temperature_max_dC; //C+1, -50.0 - 50.0 -extern int16_t system_active_power_W; //W, -32000 to 32000 -extern int16_t system_battery_current_dA; //A+1, -1000 - 1000 -extern uint16_t system_battery_voltage_dV; //V+1, 0-500.0 (0-5000) -extern uint16_t system_scaled_SOC_pptt; //SOC%, 0-100.00 (0-10000) -extern uint16_t system_real_SOC_pptt; //SOC%, 0-100.00 (0-10000) -extern uint16_t system_SOH_pptt; //SOH%, 0-100.00 (0-10000) -extern uint16_t system_cell_max_voltage_mV; //mV, 0-5000 , Stores the highest cell millivolt value -extern uint16_t system_cell_min_voltage_mV; //mV, 0-5000, Stores the minimum cell millivolt value -extern uint16_t system_cellvoltages_mV[192]; //Array with all cell voltages in mV -extern uint8_t system_number_of_cells; //Total number of cell voltages, set by each battery +extern int16_t system_temperature_min_dC; //C+1, -50.0 - 50.0 +extern int16_t system_temperature_max_dC; //C+1, -50.0 - 50.0 +extern int16_t system_active_power_W; //W, -32000 to 32000 +extern int16_t system_battery_current_dA; //A+1, -1000 - 1000 +extern uint16_t system_battery_voltage_dV; //V+1, 0-500.0 (0-5000) +extern uint16_t system_scaled_SOC_pptt; //SOC%, 0-100.00 (0-10000) +extern uint16_t system_real_SOC_pptt; //SOC%, 0-100.00 (0-10000) +extern uint16_t system_SOH_pptt; //SOH%, 0-100.00 (0-10000) +extern uint16_t system_cell_max_voltage_mV; //mV, 0-5000 , Stores the highest cell millivolt value +extern uint16_t system_cell_min_voltage_mV; //mV, 0-5000, Stores the minimum cell millivolt value +extern uint16_t system_cellvoltages_mV[MAX_AMOUNT_CELLS]; //Array with all cell voltages in mV +extern uint8_t system_number_of_cells; //Total number of cell voltages, set by each battery extern const char* mqtt_user; extern const char* mqtt_password; diff --git a/Software/src/devboard/webserver/cellmonitor_html.cpp b/Software/src/devboard/webserver/cellmonitor_html.cpp index 32c0ab41..d9377a12 100644 --- a/Software/src/devboard/webserver/cellmonitor_html.cpp +++ b/Software/src/devboard/webserver/cellmonitor_html.cpp @@ -26,7 +26,7 @@ String cellmonitor_processor(const String& var) { // Visualize the populated cells in forward order using flexbox with conditional text color content += "
"; - for (int i = 0; i < 192; ++i) { + for (int i = 0; i < MAX_AMOUNT_CELLS; ++i) { // Skip empty values if (system_cellvoltages_mV[i] == 0) { continue; diff --git a/Software/src/devboard/webserver/cellmonitor_html.h b/Software/src/devboard/webserver/cellmonitor_html.h index 9a1a0bd7..85f08b83 100644 --- a/Software/src/devboard/webserver/cellmonitor_html.h +++ b/Software/src/devboard/webserver/cellmonitor_html.h @@ -4,9 +4,9 @@ #include #include -extern uint16_t system_cell_max_voltage_mV; //mV, 0-5000, Stores the highest cell millivolt value -extern uint16_t system_cell_min_voltage_mV; //mV, 0-5000, Stores the minimum cell millivolt value -extern uint16_t system_cellvoltages_mV[192]; //Array with all cell voltages in mV +extern uint16_t system_cell_max_voltage_mV; //mV, 0-5000, Stores the highest cell millivolt value +extern uint16_t system_cell_min_voltage_mV; //mV, 0-5000, Stores the minimum cell millivolt value +extern uint16_t system_cellvoltages_mV[MAX_AMOUNT_CELLS]; //Array with all cell voltages in mV /** * @brief Replaces placeholder with content section in web page diff --git a/Software/src/devboard/webserver/webserver.h b/Software/src/devboard/webserver/webserver.h index 84735e46..ad748147 100644 --- a/Software/src/devboard/webserver/webserver.h +++ b/Software/src/devboard/webserver/webserver.h @@ -16,29 +16,29 @@ #include "../mqtt/mqtt.h" #endif -extern const char* version_number; // The current software version, shown on webserver -extern uint32_t system_capacity_Wh; //Wh, 0-150000Wh -extern uint32_t system_remaining_capacity_Wh; //Wh, 0-150000Wh -extern int16_t system_battery_current_dA; //A+1, -1000 - 1000 -extern int16_t system_temperature_min_dC; //C+1, -50.0 - 50.0 -extern int16_t system_temperature_max_dC; //C+1, -50.0 - 50.0 -extern int16_t system_active_power_W; //W, -32000 to 32000 -extern uint16_t system_max_design_voltage_dV; //V+1, 0-500.0 (0-5000) -extern uint16_t system_min_design_voltage_dV; //V+1, 0-500.0 (0-5000) -extern uint16_t system_scaled_SOC_pptt; //SOC%, 0-100.00 (0-10000) -extern uint16_t system_real_SOC_pptt; //SOC%, 0-100.00 (0-10000) -extern uint16_t system_SOH_pptt; //SOH%, 0-100.00 (0-10000) -extern uint16_t system_battery_voltage_dV; //V+1, 0-500.0 (0-5000) -extern uint16_t system_max_discharge_power_W; //W, 0-65000 -extern uint16_t system_max_charge_power_W; //W, 0-65000 -extern uint16_t system_cell_max_voltage_mV; //mV, 0-5000 , Stores the highest cell millivolt value -extern uint16_t system_cell_min_voltage_mV; //mV, 0-5000, Stores the minimum cell millivolt value -extern uint16_t system_cellvoltages_mV[192]; //Array with all cell voltages in mV -extern uint8_t system_number_of_cells; //Total number of cell voltages, set by each battery -extern uint8_t system_bms_status; //Enum 0-5 -extern uint8_t LEDcolor; //Enum, 0-10 -extern bool batteryAllowsContactorClosing; //Bool, 1=true, 0=false -extern bool inverterAllowsContactorClosing; //Bool, 1=true, 0=false +extern const char* version_number; // The current software version, shown on webserver +extern uint32_t system_capacity_Wh; //Wh, 0-150000Wh +extern uint32_t system_remaining_capacity_Wh; //Wh, 0-150000Wh +extern int16_t system_battery_current_dA; //A+1, -1000 - 1000 +extern int16_t system_temperature_min_dC; //C+1, -50.0 - 50.0 +extern int16_t system_temperature_max_dC; //C+1, -50.0 - 50.0 +extern int16_t system_active_power_W; //W, -32000 to 32000 +extern uint16_t system_max_design_voltage_dV; //V+1, 0-500.0 (0-5000) +extern uint16_t system_min_design_voltage_dV; //V+1, 0-500.0 (0-5000) +extern uint16_t system_scaled_SOC_pptt; //SOC%, 0-100.00 (0-10000) +extern uint16_t system_real_SOC_pptt; //SOC%, 0-100.00 (0-10000) +extern uint16_t system_SOH_pptt; //SOH%, 0-100.00 (0-10000) +extern uint16_t system_battery_voltage_dV; //V+1, 0-500.0 (0-5000) +extern uint16_t system_max_discharge_power_W; //W, 0-65000 +extern uint16_t system_max_charge_power_W; //W, 0-65000 +extern uint16_t system_cell_max_voltage_mV; //mV, 0-5000 , Stores the highest cell millivolt value +extern uint16_t system_cell_min_voltage_mV; //mV, 0-5000, Stores the minimum cell millivolt value +extern uint16_t system_cellvoltages_mV[MAX_AMOUNT_CELLS]; //Array with all cell voltages in mV +extern uint8_t system_number_of_cells; //Total number of cell voltages, set by each battery +extern uint8_t system_bms_status; //Enum 0-5 +extern uint8_t LEDcolor; //Enum, 0-10 +extern bool batteryAllowsContactorClosing; //Bool, 1=true, 0=false +extern bool inverterAllowsContactorClosing; //Bool, 1=true, 0=false extern const char* ssid; extern const char* password; diff --git a/Software/src/inverter/BYD-CAN.h b/Software/src/inverter/BYD-CAN.h index 30264bab..5cf9ee46 100644 --- a/Software/src/inverter/BYD-CAN.h +++ b/Software/src/inverter/BYD-CAN.h @@ -6,27 +6,27 @@ #include "../lib/miwagner-ESP32-Arduino-CAN/ESP32CAN.h" // These parameters need to be mapped for the inverter -extern uint32_t system_capacity_Wh; //Wh, 0-150000Wh -extern uint32_t system_remaining_capacity_Wh; //Wh, 0-150000Wh -extern int16_t system_temperature_min_dC; //C+1, -50.0 - 50.0 -extern int16_t system_temperature_max_dC; //C+1, -50.0 - 50.0 -extern int16_t system_active_power_W; //W, -32000 to 32000 -extern int16_t system_battery_current_dA; //A+1, -1000 - 1000 -extern uint16_t system_battery_voltage_dV; //V+1, 0-500.0 (0-5000) -extern uint16_t system_max_design_voltage_dV; //V+1, 0-500.0 (0-5000) -extern uint16_t system_min_design_voltage_dV; //V+1, 0-500.0 (0-5000) -extern uint16_t system_scaled_SOC_pptt; //SOC%, 0-100.00 (0-10000) -extern uint16_t system_real_SOC_pptt; //SOC%, 0-100.00 (0-10000) -extern uint16_t system_SOH_pptt; //SOH%, 0-100.00 (0-10000) -extern uint16_t system_max_discharge_power_W; //W, 0-65000 -extern uint16_t system_max_charge_power_W; //W, 0-65000 -extern uint16_t system_cell_max_voltage_mV; //mV, 0-5000, Stores the highest cell millivolt value -extern uint16_t system_cell_min_voltage_mV; //mV, 0-5000, Stores the minimum cell millivolt value -extern uint16_t system_cellvoltages_mV[192]; //Array with all cell voltages in mV -extern uint8_t system_number_of_cells; //Total number of cell voltages, set by each battery -extern uint8_t system_bms_status; //Enum 0-5 -extern bool batteryAllowsContactorClosing; //Bool, true/false -extern bool inverterAllowsContactorClosing; //Bool, true/false +extern uint32_t system_capacity_Wh; //Wh, 0-150000Wh +extern uint32_t system_remaining_capacity_Wh; //Wh, 0-150000Wh +extern int16_t system_temperature_min_dC; //C+1, -50.0 - 50.0 +extern int16_t system_temperature_max_dC; //C+1, -50.0 - 50.0 +extern int16_t system_active_power_W; //W, -32000 to 32000 +extern int16_t system_battery_current_dA; //A+1, -1000 - 1000 +extern uint16_t system_battery_voltage_dV; //V+1, 0-500.0 (0-5000) +extern uint16_t system_max_design_voltage_dV; //V+1, 0-500.0 (0-5000) +extern uint16_t system_min_design_voltage_dV; //V+1, 0-500.0 (0-5000) +extern uint16_t system_scaled_SOC_pptt; //SOC%, 0-100.00 (0-10000) +extern uint16_t system_real_SOC_pptt; //SOC%, 0-100.00 (0-10000) +extern uint16_t system_SOH_pptt; //SOH%, 0-100.00 (0-10000) +extern uint16_t system_max_discharge_power_W; //W, 0-65000 +extern uint16_t system_max_charge_power_W; //W, 0-65000 +extern uint16_t system_cell_max_voltage_mV; //mV, 0-5000, Stores the highest cell millivolt value +extern uint16_t system_cell_min_voltage_mV; //mV, 0-5000, Stores the minimum cell millivolt value +extern uint16_t system_cellvoltages_mV[MAX_AMOUNT_CELLS]; //Array with all cell voltages in mV +extern uint8_t system_number_of_cells; //Total number of cell voltages, set by each battery +extern uint8_t system_bms_status; //Enum 0-5 +extern bool batteryAllowsContactorClosing; //Bool, true/false +extern bool inverterAllowsContactorClosing; //Bool, true/false void update_values_can_byd(); void send_can_byd(); diff --git a/Software/src/inverter/LUNA2000-MODBUS.h b/Software/src/inverter/LUNA2000-MODBUS.h index dc856556..ec78c58f 100644 --- a/Software/src/inverter/LUNA2000-MODBUS.h +++ b/Software/src/inverter/LUNA2000-MODBUS.h @@ -6,27 +6,27 @@ #define MB_RTU_NUM_VALUES 30000 extern uint16_t mbPV[MB_RTU_NUM_VALUES]; -extern uint32_t system_capacity_Wh; //Wh, 0-150000Wh -extern uint32_t system_remaining_capacity_Wh; //Wh, 0-150000Wh -extern int16_t system_temperature_min_dC; //C+1, -50.0 - 50.0 -extern int16_t system_temperature_max_dC; //C+1, -50.0 - 50.0 -extern int16_t system_active_power_W; //W, -32000 to 32000 -extern int16_t system_battery_current_dA; //A+1, -1000 - 1000 -extern uint16_t system_battery_voltage_dV; //V+1, 0-500.0 (0-5000) -extern uint16_t system_max_design_voltage_dV; //V+1, 0-500.0 (0-5000) -extern uint16_t system_min_design_voltage_dV; //V+1, 0-500.0 (0-5000) -extern uint16_t system_scaled_SOC_pptt; //SOC%, 0-100.00 (0-10000) -extern uint16_t system_real_SOC_pptt; //SOC%, 0-100.00 (0-10000) -extern uint16_t system_SOH_pptt; //SOH%, 0-100.00 (0-10000) -extern uint16_t system_max_discharge_power_W; //W, 0-65000 -extern uint16_t system_max_charge_power_W; //W, 0-65000 -extern uint16_t system_cell_max_voltage_mV; //mV, 0-5000, Stores the highest cell millivolt value -extern uint16_t system_cell_min_voltage_mV; //mV, 0-5000, Stores the minimum cell millivolt value -extern uint16_t system_cellvoltages_mV[192]; //Array with all cell voltages in mV -extern uint8_t system_number_of_cells; //Total number of cell voltages, set by each battery -extern uint8_t system_bms_status; //Enum 0-5 -extern bool batteryAllowsContactorClosing; //Bool, true/false -extern bool inverterAllowsContactorClosing; //Bool, true/false +extern uint32_t system_capacity_Wh; //Wh, 0-150000Wh +extern uint32_t system_remaining_capacity_Wh; //Wh, 0-150000Wh +extern int16_t system_temperature_min_dC; //C+1, -50.0 - 50.0 +extern int16_t system_temperature_max_dC; //C+1, -50.0 - 50.0 +extern int16_t system_active_power_W; //W, -32000 to 32000 +extern int16_t system_battery_current_dA; //A+1, -1000 - 1000 +extern uint16_t system_battery_voltage_dV; //V+1, 0-500.0 (0-5000) +extern uint16_t system_max_design_voltage_dV; //V+1, 0-500.0 (0-5000) +extern uint16_t system_min_design_voltage_dV; //V+1, 0-500.0 (0-5000) +extern uint16_t system_scaled_SOC_pptt; //SOC%, 0-100.00 (0-10000) +extern uint16_t system_real_SOC_pptt; //SOC%, 0-100.00 (0-10000) +extern uint16_t system_SOH_pptt; //SOH%, 0-100.00 (0-10000) +extern uint16_t system_max_discharge_power_W; //W, 0-65000 +extern uint16_t system_max_charge_power_W; //W, 0-65000 +extern uint16_t system_cell_max_voltage_mV; //mV, 0-5000, Stores the highest cell millivolt value +extern uint16_t system_cell_min_voltage_mV; //mV, 0-5000, Stores the minimum cell millivolt value +extern uint16_t system_cellvoltages_mV[MAX_AMOUNT_CELLS]; //Array with all cell voltages in mV +extern uint8_t system_number_of_cells; //Total number of cell voltages, set by each battery +extern uint8_t system_bms_status; //Enum 0-5 +extern bool batteryAllowsContactorClosing; //Bool, true/false +extern bool inverterAllowsContactorClosing; //Bool, true/false void update_modbus_registers_luna2000(); void handle_update_data_modbus32051(); diff --git a/Software/src/inverter/PYLON-CAN.h b/Software/src/inverter/PYLON-CAN.h index b8fcfcb4..d7e57cfc 100644 --- a/Software/src/inverter/PYLON-CAN.h +++ b/Software/src/inverter/PYLON-CAN.h @@ -5,27 +5,27 @@ #include "../devboard/config.h" // Needed for all defines #include "../lib/miwagner-ESP32-Arduino-CAN/ESP32CAN.h" -extern uint32_t system_capacity_Wh; //Wh, 0-150000Wh -extern uint32_t system_remaining_capacity_Wh; //Wh, 0-150000Wh -extern int16_t system_temperature_min_dC; //C+1, -50.0 - 50.0 -extern int16_t system_temperature_max_dC; //C+1, -50.0 - 50.0 -extern int16_t system_active_power_W; //W, -32000 to 32000 -extern int16_t system_battery_current_dA; //A+1, -1000 - 1000 -extern uint16_t system_battery_voltage_dV; //V+1, 0-500.0 (0-5000) -extern uint16_t system_max_design_voltage_dV; //V+1, 0-500.0 (0-5000) -extern uint16_t system_min_design_voltage_dV; //V+1, 0-500.0 (0-5000) -extern uint16_t system_scaled_SOC_pptt; //SOC%, 0-100.00 (0-10000) -extern uint16_t system_real_SOC_pptt; //SOC%, 0-100.00 (0-10000) -extern uint16_t system_SOH_pptt; //SOH%, 0-100.00 (0-10000) -extern uint16_t system_max_discharge_power_W; //W, 0-65000 -extern uint16_t system_max_charge_power_W; //W, 0-65000 -extern uint16_t system_cell_max_voltage_mV; //mV, 0-5000, Stores the highest cell millivolt value -extern uint16_t system_cell_min_voltage_mV; //mV, 0-5000, Stores the minimum cell millivolt value -extern uint16_t system_cellvoltages_mV[192]; //Array with all cell voltages in mV -extern uint8_t system_number_of_cells; //Total number of cell voltages, set by each battery -extern uint8_t system_bms_status; //Enum 0-5 -extern bool batteryAllowsContactorClosing; //Bool, true/false -extern bool inverterAllowsContactorClosing; //Bool, true/false +extern uint32_t system_capacity_Wh; //Wh, 0-150000Wh +extern uint32_t system_remaining_capacity_Wh; //Wh, 0-150000Wh +extern int16_t system_temperature_min_dC; //C+1, -50.0 - 50.0 +extern int16_t system_temperature_max_dC; //C+1, -50.0 - 50.0 +extern int16_t system_active_power_W; //W, -32000 to 32000 +extern int16_t system_battery_current_dA; //A+1, -1000 - 1000 +extern uint16_t system_battery_voltage_dV; //V+1, 0-500.0 (0-5000) +extern uint16_t system_max_design_voltage_dV; //V+1, 0-500.0 (0-5000) +extern uint16_t system_min_design_voltage_dV; //V+1, 0-500.0 (0-5000) +extern uint16_t system_scaled_SOC_pptt; //SOC%, 0-100.00 (0-10000) +extern uint16_t system_real_SOC_pptt; //SOC%, 0-100.00 (0-10000) +extern uint16_t system_SOH_pptt; //SOH%, 0-100.00 (0-10000) +extern uint16_t system_max_discharge_power_W; //W, 0-65000 +extern uint16_t system_max_charge_power_W; //W, 0-65000 +extern uint16_t system_cell_max_voltage_mV; //mV, 0-5000, Stores the highest cell millivolt value +extern uint16_t system_cell_min_voltage_mV; //mV, 0-5000, Stores the minimum cell millivolt value +extern uint16_t system_cellvoltages_mV[MAX_AMOUNT_CELLS]; //Array with all cell voltages in mV +extern uint8_t system_number_of_cells; //Total number of cell voltages, set by each battery +extern uint8_t system_bms_status; //Enum 0-5 +extern bool batteryAllowsContactorClosing; //Bool, true/false +extern bool inverterAllowsContactorClosing; //Bool, true/false void update_values_can_pylon(); void receive_can_pylon(CAN_frame_t rx_frame); diff --git a/Software/src/inverter/SMA-CAN.h b/Software/src/inverter/SMA-CAN.h index 0bc85601..b86e5e64 100644 --- a/Software/src/inverter/SMA-CAN.h +++ b/Software/src/inverter/SMA-CAN.h @@ -5,27 +5,27 @@ #include "../devboard/config.h" // Needed for all defines #include "../lib/miwagner-ESP32-Arduino-CAN/ESP32CAN.h" -extern uint32_t system_capacity_Wh; //Wh, 0-150000Wh -extern uint32_t system_remaining_capacity_Wh; //Wh, 0-150000Wh -extern int16_t system_temperature_min_dC; //C+1, -50.0 - 50.0 -extern int16_t system_temperature_max_dC; //C+1, -50.0 - 50.0 -extern int16_t system_active_power_W; //W, -32000 to 32000 -extern int16_t system_battery_current_dA; //A+1, -1000 - 1000 -extern uint16_t system_battery_voltage_dV; //V+1, 0-500.0 (0-5000) -extern uint16_t system_max_design_voltage_dV; //V+1, 0-500.0 (0-5000) -extern uint16_t system_min_design_voltage_dV; //V+1, 0-500.0 (0-5000) -extern uint16_t system_scaled_SOC_pptt; //SOC%, 0-100.00 (0-10000) -extern uint16_t system_real_SOC_pptt; //SOC%, 0-100.00 (0-10000) -extern uint16_t system_SOH_pptt; //SOH%, 0-100.00 (0-10000) -extern uint16_t system_max_discharge_power_W; //W, 0-65000 -extern uint16_t system_max_charge_power_W; //W, 0-65000 -extern uint16_t system_cell_max_voltage_mV; //mV, 0-5000, Stores the highest cell millivolt value -extern uint16_t system_cell_min_voltage_mV; //mV, 0-5000, Stores the minimum cell millivolt value -extern uint16_t system_cellvoltages_mV[192]; //Array with all cell voltages in mV -extern uint8_t system_number_of_cells; //Total number of cell voltages, set by each battery -extern uint8_t system_bms_status; //Enum 0-5 -extern bool batteryAllowsContactorClosing; //Bool, true/false -extern bool inverterAllowsContactorClosing; //Bool, true/false +extern uint32_t system_capacity_Wh; //Wh, 0-150000Wh +extern uint32_t system_remaining_capacity_Wh; //Wh, 0-150000Wh +extern int16_t system_temperature_min_dC; //C+1, -50.0 - 50.0 +extern int16_t system_temperature_max_dC; //C+1, -50.0 - 50.0 +extern int16_t system_active_power_W; //W, -32000 to 32000 +extern int16_t system_battery_current_dA; //A+1, -1000 - 1000 +extern uint16_t system_battery_voltage_dV; //V+1, 0-500.0 (0-5000) +extern uint16_t system_max_design_voltage_dV; //V+1, 0-500.0 (0-5000) +extern uint16_t system_min_design_voltage_dV; //V+1, 0-500.0 (0-5000) +extern uint16_t system_scaled_SOC_pptt; //SOC%, 0-100.00 (0-10000) +extern uint16_t system_real_SOC_pptt; //SOC%, 0-100.00 (0-10000) +extern uint16_t system_SOH_pptt; //SOH%, 0-100.00 (0-10000) +extern uint16_t system_max_discharge_power_W; //W, 0-65000 +extern uint16_t system_max_charge_power_W; //W, 0-65000 +extern uint16_t system_cell_max_voltage_mV; //mV, 0-5000, Stores the highest cell millivolt value +extern uint16_t system_cell_min_voltage_mV; //mV, 0-5000, Stores the minimum cell millivolt value +extern uint16_t system_cellvoltages_mV[MAX_AMOUNT_CELLS]; //Array with all cell voltages in mV +extern uint8_t system_number_of_cells; //Total number of cell voltages, set by each battery +extern uint8_t system_bms_status; //Enum 0-5 +extern bool batteryAllowsContactorClosing; //Bool, true/false +extern bool inverterAllowsContactorClosing; //Bool, true/false #define READY_STATE 0x03 #define STOP_STATE 0x02 diff --git a/Software/src/inverter/SMA-TRIPOWER-CAN.h b/Software/src/inverter/SMA-TRIPOWER-CAN.h index 2b1755c1..1c56cadb 100644 --- a/Software/src/inverter/SMA-TRIPOWER-CAN.h +++ b/Software/src/inverter/SMA-TRIPOWER-CAN.h @@ -5,27 +5,27 @@ #include "../devboard/config.h" // Needed for all defines #include "../lib/miwagner-ESP32-Arduino-CAN/ESP32CAN.h" -extern uint32_t system_capacity_Wh; //Wh, 0-150000Wh -extern uint32_t system_remaining_capacity_Wh; //Wh, 0-150000Wh -extern int16_t system_temperature_min_dC; //C+1, -50.0 - 50.0 -extern int16_t system_temperature_max_dC; //C+1, -50.0 - 50.0 -extern int16_t system_active_power_W; //W, -32000 to 32000 -extern int16_t system_battery_current_dA; //A+1, -1000 - 1000 -extern uint16_t system_battery_voltage_dV; //V+1, 0-500.0 (0-5000) -extern uint16_t system_max_design_voltage_dV; //V+1, 0-500.0 (0-5000) -extern uint16_t system_min_design_voltage_dV; //V+1, 0-500.0 (0-5000) -extern uint16_t system_scaled_SOC_pptt; //SOC%, 0-100.00 (0-10000) -extern uint16_t system_real_SOC_pptt; //SOC%, 0-100.00 (0-10000) -extern uint16_t system_SOH_pptt; //SOH%, 0-100.00 (0-10000) -extern uint16_t system_max_discharge_power_W; //W, 0-65000 -extern uint16_t system_max_charge_power_W; //W, 0-65000 -extern uint16_t system_cell_max_voltage_mV; //mV, 0-5000, Stores the highest cell millivolt value -extern uint16_t system_cell_min_voltage_mV; //mV, 0-5000, Stores the minimum cell millivolt value -extern uint16_t system_cellvoltages_mV[192]; //Array with all cell voltages in mV -extern uint8_t system_number_of_cells; //Total number of cell voltages, set by each battery -extern uint8_t system_bms_status; //Enum 0-5 -extern bool batteryAllowsContactorClosing; //Bool, true/false -extern bool inverterAllowsContactorClosing; //Bool, true/false +extern uint32_t system_capacity_Wh; //Wh, 0-150000Wh +extern uint32_t system_remaining_capacity_Wh; //Wh, 0-150000Wh +extern int16_t system_temperature_min_dC; //C+1, -50.0 - 50.0 +extern int16_t system_temperature_max_dC; //C+1, -50.0 - 50.0 +extern int16_t system_active_power_W; //W, -32000 to 32000 +extern int16_t system_battery_current_dA; //A+1, -1000 - 1000 +extern uint16_t system_battery_voltage_dV; //V+1, 0-500.0 (0-5000) +extern uint16_t system_max_design_voltage_dV; //V+1, 0-500.0 (0-5000) +extern uint16_t system_min_design_voltage_dV; //V+1, 0-500.0 (0-5000) +extern uint16_t system_scaled_SOC_pptt; //SOC%, 0-100.00 (0-10000) +extern uint16_t system_real_SOC_pptt; //SOC%, 0-100.00 (0-10000) +extern uint16_t system_SOH_pptt; //SOH%, 0-100.00 (0-10000) +extern uint16_t system_max_discharge_power_W; //W, 0-65000 +extern uint16_t system_max_charge_power_W; //W, 0-65000 +extern uint16_t system_cell_max_voltage_mV; //mV, 0-5000, Stores the highest cell millivolt value +extern uint16_t system_cell_min_voltage_mV; //mV, 0-5000, Stores the minimum cell millivolt value +extern uint16_t system_cellvoltages_mV[MAX_AMOUNT_CELLS]; //Array with all cell voltages in mV +extern uint8_t system_number_of_cells; //Total number of cell voltages, set by each battery +extern uint8_t system_bms_status; //Enum 0-5 +extern bool batteryAllowsContactorClosing; //Bool, true/false +extern bool inverterAllowsContactorClosing; //Bool, true/false void update_values_can_sma_tripower(); void send_can_sma_tripower(); diff --git a/Software/src/inverter/SOFAR-CAN.h b/Software/src/inverter/SOFAR-CAN.h index e974e7b1..02a3772d 100644 --- a/Software/src/inverter/SOFAR-CAN.h +++ b/Software/src/inverter/SOFAR-CAN.h @@ -6,27 +6,27 @@ #include "../lib/miwagner-ESP32-Arduino-CAN/ESP32CAN.h" // These parameters need to be mapped for the inverter -extern uint32_t system_capacity_Wh; //Wh, 0-150000Wh -extern uint32_t system_remaining_capacity_Wh; //Wh, 0-150000Wh -extern int16_t system_temperature_min_dC; //C+1, -50.0 - 50.0 -extern int16_t system_temperature_max_dC; //C+1, -50.0 - 50.0 -extern int16_t system_active_power_W; //W, -32000 to 32000 -extern int16_t system_battery_current_dA; //A+1, -1000 - 1000 -extern uint16_t system_battery_voltage_dV; //V+1, 0-500.0 (0-5000) -extern uint16_t system_max_design_voltage_dV; //V+1, 0-500.0 (0-5000) -extern uint16_t system_min_design_voltage_dV; //V+1, 0-500.0 (0-5000) -extern uint16_t system_scaled_SOC_pptt; //SOC%, 0-100.00 (0-10000) -extern uint16_t system_real_SOC_pptt; //SOC%, 0-100.00 (0-10000) -extern uint16_t system_SOH_pptt; //SOH%, 0-100.00 (0-10000) -extern uint16_t system_max_discharge_power_W; //W, 0-65000 -extern uint16_t system_max_charge_power_W; //W, 0-65000 -extern uint16_t system_cell_max_voltage_mV; //mV, 0-5000, Stores the highest cell millivolt value -extern uint16_t system_cell_min_voltage_mV; //mV, 0-5000, Stores the minimum cell millivolt value -extern uint16_t system_cellvoltages_mV[192]; //Array with all cell voltages in mV -extern uint8_t system_number_of_cells; //Total number of cell voltages, set by each battery -extern uint8_t system_bms_status; //Enum 0-5 -extern bool batteryAllowsContactorClosing; //Bool, true/false -extern bool inverterAllowsContactorClosing; //Bool, true/false +extern uint32_t system_capacity_Wh; //Wh, 0-150000Wh +extern uint32_t system_remaining_capacity_Wh; //Wh, 0-150000Wh +extern int16_t system_temperature_min_dC; //C+1, -50.0 - 50.0 +extern int16_t system_temperature_max_dC; //C+1, -50.0 - 50.0 +extern int16_t system_active_power_W; //W, -32000 to 32000 +extern int16_t system_battery_current_dA; //A+1, -1000 - 1000 +extern uint16_t system_battery_voltage_dV; //V+1, 0-500.0 (0-5000) +extern uint16_t system_max_design_voltage_dV; //V+1, 0-500.0 (0-5000) +extern uint16_t system_min_design_voltage_dV; //V+1, 0-500.0 (0-5000) +extern uint16_t system_scaled_SOC_pptt; //SOC%, 0-100.00 (0-10000) +extern uint16_t system_real_SOC_pptt; //SOC%, 0-100.00 (0-10000) +extern uint16_t system_SOH_pptt; //SOH%, 0-100.00 (0-10000) +extern uint16_t system_max_discharge_power_W; //W, 0-65000 +extern uint16_t system_max_charge_power_W; //W, 0-65000 +extern uint16_t system_cell_max_voltage_mV; //mV, 0-5000, Stores the highest cell millivolt value +extern uint16_t system_cell_min_voltage_mV; //mV, 0-5000, Stores the minimum cell millivolt value +extern uint16_t system_cellvoltages_mV[MAX_AMOUNT_CELLS]; //Array with all cell voltages in mV +extern uint8_t system_number_of_cells; //Total number of cell voltages, set by each battery +extern uint8_t system_bms_status; //Enum 0-5 +extern bool batteryAllowsContactorClosing; //Bool, true/false +extern bool inverterAllowsContactorClosing; //Bool, true/false extern uint16_t min_voltage; extern uint16_t max_voltage; diff --git a/Software/src/inverter/SOLAX-CAN.h b/Software/src/inverter/SOLAX-CAN.h index 9727d153..e2fc3544 100644 --- a/Software/src/inverter/SOLAX-CAN.h +++ b/Software/src/inverter/SOLAX-CAN.h @@ -8,27 +8,27 @@ extern ACAN2515 can; -extern uint32_t system_capacity_Wh; //Wh, 0-150000Wh -extern uint32_t system_remaining_capacity_Wh; //Wh, 0-150000Wh -extern int16_t system_temperature_min_dC; //C+1, -50.0 - 50.0 -extern int16_t system_temperature_max_dC; //C+1, -50.0 - 50.0 -extern int16_t system_active_power_W; //W, -32000 to 32000 -extern int16_t system_battery_current_dA; //A+1, -1000 - 1000 -extern uint16_t system_battery_voltage_dV; //V+1, 0-500.0 (0-5000) -extern uint16_t system_max_design_voltage_dV; //V+1, 0-500.0 (0-5000) -extern uint16_t system_min_design_voltage_dV; //V+1, 0-500.0 (0-5000) -extern uint16_t system_scaled_SOC_pptt; //SOC%, 0-100.00 (0-10000) -extern uint16_t system_real_SOC_pptt; //SOC%, 0-100.00 (0-10000) -extern uint16_t system_SOH_pptt; //SOH%, 0-100.00 (0-10000) -extern uint16_t system_max_discharge_power_W; //W, 0-65000 -extern uint16_t system_max_charge_power_W; //W, 0-65000 -extern uint16_t system_cell_max_voltage_mV; //mV, 0-5000, Stores the highest cell millivolt value -extern uint16_t system_cell_min_voltage_mV; //mV, 0-5000, Stores the minimum cell millivolt value -extern uint16_t system_cellvoltages_mV[192]; //Array with all cell voltages in mV -extern uint8_t system_number_of_cells; //Total number of cell voltages, set by each battery -extern uint8_t system_bms_status; //Enum 0-5 -extern bool batteryAllowsContactorClosing; //Bool, true/false -extern bool inverterAllowsContactorClosing; //Bool, true/false +extern uint32_t system_capacity_Wh; //Wh, 0-150000Wh +extern uint32_t system_remaining_capacity_Wh; //Wh, 0-150000Wh +extern int16_t system_temperature_min_dC; //C+1, -50.0 - 50.0 +extern int16_t system_temperature_max_dC; //C+1, -50.0 - 50.0 +extern int16_t system_active_power_W; //W, -32000 to 32000 +extern int16_t system_battery_current_dA; //A+1, -1000 - 1000 +extern uint16_t system_battery_voltage_dV; //V+1, 0-500.0 (0-5000) +extern uint16_t system_max_design_voltage_dV; //V+1, 0-500.0 (0-5000) +extern uint16_t system_min_design_voltage_dV; //V+1, 0-500.0 (0-5000) +extern uint16_t system_scaled_SOC_pptt; //SOC%, 0-100.00 (0-10000) +extern uint16_t system_real_SOC_pptt; //SOC%, 0-100.00 (0-10000) +extern uint16_t system_SOH_pptt; //SOH%, 0-100.00 (0-10000) +extern uint16_t system_max_discharge_power_W; //W, 0-65000 +extern uint16_t system_max_charge_power_W; //W, 0-65000 +extern uint16_t system_cell_max_voltage_mV; //mV, 0-5000, Stores the highest cell millivolt value +extern uint16_t system_cell_min_voltage_mV; //mV, 0-5000, Stores the minimum cell millivolt value +extern uint16_t system_cellvoltages_mV[MAX_AMOUNT_CELLS]; //Array with all cell voltages in mV +extern uint8_t system_number_of_cells; //Total number of cell voltages, set by each battery +extern uint8_t system_bms_status; //Enum 0-5 +extern bool batteryAllowsContactorClosing; //Bool, true/false +extern bool inverterAllowsContactorClosing; //Bool, true/false // Timeout in milliseconds #define SolaxTimeout 2000 From 8d1c3aaa06722d9b027a7fd0513fa333616e9e30 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sun, 25 Feb 2024 22:59:02 +0200 Subject: [PATCH 08/31] Fix compilation error --- Software/src/devboard/mqtt/mqtt.h | 1 + Software/src/devboard/webserver/cellmonitor_html.h | 1 + 2 files changed, 2 insertions(+) diff --git a/Software/src/devboard/mqtt/mqtt.h b/Software/src/devboard/mqtt/mqtt.h index b39b56be..6b699a32 100644 --- a/Software/src/devboard/mqtt/mqtt.h +++ b/Software/src/devboard/mqtt/mqtt.h @@ -36,6 +36,7 @@ #include #include "../../../USER_SETTINGS.h" +#include "../config.h" // Needed for defines #define MQTT_MSG_BUFFER_SIZE (1024) diff --git a/Software/src/devboard/webserver/cellmonitor_html.h b/Software/src/devboard/webserver/cellmonitor_html.h index 85f08b83..015c23ae 100644 --- a/Software/src/devboard/webserver/cellmonitor_html.h +++ b/Software/src/devboard/webserver/cellmonitor_html.h @@ -3,6 +3,7 @@ #include #include +#include "../config.h" // Needed for defines extern uint16_t system_cell_max_voltage_mV; //mV, 0-5000, Stores the highest cell millivolt value extern uint16_t system_cell_min_voltage_mV; //mV, 0-5000, Stores the minimum cell millivolt value From ff37650f135f2edd1d9ee9ff075ca17c3eea9698 Mon Sep 17 00:00:00 2001 From: Cabooman <81711263+Cabooman@users.noreply.github.com> Date: Mon, 26 Feb 2024 08:16:13 +0100 Subject: [PATCH 09/31] Cell display update --- .../devboard/webserver/cellmonitor_html.cpp | 153 +++++++++++++++--- 1 file changed, 128 insertions(+), 25 deletions(-) diff --git a/Software/src/devboard/webserver/cellmonitor_html.cpp b/Software/src/devboard/webserver/cellmonitor_html.cpp index 627fef3d..435414c2 100644 --- a/Software/src/devboard/webserver/cellmonitor_html.cpp +++ b/Software/src/devboard/webserver/cellmonitor_html.cpp @@ -11,44 +11,147 @@ String cellmonitor_processor(const String& var) { content += ".cell { width: 48%; margin: 1%; padding: 10px; border: 1px solid white; text-align: center; }"; content += ".low-voltage { color: red; }"; // Style for low voltage text content += ".voltage-values { margin-bottom: 10px; }"; // Style for voltage values section + content += "#graph {display: flex;align-items: flex-end;height: 200px;border: 1px solid #ccc;position: relative;}"; + content += + ".bar {margin: 0 0px;background-color: blue;display: inline-block;position: relative;cursor: pointer;border: " + "1px solid white; /* Add this line */}"; + content += "#valueDisplay {text-align: left;font-weight: bold;margin-top: 10px;}"; content += ""; // Start a new block with a specific background color content += "
"; // Display max, min, and deviation voltage values - content += "
"; - content += "Max Voltage: " + String(system_cell_max_voltage_mV) + " mV
"; - content += "Min Voltage: " + String(system_cell_min_voltage_mV) + " mV
"; - int deviation = system_cell_max_voltage_mV - system_cell_min_voltage_mV; - content += "Voltage Deviation: " + String(deviation) + " mV"; - content += "
"; - - // Visualize the populated cells in forward order using flexbox with conditional text color - content += "
"; - for (int i = 0; i < 120; ++i) { - // Skip empty values - if (system_cellvoltages_mV[i] == 0) { - continue; - } - - String cellContent = "Cell " + String(i + 1) + "
" + String(system_cellvoltages_mV[i]) + " mV"; - - // Check if the cell voltage is below 3000, apply red color - if (system_cellvoltages_mV[i] < 3000) { - cellContent = "" + cellContent + ""; - } - - content += "
" + cellContent + "
"; - } - content += "
"; + content += "
"; + // Display cells + content += "
"; + // Display bars + content += "
"; + // Display single hovered value + content += "
Value: ...
"; // Close the block content += "
"; content += ""; content += ""; return content; } From 8a12a55bb7c9df15699ad2db6051c79dcd06b9c6 Mon Sep 17 00:00:00 2001 From: Cabooman <81711263+Cabooman@users.noreply.github.com> Date: Mon, 26 Feb 2024 08:17:37 +0100 Subject: [PATCH 10/31] Minor events update on the fly Updated some comments and the location of the magic EEPROM event log number --- Software/src/devboard/utils/events.cpp | 1 - Software/src/devboard/utils/events.h | 13 ++++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Software/src/devboard/utils/events.cpp b/Software/src/devboard/utils/events.cpp index 9bfb184b..b01e9255 100644 --- a/Software/src/devboard/utils/events.cpp +++ b/Software/src/devboard/utils/events.cpp @@ -8,7 +8,6 @@ #include "../config.h" #include "timer.h" -#define EE_MAGIC_HEADER_VALUE 0xA5A5 #define EE_NOF_EVENT_ENTRIES 30 #define EE_EVENT_ENTRY_SIZE sizeof(EVENT_LOG_ENTRY_TYPE) #define EE_WRITE_PERIOD_MINUTES 10 diff --git a/Software/src/devboard/utils/events.h b/Software/src/devboard/utils/events.h index 13e67179..12b0839e 100644 --- a/Software/src/devboard/utils/events.h +++ b/Software/src/devboard/utils/events.h @@ -8,16 +8,23 @@ // #define INCLUDE_EVENTS_TEST // Enable to run an event test loop, see events_test_on_target.cpp +#define EE_MAGIC_HEADER_VALUE 0x0001 // 0x0000 to 0xFFFF + #define GENERATE_ENUM(ENUM) ENUM, #define GENERATE_STRING(STRING) #STRING, /** EVENT ENUMERATION * - * Do not change the order! + * Try not to change the order! * When adding events, add them RIGHT BEFORE the EVENT_NOF_EVENTS enum. - * In addition, the event name must start with "EVENT_" + * In addition, the event name must start with "EVENT_". + * If you don't follow this instruction, the EEPROM log will become corrupt. + * To handle this, follow the instruction for EE_MAGIC_HEADER_VALUE as + * described below. * - * After adding an event, assign the proper event level in events.cpp:init_events() + * After adding an event: + * - Assign the proper event level in events.cpp:init_events() + * - Increment EE_MAGIC_HEADER_VALUE in case you've changed the order */ #define EVENTS_ENUM_TYPE(XX) \ From cf50eca5132a3c9d9851d7e8c26fc14be199cdc3 Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 26 Feb 2024 11:51:45 +0200 Subject: [PATCH 11/31] Tweak cell LFP limits from testing round --- Software/src/battery/TESLA-MODEL-3-BATTERY.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Software/src/battery/TESLA-MODEL-3-BATTERY.cpp b/Software/src/battery/TESLA-MODEL-3-BATTERY.cpp index e3541261..96580c11 100644 --- a/Software/src/battery/TESLA-MODEL-3-BATTERY.cpp +++ b/Software/src/battery/TESLA-MODEL-3-BATTERY.cpp @@ -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 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 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 From be662e4fe0f3e368fe85456ed8eee97b996e78f8 Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 26 Feb 2024 11:56:07 +0200 Subject: [PATCH 12/31] Rename defines --- Software/src/battery/TESLA-MODEL-3-BATTERY.cpp | 14 +++++++------- Software/src/battery/TESLA-MODEL-3-BATTERY.h | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Software/src/battery/TESLA-MODEL-3-BATTERY.cpp b/Software/src/battery/TESLA-MODEL-3-BATTERY.cpp index 96580c11..a5fc5a10 100644 --- a/Software/src/battery/TESLA-MODEL-3-BATTERY.cpp +++ b/Software/src/battery/TESLA-MODEL-3-BATTERY.cpp @@ -204,17 +204,17 @@ void update_values_battery() { //This function maps all the values fetched via system_max_charge_power_W = 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)); + 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 - MILLIVOLTFLOAT)) { - system_max_charge_power_W = FLOATPOWERMAX; + 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 - MILLIVOLTFLOAT)) { - system_max_charge_power_W = FLOATPOWERMAX; + 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 diff --git a/Software/src/battery/TESLA-MODEL-3-BATTERY.h b/Software/src/battery/TESLA-MODEL-3-BATTERY.h index 6ed383b9..e1d47710 100644 --- a/Software/src/battery/TESLA-MODEL-3-BATTERY.h +++ b/Software/src/battery/TESLA-MODEL-3-BATTERY.h @@ -7,9 +7,9 @@ #define BATTERY_SELECTED -#define RAMPDOWNSOC 900 // 90.0 SOC% to start ramping down from max charge power towards 0 at 100.00% -#define FLOATPOWERMAX 200 // W, what power to allow for top balancing battery -#define MILLIVOLTFLOAT 20 // mV, how many mV under overvoltage to start float charging +#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 MAXDISCHARGEPOWERALLOWED \ 60000 // 60000W we need to cap this value to max 60kW, most inverters overflow otherwise From c4a78d19cff3264b0f33ed861a715fafd011b0d2 Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 26 Feb 2024 11:57:03 +0200 Subject: [PATCH 13/31] Fix else-if statement --- Software/src/battery/TESLA-MODEL-3-BATTERY.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Software/src/battery/TESLA-MODEL-3-BATTERY.cpp b/Software/src/battery/TESLA-MODEL-3-BATTERY.cpp index a5fc5a10..0291b211 100644 --- a/Software/src/battery/TESLA-MODEL-3-BATTERY.cpp +++ b/Software/src/battery/TESLA-MODEL-3-BATTERY.cpp @@ -202,8 +202,7 @@ 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; - } - if (soc_vi > 990) { + } else if (soc_vi > 990) { 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)); From bdcaa16d46361d0a3fe79a161d065b51b5b78fca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20=C3=96ster?= Date: Mon, 26 Feb 2024 13:06:18 +0200 Subject: [PATCH 14/31] Update version number --- Software/Software.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Software/Software.ino b/Software/Software.ino index 881aaf71..84525c15 100644 --- a/Software/Software.ino +++ b/Software/Software.ino @@ -23,7 +23,7 @@ #endif Preferences settings; // Store user settings -const char* version_number = "5.3.RC"; // The current software version, shown on webserver +const char* version_number = "5.3.0"; // The current software version, shown on webserver // Interval settings int intervalUpdateValues = 4800; // Interval at which to update inverter values / Modbus registers const int interval10 = 10; // Interval for 10ms tasks From 874e54a4d76d3e2d5c7caf3f8a16575cb15a4df3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20=C3=96ster?= Date: Mon, 26 Feb 2024 13:13:24 +0200 Subject: [PATCH 15/31] Update version number --- Software/Software.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Software/Software.ino b/Software/Software.ino index 84525c15..5b97aaef 100644 --- a/Software/Software.ino +++ b/Software/Software.ino @@ -23,7 +23,7 @@ #endif Preferences settings; // Store user settings -const char* version_number = "5.3.0"; // The current software version, shown on webserver +const char* version_number = "5.4.dev"; // The current software version, shown on webserver // Interval settings int intervalUpdateValues = 4800; // Interval at which to update inverter values / Modbus registers const int interval10 = 10; // Interval for 10ms tasks From 6f1bffea5ea5d7af685a929949d19073ed6858d1 Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 26 Feb 2024 22:33:32 +0200 Subject: [PATCH 16/31] Improve visibility on scale_soc setting --- Software/Software.ino | 4 ++-- Software/src/devboard/webserver/settings_html.cpp | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Software/Software.ino b/Software/Software.ino index 5b97aaef..6625d80c 100644 --- a/Software/Software.ino +++ b/Software/Software.ino @@ -22,8 +22,8 @@ #include "src/devboard/webserver/webserver.h" #endif -Preferences settings; // Store user settings -const char* version_number = "5.4.dev"; // The current software version, shown on webserver +Preferences settings; // Store user settings +const char* version_number = "5.4.dev"; //The current software version, shown on webserver // Interval settings int intervalUpdateValues = 4800; // Interval at which to update inverter values / Modbus registers const int interval10 = 10; // Interval for 10ms tasks diff --git a/Software/src/devboard/webserver/settings_html.cpp b/Software/src/devboard/webserver/settings_html.cpp index dd824dc4..2f730267 100644 --- a/Software/src/devboard/webserver/settings_html.cpp +++ b/Software/src/devboard/webserver/settings_html.cpp @@ -15,11 +15,14 @@ String settings_processor(const String& var) { // Show current settings with edit buttons and input fields content += "

Battery capacity: " + String(BATTERY_WH_MAX) + " Wh

"; - content += "

Rescale SOC: " + String(USE_SCALED_SOC) + + content += "

Rescale SOC: " + + String(USE_SCALED_SOC ? "" : "") + "

"; - content += "

SOC max percentage: " + String(MAXPERCENTAGE / 10.0, 1) + + content += "

SOC max percentage: " + String(MAXPERCENTAGE / 10.0, 1) + "

"; - content += "

SOC min percentage: " + String(MINPERCENTAGE / 10.0, 1) + + content += "

SOC min percentage: " + String(MINPERCENTAGE / 10.0, 1) + "

"; content += "

Max charge speed: " + String(MAXCHARGEAMP / 10.0, 1) + " A

"; From 6ebf47d8c492c09949199ae02d23d0859c95d316 Mon Sep 17 00:00:00 2001 From: Steven Maresca Date: Mon, 26 Feb 2024 23:21:34 -0500 Subject: [PATCH 17/31] Auto-refresh settings page on success, alert on error --- .../src/devboard/webserver/settings_html.cpp | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/Software/src/devboard/webserver/settings_html.cpp b/Software/src/devboard/webserver/settings_html.cpp index dd824dc4..0e8f3bd8 100644 --- a/Software/src/devboard/webserver/settings_html.cpp +++ b/Software/src/devboard/webserver/settings_html.cpp @@ -70,11 +70,21 @@ String settings_processor(const String& var) { #endif content += "