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

小电流保护时间根据采集到的电流计算

Signed-off-by: huhui <huhui@sharkgulf.com>
huhui 5 лет назад
Родитель
Сommit
23b3b6b247

+ 11 - 4
Application/app/sox/health.c

@@ -329,24 +329,31 @@ static uint8_t small_power_detect_count = 0;
 static shark_timer_t _aux_lock_timer = {.handler = _aux_lock_timer_handler};
 static shark_timer_t _aux_unlock_timer = {.handler = _aux_unlock_timer_handler};
 
+u32 _aux_unlock_delay(float voltage){
+	float aux_current = voltage / SMALL_CURRENT_R;
+	return aux_current * 10 * 1000; //ms
+}
+
 static void _aux_lock_timer_handler(shark_timer_t *t){
 	AUX_VOL_OPEN(1);
 	if (++small_power_detect_count >= MAX_TRY_FOR_AUX_SHORT){
 		//端口电压小于阈值,判断为小电流短路
 		int short_voltage = get_small_current_voltage()/1000;
 		int pack_voltage = bms_state_get()->pack_voltage/1000;
-		if (short_voltage >= (pack_voltage - AUX_SHORT_DIFF_VOLTAGE)) {
+		if (short_voltage >= AUX_SHORT_DIFF_VOLTAGE) {
 			_health.small_current_short = 1;
 			error_counts.aux_short ++;
 			AUX_VOL_OPEN(0);
 			small_power_detect_count = 0;
-			shark_timer_post( &_aux_lock_timer, 30 * 1000); //30s后再次尝试打开
-			shark_timer_cancel(&_aux_unlock_timer);
+			u32 delay_time = _aux_unlock_delay(short_voltage);
 			if (short_voltage >= (pack_voltage - AUX_SHORT_REAL_DIFF_VOLTAGE)){ //real short
 				error_counts.aux_real_short ++;
 				_health.small_current_real_short = 1;
+				delay_time = 30 * 1000;
 			}
-			health_debug("aux short, v:%d, and retry after 30s\n", short_voltage);
+			shark_timer_post( &_aux_lock_timer, delay_time); //30s后再次尝试打开
+			shark_timer_cancel(&_aux_unlock_timer);			
+			health_debug("aux short, v:%d, and retry after %ds\n", short_voltage, delay_time/1000);
 		}
 	}else {
 		health_debug("open aux[re-enable], %lld\n", shark_get_mseconds());

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

@@ -7,7 +7,7 @@
 #define SIGLE_CELL_MAX_CHARGER_VOLTAGE (3800)//最大允许充电电压,3.9v,考虑到采样的误差取 3.88
 #define MAX_CURRENT_FOR_DISCHARGER (120 * 1000) //软件采样的电流保护
 #define AUX_SHORT_REAL_DIFF_VOLTAGE (5) //判断小电流是否真实短路的,端口压差
-#define AUX_SHORT_DIFF_VOLTAGE (20) //判断小电流是否保护,端口压差
+#define AUX_SHORT_DIFF_VOLTAGE (7.5f) //判断小电流是否保护,28欧姆上的电压,能抗300mA
 
 /* 
  * xxx_over_temp: 表示过高温(温度过高)

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

@@ -196,7 +196,7 @@ float get_small_current(void){
 /* 用来判断小电流的情况下,电压小于某一个值认为小电流真正短路,比如16v*/
 float get_small_current_voltage(void){
 	float s_current_a = get_small_current();//MA
-	return s_current_a * (small_cur_r_sense + 28.0f);//28欧姆是mos的D极两个56的并联
+	return s_current_a * (small_cur_r_sense + SMALL_CURRENT_R);//28欧姆是mos的D极两个56的并联
 }
 
 int get_pcb_temperature(void){

+ 2 - 0
Application/bsp/shark_bsp.h

@@ -41,6 +41,8 @@
 #define UART_NUM 1
 #endif
 
+#define SMALL_CURRENT_R (28.0f)
+
 #define CELLS_NUM 15
 #define PACK_TEMPS_NUM 4
 #define PCB_TEMP_INDEX 3