Просмотр исходного кода

1. 软件过流保护从50A开始计时
2. shutdown power 改为判断2s,欠压改为判断改为500ms1.

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

huhui 5 лет назад
Родитель
Сommit
ab8ff899bc
2 измененных файлов с 17 добавлено и 14 удалено
  1. 15 12
      Application/app/sox/health.c
  2. 2 2
      Application/bsp/shark_bsp.h

+ 15 - 12
Application/app/sox/health.c

@@ -60,6 +60,8 @@ static debounce_timer_t _load_detect_timer = {.max_count = 100, .interval = 10,
 static debounce_timer_t _charger_detect_timer = {.max_count = 500, .interval = 10, ._timer.handler = charger_detect_handler};
 static shark_timer_t _clear_short_current_timer = {.handler = clear_short_current_handler};
 static error_counts_t error_counts;
+static u16 discharger_lower_cell_voltage = 0;
+static u16 discharger_lower_voltage = 0;
 
 void health_init(void){
 	/* 5238如果有异常情况,比如短路,负载移除,通过这个handler上报 */
@@ -77,6 +79,7 @@ void health_log(void){
 	health_debug("hard short:%d\n", error_counts.hard_current_short);
 	health_debug("work temp: %d\n", _health.is_work_temp_normal);
 	health_debug("aux_short: %d, %d\n", error_counts.aux_short, error_counts.aux_real_short);
+	health_debug("lower voltage: %d, %d\n", discharger_lower_cell_voltage, discharger_lower_voltage);
 }
 
 bms_health_t *bms_health(){
@@ -189,12 +192,12 @@ void check_current_state(void){
 }
 
 /* 检测pack电压,cell电压,pack电压过低触发powerdown*/
-static debounce_t _discharger_lower_voltage = {.count = 0, .max_count = 10, .init_count = 0};
-static debounce_t _power_down_voltage = {.count = 0, .max_count = 10, .init_count = 0};
-static debounce_t _sigle_cell_discharger_lower_vol = {.count = 0, .max_count = 5, .init_count = 0};
-static debounce_t _sigle_cell_charger_max_vol = {.count = 0, .max_count = 15, .init_count = 0};
-static debounce_t _shut_discharger_lower_voltage = {.count = 0, .max_count = 20,};
-static debounce_t _shut_discharger_cell_lower_voltage = {.count = 0, .max_count = 20,};
+static debounce_t _discharger_lower_voltage = {.count = 0, .max_count = 20, .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 = 100, .init_count = 0};
+static debounce_t _sigle_cell_charger_max_vol = {.count = 0, .max_count = 20, .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};
 
 static int judge_debounce(int input, debounce_t *d){
 	if (input) {
@@ -246,30 +249,29 @@ void check_voltage_state(void) {
 		if ((bms_state_get()->cell_min_vol <= min_discharger_cell_vol[_health.is_work_temp_normal])){
 			if (judge_debounce(!_health.sigle_cell_lower_voltage, &_sigle_cell_discharger_lower_vol)){
 				_health.sigle_cell_lower_voltage = 1;
-				_sigle_cell_discharger_lower_vol.max_count = 30;//从欠压恢复可以稍微慢一点
+				discharger_lower_cell_voltage = bms_state_get()->cell_min_vol;
 			}
 		}else if ((bms_state_get()->cell_min_vol >= min_discharger_cell_recovery_vol[_health.is_work_temp_normal])){
 			if (judge_debounce(_health.sigle_cell_lower_voltage, &_sigle_cell_discharger_lower_vol)){
 				_health.sigle_cell_lower_voltage = 0;
-				_sigle_cell_discharger_lower_vol.max_count = 5;
 			}
 		}
 		//check sigle pack's voltage for discharger
 		if (bms_state_get()->pack_voltage <= min_discharger_vol[_health.is_work_temp_normal]){
 			if (judge_debounce(!_health.discharger_lower_voltage, &_discharger_lower_voltage)){
 				_health.discharger_lower_voltage = 1;
-				_discharger_lower_voltage.max_count = 30; //从欠压恢复可以稍微慢一点
+				discharger_lower_voltage = bms_state_get()->pack_voltage;
 			}
 		}else if (bms_state_get()->pack_voltage >= min_discharger_recovery_vol[_health.is_work_temp_normal]){
 			if (judge_debounce(_health.discharger_lower_voltage, &_discharger_lower_voltage)){
 				_health.discharger_lower_voltage = 0;
-				_discharger_lower_voltage.max_count = 10;
 			}
 		}
 		//check for shutdown power
 		if ((bms_state_get()->cell_min_vol <= min_discharger_power_cell_vol[_health.is_work_temp_normal])){
 			if (judge_debounce(!_health.discharger_cell_shutpower_voltage, &_shut_discharger_cell_lower_voltage)){
 				_health.discharger_cell_shutpower_voltage = 1;
+				discharger_lower_cell_voltage = bms_state_get()->cell_min_vol;
 			}
 		}else if ((bms_state_get()->cell_min_vol >= min_discharger_power_recovery_cell_vol[_health.is_work_temp_normal])){
 			if (judge_debounce(_health.discharger_cell_shutpower_voltage, &_shut_discharger_cell_lower_voltage)){
@@ -277,11 +279,12 @@ void check_voltage_state(void) {
 			}
 		}
 		if ((bms_state_get()->pack_voltage <= min_discharger_power_vol[_health.is_work_temp_normal])){
-			if (judge_debounce(!_health.discharger_cell_shutpower_voltage, &_shut_discharger_lower_voltage)){
+			if (judge_debounce(!_health.discharger_shutpower_voltage, &_shut_discharger_lower_voltage)){
 				_health.discharger_shutpower_voltage = 1;
+				discharger_lower_voltage = bms_state_get()->pack_voltage;
 			}
 		}else if ((bms_state_get()->pack_voltage >= min_discharger_power_recovery_vol[_health.is_work_temp_normal])){
-			if (judge_debounce(_health.discharger_cell_shutpower_voltage, &_shut_discharger_lower_voltage)){
+			if (judge_debounce(_health.discharger_shutpower_voltage, &_shut_discharger_lower_voltage)){
 				_health.discharger_shutpower_voltage = 0;
 			}
 		}

+ 2 - 2
Application/bsp/shark_bsp.h

@@ -26,7 +26,7 @@
 #if (CONFIG_BOARD_TYPE==SHARK_BOARD_SP700)
 #define r_resistor 1.0f // 1ºÁÅ·
 #define MAX_HA (30.0f)
-#define MAX_SOFT_CURRENT (45)
+#define MAX_SOFT_CURRENT (50)
 #define MAX_I2T  (2500.0f * 2)
 #define UART_NUM 2
 #elif (CONFIG_BOARD_TYPE==SHARK_BOARD_SP600)
@@ -36,7 +36,7 @@
 #else
 #define MAX_HA (22.5f)
 #endif
-#define MAX_SOFT_CURRENT (23)
+#define MAX_SOFT_CURRENT (25)
 #define MAX_I2T  (900.0f * 2)
 #define UART_NUM 1
 #endif