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

加入短路计数

Signed-off-by: huhui <huhui@sharkgulf.com>
huhui 5 лет назад
Родитель
Сommit
7e7d4ae3d7
3 измененных файлов с 17 добавлено и 0 удалено
  1. 1 0
      Application/app/bms_message.c
  2. 10 0
      Application/app/sox/health.c
  3. 6 0
      Application/app/sox/health.h

+ 1 - 0
Application/app/bms_message.c

@@ -203,6 +203,7 @@ void process_bms_message(can_frame_t *frame, int len){
 				set_log_all(L_debug);
 				ml5238_reg_log(); //just for debug
 				cs1180_log();
+				health_log();
 				result = 1;
 			} else if (len < 2) {
 				set_log_all(frame->data[0]);

+ 10 - 0
Application/app/sox/health.c

@@ -54,6 +54,9 @@ static bms_health_t _health;
 static debounce_timer_t _load_detect_timer = {.max_count = 100, .interval = 10, ._timer.handler = load_detect_handler};
 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;
+
 void health_init(void){
 	/* 5238如果有异常情况,比如短路,负载移除,通过这个handler上报 */
 	ml5238_register_notify_handler(check_ml5238_state);
@@ -65,6 +68,11 @@ void health_init(void){
 	_health.is_work_temp_normal = 1;
 }
 
+void health_log(void){
+	health_debug("soft short:%d\n", error_counts.soft_current_short);
+	health_debug("hard short:%d\n", error_counts.hard_current_short);
+}
+
 bms_health_t *bms_health(){
 	return &_health;
 }
@@ -120,6 +128,7 @@ static void check_ml5238_state(int event){
 		shark_timer_post(&_charger_detect_timer._timer, _charger_detect_timer.interval);
 	}else if (event == ML5238_Event_Short_Current) { //ml5238触发短路保护,充放电mos全部关闭
 		_health.load_current_short = 1;
+		error_counts.hard_current_short ++;
 		ml5238_enable_load_detect(1); //打开负载检测
 		shark_timer_post(&_load_detect_timer._timer, _load_detect_timer.interval);
 	}else if (event == ML5238_Event_Load_Disconnect) {
@@ -168,6 +177,7 @@ void check_current_state(void){
 		if (!_health.load_current_short){
 			if (soft_current_push(current)) {
 				_health.load_current_short = 1;
+				error_counts.soft_current_short ++;
 				//_discharger_over_current.count = 0;
 				ml5238_enable_load_detect(1); //打开负载检测
 				shark_timer_post(&_load_detect_timer._timer, _load_detect_timer.interval);

+ 6 - 0
Application/app/sox/health.h

@@ -49,6 +49,11 @@ typedef struct {
 	uint8_t    internal_resistance[CELLS_NUM];   //cell's internal resistance
 }bms_health_t;
 
+typedef struct {
+	uint32_t soft_current_short;
+	uint32_t hard_current_short;
+}error_counts_t;
+
 bms_health_t *bms_health(void);
 void health_init(void);
 void check_current_state(void);
@@ -58,6 +63,7 @@ void health_process_aux_lock(void);
 void health_stop_aux_detect(void);
 uint32_t bms_health_pack_lower_voltage(void);
 uint32_t bms_health_cell_lower_voltage(void);
+void health_log(void);
 
 #endif /* _HEALTH_H__ */