From aba193ca85ce39ba67aaa9dafe561d9e4079f253 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20=C3=96ster?= Date: Mon, 1 Sep 2025 23:41:18 +0300 Subject: [PATCH] Remove more USER_SETTINGS --- Software/Software.ino | 8 ++++++++ Software/USER_SETTINGS.h | 19 ------------------- Software/src/battery/DALY-BMS.cpp | 5 +++-- Software/src/datalayer/datalayer.h | 18 +++++++++++------- Software/src/devboard/safety/safety.h | 4 +++- 5 files changed, 25 insertions(+), 29 deletions(-) diff --git a/Software/Software.ino b/Software/Software.ino index e26fc42f..9d9f2c62 100644 --- a/Software/Software.ino +++ b/Software/Software.ino @@ -51,6 +51,14 @@ TaskHandle_t connectivity_loop_task; TaskHandle_t logging_loop_task; TaskHandle_t mqtt_loop_task; +/* Charger settings (Optional, when using generator charging) */ +volatile float CHARGER_SET_HV = 384; // Reasonably appropriate 4.0v per cell charging of a 96s pack +volatile float CHARGER_MAX_HV = 420; // Max permissible output (VDC) of charger +volatile float CHARGER_MIN_HV = 200; // Min permissible output (VDC) of charger +volatile float CHARGER_MAX_POWER = 3300; // Max power capable of charger, as a ceiling for validating config +volatile float CHARGER_MAX_A = 11.5; // Max current output (amps) of charger +volatile float CHARGER_END_A = 1.0; // Current at which charging is considered complete + Logging logging; // Initialization diff --git a/Software/USER_SETTINGS.h b/Software/USER_SETTINGS.h index 3495ae44..6b199614 100644 --- a/Software/USER_SETTINGS.h +++ b/Software/USER_SETTINGS.h @@ -22,29 +22,10 @@ /* Connectivity options */ //#define WIFICONFIG //Enable this line to set a static IP address / gateway /subnet mask for the device. see USER_SETTINGS.cpp for the settings -/* MQTT options */ -// #define MQTT // Enable this line to enable MQTT #define MQTT_QOS 0 // MQTT Quality of Service (0, 1, or 2) #define MQTT_PUBLISH_CELL_VOLTAGES // Enable this line to publish cell voltages to MQTT #define MQTT_TIMEOUT 2000 // MQTT timeout in milliseconds -// 500 = 50.0 °C , Max temperature (Will produce a battery overheat event if above) -#define BATTERY_MAXTEMPERATURE 500 -// -250 = -25.0 °C , Min temperature (Will produce a battery frozen event if below) -#define BATTERY_MINTEMPERATURE -250 -// 150 = 15.0 °C , Max difference between min and max temperature (Will produce a battery temperature deviation event if greater) -#define BATTERY_MAX_TEMPERATURE_DEVIATION 150 -// 300 = 30.0A , Max charge in Amp (Some inverters needs to be limited) -#define BATTERY_MAX_CHARGE_AMP 300 -// 300 = 30.0A , Max discharge in Amp (Some inverters needs to be limited) -#define BATTERY_MAX_DISCHARGE_AMP 300 -// Enable this to manually set voltage limits on how much battery can be discharged/charged. Normally not used. -#define BATTERY_USE_VOLTAGE_LIMITS false -// 5000 = 500.0V , Target charge voltage (Value can be tuned on the fly via webserver). Not used unless BATTERY_USE_VOLTAGE_LIMITS = true -#define BATTERY_MAX_CHARGE_VOLTAGE 5000 -// 3000 = 300.0V, Target discharge voltage (Value can be tuned on the fly via webserver). Not used unless BATTERY_USE_VOLTAGE_LIMITS = true -#define BATTERY_MAX_DISCHARGE_VOLTAGE 3000 - /* Do not change any code below this line */ /* Only change battery specific settings above and in "USER_SETTINGS.cpp" */ typedef struct { diff --git a/Software/src/battery/DALY-BMS.cpp b/Software/src/battery/DALY-BMS.cpp index 9cbeb794..74f92703 100644 --- a/Software/src/battery/DALY-BMS.cpp +++ b/Software/src/battery/DALY-BMS.cpp @@ -27,8 +27,9 @@ void DalyBms::update_values() { datalayer.battery.status.current_dA = current_dA; //value is *10 (150 = 15.0) datalayer.battery.status.remaining_capacity_Wh = (remaining_capacity_mAh * (uint32_t)voltage_dV) / 10000; - datalayer.battery.status.max_charge_power_W = (BATTERY_MAX_CHARGE_AMP * voltage_dV) / 100; - datalayer.battery.status.max_discharge_power_W = (BATTERY_MAX_DISCHARGE_AMP * voltage_dV) / 100; + datalayer.battery.status.max_charge_power_W = (datalayer.battery.settings.max_user_set_charge_dA * voltage_dV) / 100; + datalayer.battery.status.max_discharge_power_W = + (datalayer.battery.settings.max_user_set_discharge_dA * voltage_dV) / 100; // limit power when SoC is low or high uint32_t adaptive_power_limit = 999999; diff --git a/Software/src/datalayer/datalayer.h b/Software/src/datalayer/datalayer.h index 6ac56088..fddc057c 100644 --- a/Software/src/datalayer/datalayer.h +++ b/Software/src/datalayer/datalayer.h @@ -128,18 +128,22 @@ struct DATALAYER_BATTERY_SETTINGS_TYPE { * will "see" 100% Example 8000 = 80.0%*/ uint16_t max_percentage = 8000; - /** The user specified maximum allowed charge rate, in deciAmpere. 300 = 30.0 A */ - uint16_t max_user_set_charge_dA = BATTERY_MAX_CHARGE_AMP; - /** The user specified maximum allowed discharge rate, in deciAmpere. 300 = 30.0 A */ - uint16_t max_user_set_discharge_dA = BATTERY_MAX_DISCHARGE_AMP; + /** The user specified maximum allowed charge rate, in deciAmpere. 300 = 30.0 A + * Updates later on via Settings + */ + uint16_t max_user_set_charge_dA = 300; + /** The user specified maximum allowed discharge rate, in deciAmpere. 300 = 30.0 A + * Updates later on via Settings + */ + uint16_t max_user_set_discharge_dA = 300; /** User specified discharge/charge voltages in use. Set to true to use user specified values */ /** Some inverters like to see a specific target voltage for charge/discharge. Use these values to override automatic voltage limits*/ - bool user_set_voltage_limits_active = BATTERY_USE_VOLTAGE_LIMITS; + bool user_set_voltage_limits_active = false; /** The user specified maximum allowed charge voltage, in deciVolt. 4000 = 400.0 V */ - uint16_t max_user_set_charge_voltage_dV = BATTERY_MAX_CHARGE_VOLTAGE; + uint16_t max_user_set_charge_voltage_dV = 4500; /** The user specified maximum allowed discharge voltage, in deciVolt. 3000 = 300.0 V */ - uint16_t max_user_set_discharge_voltage_dV = BATTERY_MAX_DISCHARGE_VOLTAGE; + uint16_t max_user_set_discharge_voltage_dV = 3000; /** The user specified BMS reset period. Keeps track on how many milliseconds should we keep power off during daily BMS reset */ uint16_t user_set_bms_reset_duration_ms = 30000; diff --git a/Software/src/devboard/safety/safety.h b/Software/src/devboard/safety/safety.h index c402176c..432e05ce 100644 --- a/Software/src/devboard/safety/safety.h +++ b/Software/src/devboard/safety/safety.h @@ -3,7 +3,9 @@ #include #define MAX_CAN_FAILURES 50 - +#define BATTERY_MAX_TEMPERATURE_DEVIATION 150 // 150 = 15.0 °C +#define BATTERY_MAXTEMPERATURE 500 +#define BATTERY_MINTEMPERATURE -250 #define MAX_CHARGE_DISCHARGE_LIMIT_FAILURES 5 //battery pause status begin