فهرست منبع

1. balance 时间3s停100ms
2. 单电芯过压3.75v,容量校准到100%
3. 解决骑行一充一放导致容量始终100%的问题

Signed-off-by: huhui <huhui@sharkgulf.com>

huhui 4 سال پیش
والد
کامیت
297f5445af
4فایلهای تغییر یافته به همراه16 افزوده شده و 7 حذف شده
  1. 1 1
      Application/app/sox/health.c
  2. 1 1
      Application/app/sox/health.h
  3. 11 3
      Application/app/sox/soc.c
  4. 3 2
      Application/app/sox/state.c

+ 1 - 1
Application/app/sox/health.c

@@ -203,7 +203,7 @@ void check_current_state(void){
 static debounce_t _discharger_lower_voltage = {.count = 0, .max_count = 200, .init_count = 0};
 static debounce_t _power_down_voltage = {.count = 0, .max_count = 20, .init_count = 0};
 static debounce_t _sigle_cell_discharger_lower_vol = {.count = 0, .max_count = 200, .init_count = 0};
-static debounce_t _sigle_cell_charger_max_vol = {.count = 0, .max_count = 20, .init_count = 0};
+static debounce_t _sigle_cell_charger_max_vol = {.count = 0, .max_count = 50, .init_count = 0};
 static debounce_t _shut_discharger_lower_voltage = {.count = 0, .max_count = 20,.init_count = 0};
 static debounce_t _shut_discharger_cell_lower_voltage = {.count = 0, .max_count = 400,.init_count = 0};
 

+ 1 - 1
Application/app/sox/health.h

@@ -4,7 +4,7 @@
 #include "bsp/shark_bsp.h"
 
 #define MAX_CURRENT_FOR_CHARGER (30*1000) //最大充电电流20A
-#define SIGLE_CELL_MAX_CHARGER_VOLTAGE (3800)//最大允许充电电压,3.9v,考虑到采样的误差取 3.88
+#define SIGLE_CELL_MAX_CHARGER_VOLTAGE (3750)//最大允许充电电压,3.9v,考虑到采样的误差取 3.88
 #define MAX_CURRENT_FOR_DISCHARGER (120 * 1000) //软件采样的电流保护
 #define AUX_SHORT_REAL_DIFF_VOLTAGE (5) //判断小电流是否真实短路的,端口压差
 #define AUX_SHORT_DIFF_VOLTAGE (7.5f) //判断小电流是否保护,28欧姆上的电压,能抗300mA

+ 11 - 3
Application/app/sox/soc.c

@@ -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;

+ 3 - 2
Application/app/sox/state.c

@@ -605,11 +605,12 @@ static void _balance_timer_handler(shark_timer_t *t);
 
 static shark_timer_t _balance_timer = {.handler = _balance_timer_handler};
 
-static debounce_t _cell_balance = {.count = 0, .max_count = 10, .init_count = 0};
+static debounce_t _cell_balance = {.count = 0, .max_count = 120, .init_count = 0};
 
 static void _balance_timer_handler(shark_timer_t *t){
 	ml5238_cell_start_balance(0);
 	_bms_state.pack_balancing = 0;
+	debounce_reset(_cell_balance);
 }
 
 static uint32_t get_balance_mask(uint8_t current_max_index){
@@ -637,7 +638,7 @@ static void check_cell_balance(uint8_t current_max_index){
 	if (!_bms_state.pack_balancing && debounce_reach_max(_cell_balance)){
 		_bms_state.pack_balancing = 1;
 		ml5238_cell_start_balance(get_balance_mask(current_max_index));
-		shark_timer_post(&_balance_timer, 30 * 1000); //stop balance after 30s
+		shark_timer_post(&_balance_timer, 5 * 1000); //stop balance after 30s
 		debounce_reset(_cell_balance);
 	}
 	_bms_state.cell_index_of_max_vol = current_max_index;