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

记录和清除充放电异常电芯电压

Signed-off-by: huhui <huhui@sharkgulf.com>
huhui 4 лет назад
Родитель
Сommit
e52e612454
1 измененных файлов с 14 добавлено и 0 удалено
  1. 14 0
      Application/app/sox/health.c

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

@@ -62,6 +62,7 @@ static shark_timer_t _clear_short_current_timer = {.handler = clear_short_curren
 static error_counts_t error_counts;
 static u16 discharger_lower_cell_voltage = 0;
 static u16 discharger_lower_voltage = 0;
+static u16 charger_over_cell_voltage = 0;
 
 void health_init(void){
 	/* 5238如果有异常情况,比如短路,负载移除,通过这个handler上报 */
@@ -80,6 +81,7 @@ void health_log(void){
 	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, %d, %d\n", discharger_lower_cell_voltage, discharger_lower_voltage, error_counts.cell_under_voltage, error_counts.pack_under_voltage);
+	health_debug("over voltage: %d\n", charger_over_cell_voltage);
 	health_debug("uart error %d, %d, %d\n", error_counts.uart_crc_error, error_counts.uart_len_error, error_counts.uart_dir_error);
 	health_debug("Temp abnormal: %d,%d,%d,%d\n", error_counts.discharger_high_temp, error_counts.charger_high_temp, error_counts.discharger_lower_temp, error_counts.charger_lower_temp);
 }
@@ -266,6 +268,17 @@ static void _pack_low_judge_current(bool set) {
 }
 
 void check_voltage_state(void) {
+	static uint16_t _charging = 0xFFFF;
+	if (_charging != bms_state_get()->charging) {
+		if (bms_state_get()->charging) {
+			charger_over_cell_voltage = 0;
+		}else {
+			discharger_lower_cell_voltage = 0;
+			discharger_lower_voltage = 0;
+			error_counts.cell_under_voltage = 0;
+		}
+		_charging != bms_state_get()->charging;
+	}
 	if (bms_state_get()->charging){ //check sigle cell's voltage for charger
 		_health.discharger_shutpower_voltage = 0;
 		_health.sigle_cell_lower_voltage = 0;
@@ -274,6 +287,7 @@ void check_voltage_state(void) {
 		if ((bms_state_get()->cell_max_vol>= SIGLE_CELL_MAX_CHARGER_VOLTAGE)){
 			if (judge_debounce(!_health.sigle_cell_over_voltage, &_sigle_cell_charger_max_vol)){
 				_health.sigle_cell_over_voltage = 1;
+				charger_over_cell_voltage = bms_state_get()->cell_max_vol;
 				sys_debug("sigle cell %d\n", bms_state_get()->cell_max_vol);
 			}
 		}else if ((bms_state_get()->cell_max_vol < SIGLE_CELL_MAX_CHARGER_VOLTAGE)){