|
|
@@ -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());
|