|
|
@@ -27,6 +27,8 @@ static const float _discharger_gain[] = {1.0f/*>0
|
|
|
#define SIGAL_CELL_OV_MAX_PACK_VOL (53000)
|
|
|
#define FULL_MAX_VOLTAGE (54000) //mV
|
|
|
#define FULL_MIN_CURRENT (500.0f) //mA
|
|
|
+static int _full_reason = 0;
|
|
|
+static int _force_full = 0;
|
|
|
static void calibrate_soc_by_ocv(void);
|
|
|
static void _soc_clear(void);
|
|
|
|
|
|
@@ -194,7 +196,7 @@ void soc_log(void){
|
|
|
soc_debug("C energy: %f\n", _soc.energy);
|
|
|
soc_debug("C delta time %f,%f, -- %d\n", max_soc_delta_time, soc_delta_time, force_full_ts);
|
|
|
soc_debug("C discharger coefficient = %f\n", _discharger_coefficient);
|
|
|
- soc_debug("C SOH = %d\n", soc_get_soh());
|
|
|
+ soc_debug("forcce full = %d, %d\n", _full_reason, _force_full);
|
|
|
if (chargering){
|
|
|
soc_debug("C remain %d\n", charger_remain_time);
|
|
|
}
|
|
|
@@ -251,7 +253,9 @@ static __inline__ int can_modify_min_cap(void){
|
|
|
|
|
|
static void _force_capacity_full(void){
|
|
|
_soc.capacity = 100;
|
|
|
+ _soc.coulomb_now = _soc.coulomb_max;//充满后,当前容量设置为最大容量
|
|
|
force_full_ts = shark_get_seconds();
|
|
|
+ _force_full = 2;
|
|
|
}
|
|
|
|
|
|
static int _soc_is_under_voltage(void) {
|
|
|
@@ -319,8 +323,9 @@ static int _soc_update_by_ocv(uint8_t prev_charge_status){
|
|
|
ocv_full_count = 0;
|
|
|
return changed;
|
|
|
}*/
|
|
|
- if (chargering && bms_health()->sigle_cell_over_voltage && (_soc.charger_coulomb >= (0.1f * 3600.0f))) { //单电芯过压强制充满
|
|
|
+ if (chargering && bms_health()->sigle_cell_over_voltage) { //单电芯过压强制充满
|
|
|
_force_capacity_full();
|
|
|
+ _full_reason = 3;
|
|
|
if (bms_state_get()->pack_voltage < SIGAL_CELL_OV_MAX_PACK_VOL) {
|
|
|
force_full_ts = 0; //单电芯过压,总电压小于SIGAL_CELL_OV_MAX_PACK_VOL, 放电欠压后不校准最小容量
|
|
|
}
|
|
|
@@ -331,6 +336,7 @@ static int _soc_update_by_ocv(uint8_t prev_charge_status){
|
|
|
if (bms_state_get()->pack_voltage >= (FULL_MAX_VOLTAGE_CHARGING) && (measure_value()->load_current <= FULL_MIN_CURRENT)){
|
|
|
if (ocv_full_count++ >= 100) { //连续100次(小电流采集30ms一次,就是3s时间)电压和电流满足条件,强制充满
|
|
|
_force_capacity_full();
|
|
|
+ _full_reason = 4;
|
|
|
ocv_full_count = 0;
|
|
|
changed = 1;
|
|
|
}
|
|
|
@@ -340,6 +346,7 @@ static int _soc_update_by_ocv(uint8_t prev_charge_status){
|
|
|
}else if (!chargering && prev_charge_status && (_soc.capacity != 100)){
|
|
|
if ((bms_state_get()->pack_voltage >= FULL_MAX_VOLTAGE) && (_soc.charger_coulomb >= (0.1f * 3600.0f))){//充电容量几乎接近最大容量
|
|
|
_force_capacity_full();
|
|
|
+ _full_reason = 5;
|
|
|
changed = 1;
|
|
|
}
|
|
|
}
|
|
|
@@ -363,12 +370,14 @@ static void soc_calibrate(uint8_t prev_charge_status){
|
|
|
if (cali_full_count >= 20 || bms_health()->sigle_cell_over_voltage) {
|
|
|
soc_debug("calibrate Capacity to 100, measure_value()->load_current %d\n", measure_value()->load_current);
|
|
|
_force_capacity_full();
|
|
|
+ _full_reason = 1;
|
|
|
}
|
|
|
}
|
|
|
}else if (prev_charge_status){
|
|
|
if((_soc.capacity != 100) && ((bms_state_get()->pack_voltage >= FULL_MAX_VOLTAGE) || bms_health()->sigle_cell_over_voltage)){
|
|
|
soc_debug("calibrate Capacity to 100\n");
|
|
|
_force_capacity_full();
|
|
|
+ _full_reason = 2;
|
|
|
}
|
|
|
}else {
|
|
|
if (_soc.capacity && _soc_is_under_voltage()) {
|
|
|
@@ -462,7 +471,6 @@ static void soc_update_by_current_and_time(float current_now, float delta_time,
|
|
|
|
|
|
//如果没有校准过,充电过程中,电量100%后,设置校准标志位
|
|
|
if (chargering && (_soc.capacity == 100)){
|
|
|
- _soc.coulomb_now = _soc.coulomb_max;//充满后,当前容量设置为最大容量
|
|
|
if ((_soc.flags & SOC_FLAG_CALIBRATED) == 0){
|
|
|
_soc.flags |= SOC_FLAG_CALIBRATED;
|
|
|
update_capticy = 1;
|