mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-03 09:49:32 +02:00
Add configurable option for estimated SOC
This commit is contained in:
parent
3ead4d12d4
commit
15143d1384
7 changed files with 33 additions and 15 deletions
|
@ -296,6 +296,8 @@ bool user_selected_tesla_GTW_rightHandDrive = true;
|
||||||
uint16_t user_selected_tesla_GTW_mapRegion = 2;
|
uint16_t user_selected_tesla_GTW_mapRegion = 2;
|
||||||
uint16_t user_selected_tesla_GTW_chassisType = 2;
|
uint16_t user_selected_tesla_GTW_chassisType = 2;
|
||||||
uint16_t user_selected_tesla_GTW_packEnergy = 1;
|
uint16_t user_selected_tesla_GTW_packEnergy = 1;
|
||||||
|
/* User-selected EGMP+others settings */
|
||||||
|
bool user_selected_use_estimated_SOC = false;
|
||||||
|
|
||||||
// Use 0V for user selected cell/pack voltage defaults (On boot will be replaced with saved values from NVM)
|
// Use 0V for user selected cell/pack voltage defaults (On boot will be replaced with saved values from NVM)
|
||||||
uint16_t user_selected_max_pack_voltage_dV = 0;
|
uint16_t user_selected_max_pack_voltage_dV = 0;
|
||||||
|
|
|
@ -62,7 +62,7 @@ extern uint16_t user_selected_max_pack_voltage_dV;
|
||||||
extern uint16_t user_selected_min_pack_voltage_dV;
|
extern uint16_t user_selected_min_pack_voltage_dV;
|
||||||
extern uint16_t user_selected_max_cell_voltage_mV;
|
extern uint16_t user_selected_max_cell_voltage_mV;
|
||||||
extern uint16_t user_selected_min_cell_voltage_mV;
|
extern uint16_t user_selected_min_cell_voltage_mV;
|
||||||
|
extern bool user_selected_use_estimated_SOC;
|
||||||
extern bool user_selected_LEAF_interlock_mandatory;
|
extern bool user_selected_LEAF_interlock_mandatory;
|
||||||
extern bool user_selected_tesla_digital_HVIL;
|
extern bool user_selected_tesla_digital_HVIL;
|
||||||
extern uint16_t user_selected_tesla_GTW_country;
|
extern uint16_t user_selected_tesla_GTW_country;
|
||||||
|
|
|
@ -114,16 +114,17 @@ uint8_t KiaEGmpBattery::calculateCRC(CAN_frame rx_frame, uint8_t length, uint8_t
|
||||||
|
|
||||||
void KiaEGmpBattery::update_values() {
|
void KiaEGmpBattery::update_values() {
|
||||||
|
|
||||||
#ifdef ESTIMATE_SOC_FROM_CELLVOLTAGE
|
if (user_selected_use_estimated_SOC) {
|
||||||
// Use the simplified pack-based SOC estimation with proper compensation
|
// Use the simplified pack-based SOC estimation with proper compensation
|
||||||
datalayer.battery.status.real_soc = estimateSOC(batteryVoltage, datalayer.battery.info.number_of_cells, batteryAmps);
|
datalayer.battery.status.real_soc =
|
||||||
|
estimateSOC(batteryVoltage, datalayer.battery.info.number_of_cells, batteryAmps);
|
||||||
|
|
||||||
// For comparison or fallback, we can still calculate from min/max cell voltages
|
// For comparison or fallback, we can still calculate from min/max cell voltages
|
||||||
SOC_estimated_lowest = estimateSOCFromCell(CellVoltMin_mV);
|
SOC_estimated_lowest = estimateSOCFromCell(CellVoltMin_mV);
|
||||||
SOC_estimated_highest = estimateSOCFromCell(CellVoltMax_mV);
|
SOC_estimated_highest = estimateSOCFromCell(CellVoltMax_mV);
|
||||||
#else
|
} else {
|
||||||
datalayer.battery.status.real_soc = (SOC_Display * 10); //increase SOC range from 0-100.0 -> 100.00
|
datalayer.battery.status.real_soc = (SOC_Display * 10); //increase SOC range from 0-100.0 -> 100.00
|
||||||
#endif
|
}
|
||||||
|
|
||||||
datalayer.battery.status.soh_pptt = (batterySOH * 10); //Increase decimals from 100.0% -> 100.00%
|
datalayer.battery.status.soh_pptt = (batterySOH * 10); //Increase decimals from 100.0% -> 100.00%
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#include "CanBattery.h"
|
#include "CanBattery.h"
|
||||||
#include "KIA-E-GMP-HTML.h"
|
#include "KIA-E-GMP-HTML.h"
|
||||||
|
|
||||||
#define ESTIMATE_SOC_FROM_CELLVOLTAGE
|
extern bool user_selected_use_estimated_SOC;
|
||||||
|
|
||||||
class KiaEGmpBattery : public CanBattery {
|
class KiaEGmpBattery : public CanBattery {
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -104,6 +104,7 @@ void init_stored_settings() {
|
||||||
user_selected_can_addon_crystal_frequency_mhz = settings.getUInt("CANFREQ", 8);
|
user_selected_can_addon_crystal_frequency_mhz = settings.getUInt("CANFREQ", 8);
|
||||||
user_selected_canfd_addon_crystal_frequency_mhz = settings.getUInt("CANFDFREQ", 40);
|
user_selected_canfd_addon_crystal_frequency_mhz = settings.getUInt("CANFDFREQ", 40);
|
||||||
user_selected_LEAF_interlock_mandatory = settings.getBool("INTERLOCKREQ", false);
|
user_selected_LEAF_interlock_mandatory = settings.getBool("INTERLOCKREQ", false);
|
||||||
|
user_selected_use_estimated_SOC = settings.getBool("SOCESTIMATED", false);
|
||||||
user_selected_tesla_digital_HVIL = settings.getBool("DIGITALHVIL", false);
|
user_selected_tesla_digital_HVIL = settings.getBool("DIGITALHVIL", false);
|
||||||
user_selected_tesla_GTW_country = settings.getUInt("GTWCOUNTRY", 0);
|
user_selected_tesla_GTW_country = settings.getUInt("GTWCOUNTRY", 0);
|
||||||
user_selected_tesla_GTW_rightHandDrive = settings.getBool("GTWRHD", false);
|
user_selected_tesla_GTW_rightHandDrive = settings.getBool("GTWRHD", false);
|
||||||
|
|
|
@ -251,6 +251,10 @@ String settings_processor(const String& var, BatteryEmulatorSettingsStore& setti
|
||||||
return settings.getBool("DBLBTR") ? "checked" : "";
|
return settings.getBool("DBLBTR") ? "checked" : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (var == "SOCESTIMATED") {
|
||||||
|
return settings.getBool("SOCESTIMATED") ? "checked" : "";
|
||||||
|
}
|
||||||
|
|
||||||
if (var == "CNTCTRL") {
|
if (var == "CNTCTRL") {
|
||||||
return settings.getBool("CNTCTRL") ? "checked" : "";
|
return settings.getBool("CNTCTRL") ? "checked" : "";
|
||||||
}
|
}
|
||||||
|
@ -912,6 +916,11 @@ const char* getCANInterfaceName(CAN_Interface interface) {
|
||||||
display: contents;
|
display: contents;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
form .if-socestimated { display: none; } /* Integrations where you can turn on SOC estimation */
|
||||||
|
form[data-battery="16"] .if-socestimated {
|
||||||
|
display: contents;
|
||||||
|
}
|
||||||
|
|
||||||
form .if-dblbtr { display: none; }
|
form .if-dblbtr { display: none; }
|
||||||
form[data-dblbtr="true"] .if-dblbtr {
|
form[data-dblbtr="true"] .if-dblbtr {
|
||||||
display: contents;
|
display: contents;
|
||||||
|
@ -1022,6 +1031,11 @@ const char* getCANInterfaceName(CAN_Interface interface) {
|
||||||
<input name='DCHGPOWER' pattern="^[0-9]+$" type='text' value='%DCHGPOWER%' />
|
<input name='DCHGPOWER' pattern="^[0-9]+$" type='text' value='%DCHGPOWER%' />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="if-socestimated">
|
||||||
|
<label>Use estimated SOC: </label>
|
||||||
|
<input type='checkbox' name='SOCESTIMATED' value='on' %SOCESTIMATED% />
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="if-battery">
|
<div class="if-battery">
|
||||||
<label for='BATTCOMM'>Battery interface: </label><select name='BATTCOMM' id='BATTCOMM'>
|
<label for='BATTCOMM'>Battery interface: </label><select name='BATTCOMM' id='BATTCOMM'>
|
||||||
%BATTCOMM%
|
%BATTCOMM%
|
||||||
|
|
|
@ -400,7 +400,7 @@ void init_webserver() {
|
||||||
"DBLBTR", "CNTCTRL", "CNTCTRLDBL", "PWMCNTCTRL", "PERBMSRESET", "SDLOGENABLED", "STATICIP",
|
"DBLBTR", "CNTCTRL", "CNTCTRLDBL", "PWMCNTCTRL", "PERBMSRESET", "SDLOGENABLED", "STATICIP",
|
||||||
"REMBMSRESET", "EXTPRECHARGE", "USBENABLED", "CANLOGUSB", "WEBENABLED", "CANFDASCAN", "CANLOGSD",
|
"REMBMSRESET", "EXTPRECHARGE", "USBENABLED", "CANLOGUSB", "WEBENABLED", "CANFDASCAN", "CANLOGSD",
|
||||||
"WIFIAPENABLED", "MQTTENABLED", "NOINVDISC", "HADISC", "MQTTTOPICS", "MQTTCELLV", "INVICNT",
|
"WIFIAPENABLED", "MQTTENABLED", "NOINVDISC", "HADISC", "MQTTTOPICS", "MQTTCELLV", "INVICNT",
|
||||||
"GTWRHD", "DIGITALHVIL", "PERFPROFILE", "INTERLOCKREQ",
|
"GTWRHD", "DIGITALHVIL", "PERFPROFILE", "INTERLOCKREQ", "SOCESTIMATED",
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handles the form POST from UI to save settings of the common image
|
// Handles the form POST from UI to save settings of the common image
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue