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

3个电芯温度传感器都常温才认为BMS的工作温度在常温下

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

+ 8 - 5
Application/app/sox/health.c

@@ -321,21 +321,23 @@ static debounce_t _discharger_normal_temp_count = {.count = 0, .max_count = 8, .
 static debounce_t _work_lower_temp_count = 		{.count = 0, .max_count = 8, .init_count = 0};
 static debounce_t _work_lower_temp_count = 		{.count = 0, .max_count = 8, .init_count = 0};
 
 
 static int _is_over_temp(int8_t *temps, int size){
 static int _is_over_temp(int8_t *temps, int size){
+	int count = 0;
 	for (int i = 0; i < size; i++){
 	for (int i = 0; i < size; i++){
 		if (measure_value()->pack_temp[i] >= temps[i]){
 		if (measure_value()->pack_temp[i] >= temps[i]){
-			return 1;
+			count ++;
 		}
 		}
 	}
 	}
-	return 0;
+	return count;
 }
 }
 
 
 static int _is_low_temp(int8_t *temps, int size){
 static int _is_low_temp(int8_t *temps, int size){
+	int count = 0;
 	for (int i = 0; i < size; i++){
 	for (int i = 0; i < size; i++){
 		if (measure_value()->pack_temp[i] < temps[i]){
 		if (measure_value()->pack_temp[i] < temps[i]){
-			return 1;
+			count ++;
 		}
 		}
 	}
 	}
-	return 0;
+	return count;
 }
 }
 
 
 static uint8_t small_power_detect_count = 0;
 static uint8_t small_power_detect_count = 0;
@@ -465,7 +467,8 @@ void check_temp_state(void){
 		}	
 		}	
 	}
 	}
 	if (!_health.is_work_temp_normal){
 	if (!_health.is_work_temp_normal){
-		if (_is_over_temp(work_lower_temp, sizeof(work_lower_temp))){
+		/* 3个电芯温度都正常才算正常 */
+		if (_is_over_temp(work_lower_temp, sizeof(work_lower_temp)) == sizeof(work_lower_temp)){
 			debounce_inc(_work_lower_temp_count);
 			debounce_inc(_work_lower_temp_count);
 			if (debounce_reach_max(_work_lower_temp_count)){
 			if (debounce_reach_max(_work_lower_temp_count)){
 				_health.is_work_temp_normal = 1;
 				_health.is_work_temp_normal = 1;