mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-05 02:39:57 +02:00
Merge branch 'main' into can-frames
This commit is contained in:
commit
c63913e810
4 changed files with 33 additions and 14 deletions
|
@ -151,7 +151,10 @@ void BydAttoBattery::
|
|||
datalayer_battery->status.voltage_dV = BMS_voltage * 10;
|
||||
}
|
||||
|
||||
#ifdef USE_ESTIMATED_SOC
|
||||
if (SOC_method == MEASURED) {
|
||||
// Pack is not crashed, we can use periodically transmitted SOC
|
||||
datalayer_battery->status.real_soc = battery_highprecision_SOC * 10;
|
||||
} else {
|
||||
// When the battery is crashed hard, it locks itself and SOC becomes unavailable.
|
||||
// We instead estimate the SOC% based on the battery voltage.
|
||||
// This is a bad solution, you wont be able to use 100% of the battery
|
||||
|
@ -161,11 +164,7 @@ void BydAttoBattery::
|
|||
if (battery_type == STANDARD_RANGE) {
|
||||
datalayer_battery->status.real_soc = estimateSOCstandard(datalayer_battery->status.voltage_dV);
|
||||
}
|
||||
SOC_method = ESTIMATED;
|
||||
#else // Pack is not crashed, we can use periodically transmitted SOC
|
||||
datalayer_battery->status.real_soc = battery_highprecision_SOC * 10;
|
||||
SOC_method = MEASURED;
|
||||
#endif
|
||||
}
|
||||
|
||||
datalayer_battery->status.current_dA = -BMS_current;
|
||||
|
||||
|
@ -691,6 +690,11 @@ void BydAttoBattery::setup(void) { // Performs one time setup at startup
|
|||
datalayer_battery->info.max_cell_voltage_mV = MAX_CELL_VOLTAGE_MV;
|
||||
datalayer_battery->info.min_cell_voltage_mV = MIN_CELL_VOLTAGE_MV;
|
||||
datalayer_battery->info.max_cell_voltage_deviation_mV = MAX_CELL_DEVIATION_MV;
|
||||
#ifdef USE_ESTIMATED_SOC // Initial setup for selected SOC method
|
||||
SOC_method = ESTIMATED;
|
||||
#else
|
||||
SOC_method = MEASURED;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -57,6 +57,13 @@ class BydAttoBattery : public CanBattery {
|
|||
|
||||
void reset_crash() { datalayer_bydatto->UserRequestCrashReset = true; }
|
||||
|
||||
#ifndef USE_ESTIMATED_SOC
|
||||
// Toggle SOC method in UI is only enabled if we initially use measured SOC
|
||||
bool supports_toggle_SOC_method() { return true; }
|
||||
#endif
|
||||
|
||||
void toggle_SOC_method() { SOC_method = !SOC_method; }
|
||||
|
||||
BatteryHtmlRenderer& get_status_renderer() { return renderer; }
|
||||
|
||||
private:
|
||||
|
|
|
@ -29,6 +29,7 @@ class Battery {
|
|||
virtual bool supports_set_fake_voltage() { return false; }
|
||||
virtual bool supports_manual_balancing() { return false; }
|
||||
virtual bool supports_real_BMS_status() { return false; }
|
||||
virtual bool supports_toggle_SOC_method() { return false; }
|
||||
|
||||
virtual void clear_isolation() {}
|
||||
virtual void reset_BMS() {}
|
||||
|
@ -40,6 +41,7 @@ class Battery {
|
|||
virtual void reset_BECM() {}
|
||||
virtual void request_open_contactors() {}
|
||||
virtual void request_close_contactors() {}
|
||||
virtual void toggle_SOC_method() {}
|
||||
|
||||
virtual void set_fake_voltage(float v) {}
|
||||
virtual float get_voltage() { static_cast<float>(datalayer.battery.status.voltage_dV) / 10.0; }
|
||||
|
|
|
@ -56,6 +56,12 @@ std::vector<BatteryCommand> battery_commands = {
|
|||
[](Battery* b) {
|
||||
b->reset_SOH();
|
||||
}},
|
||||
{"toggleSOC", "Toggle SOC method",
|
||||
"toggle SOC method? This will toggle between ESTIMATED and MEASURED SOC methods.",
|
||||
[](Battery* b) { return b && b->supports_toggle_SOC_method(); },
|
||||
[](Battery* b) {
|
||||
b->toggle_SOC_method();
|
||||
}},
|
||||
};
|
||||
|
||||
String advanced_battery_processor(const String& var) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue