Skip to content

Commit

Permalink
Merge pull request #37 from Sleeper85/v1.17.5
Browse files Browse the repository at this point in the history
V1.17.5
  • Loading branch information
MrPabloUK authored Mar 27, 2024
2 parents f7e0d75 + d13f969 commit 56133f7
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 12 deletions.
20 changes: 16 additions & 4 deletions ESP32_LFP_BLE_jk-bms-can.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/gpl.html>.

# v1.17.5 MrPablo : "Auto Charge Voltage Control" function rewritten, EOC cycle threshold added to reduce premature triggering of float phase
# V1.17.4 MrPablo : Added "SMA" to CAN BMS names, added function "Auto Charge Voltage Control" to avoid OVP alarms and improve balancing, categorised sensors, set time source to SNTP, min battery voltage based on BMS value, added "Last Complete Charge" timestamp, renamed daily energy sensors and added input number display option
# V1.17.3 Sleeper85 : Renumbering cells, Added “JK-BMS ESP32 Restart” switch, adding Total Daily Energy sensors, set jk_bms update interval to 3s, set default log level to INFO, improvement of comments
# V1.17.2 MrPablo : Added function "Auto Charge/Discharge Current Control" to avoid OVP/UVP alarms
Expand Down Expand Up @@ -80,6 +81,9 @@ substitutions:
# Factor to adjust the aggression of the auto voltage control logic.
# The higher the setting, the more that requested charge voltage will reduce as cells exceed the target voltage (bulk voltage).
charge_v_factor: "2.0"
# End of charge (EOC) will be triggered if current and max cell voltage meet cut-off thresholds, plus the cycle count exceeds the below threshold.
# As default, this cycle count is set to 60 which is approximately 60 seconds. This will reduce the liklihood of premature EOC.
eoc_cycle_threshold: "60"
# +--------------------------------------+
# | Battery Discharge Settings |
# +--------------------------------------+
Expand Down Expand Up @@ -1213,6 +1217,7 @@ interval:
float cell_bulk_v = (id(bulk_voltage).state / id(cell_count).state);
float cell_rebulk_v = (id(rebulk_voltage).state / id(cell_count).state);
float cell_absorption_offset_v = (id(absorption_offset).state / id(cell_count).state);
static int num_executions = 0;
// Force Bulk Logic
if (id(can_switch_force_bulk).state) {
Expand All @@ -1233,25 +1238,32 @@ interval:
// Charging
if (id(current).state >= 0) {
float cv_min = 3.37;
float cv_max = 3.65;
float cutoff_current = (id(battery_capacity).state * 0.05 * (cell_bulk_v - cv_min) / (cv_max - cv_min));
float cutoff_voltage = (cv_min + (cv_max - cv_min)/(0.05 + cell_absorption_offset_v) * (id(current).state / id(battery_capacity).state));
ESP_LOGI("main", "Cut-Off Current : %f", cutoff_current);
ESP_LOGI("main", "Cut-Off Voltage : %f", cutoff_voltage);
ESP_LOGI("main", "Cut-Off Voltage : %f", cutoff_voltage);
// Stop Charging
if ((id(current).state <= cutoff_current) & (id(max_cell_voltage).state >= cutoff_voltage)) {
// End Of Charge
if ((!id(equalizing).state)) id(charge_status) = "EOC";
if ((!id(equalizing).state)) {
num_executions += 1;
ESP_LOGI("main", "EOC Cycle Count : %i", num_executions);
if (num_executions > ${eoc_cycle_threshold}) {
num_executions = 0;
id(charge_status) = "EOC";
}
}
}
// Start Charging
else {
num_executions = 0;
// With the "Auto Charge Current Control", the current is reduced automatically if "max_cell_voltage" approaches BMS OVPR
// Balancing : the BMS is equalizing the cells
Expand Down
16 changes: 14 additions & 2 deletions ESP32_LFP_Wire_jk-bms-can.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/gpl.html>.

# v1.17.5 MrPablo : "Auto Charge Voltage Control" function rewritten, EOC cycle threshold added to reduce premature triggering of float phase
# V1.17.4 MrPablo : Added "SMA" to CAN BMS names, added function "Auto Charge Voltage Control" to avoid OVP alarms and improve balancing, categorised sensors, set time source to SNTP, min battery voltage based on BMS value, added "Last Complete Charge" timestamp, renamed daily energy sensors and added input number display option
# V1.17.3 Sleeper85 : Renumbering cells, Added “BMS Charging”, “BMS Discharging” and “JK-BMS ESP32 Restart” switches, adding Total Daily Energy sensors, set jk_bms update interval to 3s, set default log level to INFO, improvement of comments
# V1.17.2 MrPablo : Added function "Auto Charge/Discharge Current Control" to avoid OVP/UVP alarms
Expand Down Expand Up @@ -72,6 +73,9 @@ substitutions:
# Factor to adjust the aggression of the auto voltage control logic.
# The higher the setting, the more that requested charge voltage will reduce as cells exceed the target voltage (bulk voltage).
charge_v_factor: "2.0"
# End of charge (EOC) will be triggered if current and max cell voltage meet cut-off thresholds, plus the cycle count exceeds the below threshold.
# As default, this cycle count is set to 60 which is approximately 60 seconds. This will reduce the liklihood of premature EOC.
eoc_cycle_threshold: "60"
# +--------------------------------------+
# | Battery Discharge Settings |
# +--------------------------------------+
Expand Down Expand Up @@ -1214,6 +1218,7 @@ interval:
float cell_bulk_v = (id(bulk_voltage).state / id(cell_count).state);
float cell_rebulk_v = (id(rebulk_voltage).state / id(cell_count).state);
float cell_absorption_offset_v = (id(absorption_offset).state / id(cell_count).state);
static int num_executions = 0;
// Force Bulk Logic
if (id(can_switch_force_bulk).state) {
Expand Down Expand Up @@ -1247,12 +1252,19 @@ interval:
if ((id(current).state <= cutoff_current) & (id(max_cell_voltage).state >= cutoff_voltage)) {
// End Of Charge
if ((!id(equalizing).state)) id(charge_status) = "EOC";
if ((!id(equalizing).state)) {
num_executions += 1;
ESP_LOGI("main", "EOC Cycle Count : %i", num_executions);
if (num_executions > ${eoc_cycle_threshold}) {
num_executions = 0;
id(charge_status) = "EOC";
}
}
}
// Start Charging
else {
num_executions = 0;
// With the "Auto Charge Current Control", the current is reduced automatically if "max_cell_voltage" approaches BMS OVPR
// Balancing : the BMS is equalizing the cells
Expand Down
20 changes: 16 additions & 4 deletions ESP32_Li-ion_BLE_jk-bms-can.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/gpl.html>.

# v1.17.5 MrPablo : "Auto Charge Voltage Control" function rewritten, EOC cycle threshold added to reduce premature triggering of float phase
# V1.17.4 MrPablo : Added "SMA" to CAN BMS names, added function "Auto Charge Voltage Control" to avoid OVP alarms and improve balancing, categorised sensors, set time source to SNTP, min battery voltage based on BMS value, added "Last Complete Charge" timestamp, renamed daily energy sensors and added input number display option
# V1.17.3 Sleeper85 : Renumbering cells, Added “JK-BMS ESP32 Restart” switch, adding Total Daily Energy sensors, set jk_bms update interval to 3s, set default log level to INFO, improvement of comments
# V1.17.2 MrPablo : Added function "Auto Charge/Discharge Current Control" to avoid OVP/UVP alarms
Expand Down Expand Up @@ -80,6 +81,9 @@ substitutions:
# Factor to adjust the aggression of the auto voltage control logic.
# The higher the setting, the more that requested charge voltage will reduce as cells exceed the target voltage (bulk voltage).
charge_v_factor: "2.0"
# End of charge (EOC) will be triggered if current and max cell voltage meet cut-off thresholds, plus the cycle count exceeds the below threshold.
# As default, this cycle count is set to 60 which is approximately 60 seconds. This will reduce the liklihood of premature EOC.
eoc_cycle_threshold: "60"
# +--------------------------------------+
# | Battery Discharge Settings |
# +--------------------------------------+
Expand Down Expand Up @@ -1213,6 +1217,7 @@ interval:
float cell_bulk_v = (id(bulk_voltage).state / id(cell_count).state);
float cell_rebulk_v = (id(rebulk_voltage).state / id(cell_count).state);
float cell_absorption_offset_v = (id(absorption_offset).state / id(cell_count).state);
static int num_executions = 0;
// Force Bulk Logic
if (id(can_switch_force_bulk).state) {
Expand All @@ -1233,25 +1238,32 @@ interval:
// Charging
if (id(current).state >= 0) {
float cv_min = 3.37;
float cv_max = 3.65;
float cutoff_current = (id(battery_capacity).state * 0.05 * (cell_bulk_v - cv_min) / (cv_max - cv_min));
float cutoff_voltage = (cv_min + (cv_max - cv_min)/(0.05 + cell_absorption_offset_v) * (id(current).state / id(battery_capacity).state));
ESP_LOGI("main", "Cut-Off Current : %f", cutoff_current);
ESP_LOGI("main", "Cut-Off Voltage : %f", cutoff_voltage);
ESP_LOGI("main", "Cut-Off Voltage : %f", cutoff_voltage);
// Stop Charging
if ((id(current).state <= cutoff_current) & (id(max_cell_voltage).state >= cutoff_voltage)) {
// End Of Charge
if ((!id(equalizing).state)) id(charge_status) = "EOC";
if ((!id(equalizing).state)) {
num_executions += 1;
ESP_LOGI("main", "EOC Cycle Count : %i", num_executions);
if (num_executions > ${eoc_cycle_threshold}) {
num_executions = 0;
id(charge_status) = "EOC";
}
}
}
// Start Charging
else {
num_executions = 0;
// With the "Auto Charge Current Control", the current is reduced automatically if "max_cell_voltage" approaches BMS OVPR
// Balancing : the BMS is equalizing the cells
Expand Down
16 changes: 14 additions & 2 deletions ESP32_Li-ion_Wire_jk-bms-can.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/gpl.html>.

# v1.17.5 MrPablo : "Auto Charge Voltage Control" function rewritten, EOC cycle threshold added to reduce premature triggering of float phase
# V1.17.4 MrPablo : Added "SMA" to CAN BMS names, added function "Auto Charge Voltage Control" to avoid OVP alarms and improve balancing, categorised sensors, set time source to SNTP, min battery voltage based on BMS value, added "Last Complete Charge" timestamp, renamed daily energy sensors and added input number display option
# V1.17.3 Sleeper85 : Renumbering cells, Added “BMS Charging”, “BMS Discharging” and “JK-BMS ESP32 Restart” switches, adding Total Daily Energy sensors, set jk_bms update interval to 3s, set default log level to INFO, improvement of comments
# V1.17.2 MrPablo : Added function "Auto Charge/Discharge Current Control" to avoid OVP/UVP alarms
Expand Down Expand Up @@ -72,6 +73,9 @@ substitutions:
# Factor to adjust the aggression of the auto voltage control logic.
# The higher the setting, the more that requested charge voltage will reduce as cells exceed the target voltage (bulk voltage).
charge_v_factor: "2.0"
# End of charge (EOC) will be triggered if current and max cell voltage meet cut-off thresholds, plus the cycle count exceeds the below threshold.
# As default, this cycle count is set to 60 which is approximately 60 seconds. This will reduce the liklihood of premature EOC.
eoc_cycle_threshold: "60"
# +--------------------------------------+
# | Battery Discharge Settings |
# +--------------------------------------+
Expand Down Expand Up @@ -1214,6 +1218,7 @@ interval:
float cell_bulk_v = (id(bulk_voltage).state / id(cell_count).state);
float cell_rebulk_v = (id(rebulk_voltage).state / id(cell_count).state);
float cell_absorption_offset_v = (id(absorption_offset).state / id(cell_count).state);
static int num_executions = 0;
// Force Bulk Logic
if (id(can_switch_force_bulk).state) {
Expand Down Expand Up @@ -1247,12 +1252,19 @@ interval:
if ((id(current).state <= cutoff_current) & (id(max_cell_voltage).state >= cutoff_voltage)) {
// End Of Charge
if ((!id(equalizing).state)) id(charge_status) = "EOC";
if ((!id(equalizing).state)) {
num_executions += 1;
ESP_LOGI("main", "EOC Cycle Count : %i", num_executions);
if (num_executions > ${eoc_cycle_threshold}) {
num_executions = 0;
id(charge_status) = "EOC";
}
}
}
// Start Charging
else {
num_executions = 0;
// With the "Auto Charge Current Control", the current is reduced automatically if "max_cell_voltage" approaches BMS OVPR
// Balancing : the BMS is equalizing the cells
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ wifi:
## Changelog
* v1.17.5 MrPablo : "Auto Charge Voltage Control" function rewritten, EOC cycle threshold added to reduce premature triggering of float phase
* V1.17.4 MrPablo : Added "SMA" to CAN BMS names, added function "Auto Charge Voltage Control" to avoid OVP alarms and improve balancing, categorised sensors, set time source to SNTP, min battery voltage based on BMS value, added "Last Complete Charge" timestamp, renamed daily energy sensors and added input number display option
* V1.17.3 Sleeper85 : Renumbering cells, Added “BMS Charging”, “BMS Discharging” and “JK-BMS ESP32 Restart” switches, adding Total Daily Energy sensors, set jk_bms update interval to 3s, set default log level to INFO, improvement of comments
* V1.17.2 MrPablo : Added function "Auto Charge/Discharge Current Control" to avoid OVP/UVP alarms
Expand Down
Binary file modified images/ESPHome_Web_Server.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 56133f7

Please sign in to comment.