Skip to content

Commit

Permalink
Front end changes for SOH
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartpittaway committed Dec 7, 2023
1 parent c6eb40a commit 5426e6d
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ESPController/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3201,7 +3201,7 @@ void send_ext_canbus_message(const uint32_t identifier, const uint8_t *buffer, c
void CalculateStateOfHealth(diybms_eeprom_settings *settings)
{
// Value indicating what a typical discharge cycle looks like in amp-hours (normally 80% of cell for LFP)
float depth = 1000.0F * ((float)settings->currentMonitoring_batterycapacity/100.0F * (float)settings->soh_discharge_depth);
float depth = 1000.0F * ((float)settings->nominalbatcap/100.0F * (float)settings->soh_discharge_depth);
float in = (float)settings->soh_total_milliamphour_in / depth;
float out = (float)settings->soh_total_milliamphour_out / depth;
//Take worst case
Expand Down
8 changes: 8 additions & 0 deletions ESPController/src/webserver_json_requests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,14 @@ esp_err_t content_handler_chargeconfig(httpd_req_t *req)
settings["canbusbaud"] = mysettings.canbusbaud;
settings["equip_addr"] = mysettings.canbus_equipment_addr;
settings["nominalbatcap"] = mysettings.nominalbatcap;

settings["depthofdischarge"] = mysettings.soh_discharge_depth;
settings["expectedlifetime_cycles"] = mysettings.soh_lifetime_battery_cycles;
settings["total_mah_charge"] = mysettings.soh_total_milliamphour_in;
settings["total_mah_discharge"] = mysettings.soh_total_milliamphour_out;
settings["estimatebatterycycle"] = mysettings.soh_estimated_battery_cycles;
settings["stateofhealth"] = mysettings.soh_percent;

settings["chargevolt"] = mysettings.chargevolt;
settings["chargecurrent"] = mysettings.chargecurrent;
settings["dischargecurrent"] = mysettings.dischargecurrent;
Expand Down
22 changes: 21 additions & 1 deletion ESPController/web_src/default.htm
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ <h1>History</h1>
<th id="ht1">Date/time</th>
<th id="ht2">Voltage</th>
<th id="ht3">Current</th>
<th id="ht4">SoC%</th>
<th id="ht4">SoC%%</th>
<th id="ht5">mA In</th>
<th id="ht6">mA Out</th>
<th id="ht7">Highest Range</th>
Expand Down Expand Up @@ -1034,6 +1034,26 @@ <h1 id="v0">Charge/Discharge configuration</h1>
<label for="nominalbatcap">Nominal Battery Capacity (Amp-hours)</label>
<input id="nominalbatcap" name="nominalbatcap" value="" type="number" min="1" max="9999" step="1" />
</div>
<div>
<label for="expected_cycles">Expected battery lifetime/cycles (at 80%% DOD)</label>
<input id="expected_cycles" name="expected_cycles" value="" type="number" min="100" max="99999" step="1" />
</div>
<div>
<label for="total_ah_charge">Lifetime amp-hours charge (in)</label>
<input id="total_ah_charge" name="total_ah_charge" value="" type="number" min="0" step="1" />
</div>
<div>
<label for="total_ah_discharge">Lifetime amp-hours discharge (out)</label>
<input id="total_ah_discharge" name="total_ah_discharge" value="" type="number" min="0" step="1" />
</div>
<div>
<label for="estimate_bat_cycle">Estimated battery cycles consumed</label>
<input id="estimate_bat_cycle" name="estimate_bat_cycle" value="" type="number" readonly="" />
</div>
<div>
<label for="stateofhealth">State of health (%%)</label>
<input id="stateofhealth" name="stateofhealth" value="" type="number" readonly="" />
</div>

<p>Charging</p>
<div>
Expand Down
6 changes: 6 additions & 0 deletions ESPController/web_src/pagecode.js
Original file line number Diff line number Diff line change
Expand Up @@ -2003,6 +2003,12 @@ $(function () {
$("#canbusbaud").val(data.chargeconfig.canbusbaud);
$("#nominalbatcap").val(data.chargeconfig.nominalbatcap);

$("#expected_cycles").val(data.chargeconfig.expectedlifetime_cycles);
$("#total_ah_charge").val(Math.trunc(data.chargeconfig.total_mah_charge/1000));
$("#total_ah_discharge").val(Math.trunc(data.chargeconfig.total_mah_discharge/1000));
$("#estimate_bat_cycle").val(data.chargeconfig.estimatebatterycycle);
$("#stateofhealth").val((data.chargeconfig.stateofhealth).toFixed(2));

$("#chargevolt").val((data.chargeconfig.chargevolt / 10.0).toFixed(1));
$("#chargecurrent").val((data.chargeconfig.chargecurrent / 10.0).toFixed(1));
$("#dischargecurrent").val((data.chargeconfig.dischargecurrent / 10.0).toFixed(1));
Expand Down

0 comments on commit 5426e6d

Please sign in to comment.