|
|
@@ -60,6 +60,8 @@ static debounce_timer_t _load_detect_timer = {.max_count = 100, .interval = 10,
|
|
|
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;
|
|
|
+static u16 discharger_lower_cell_voltage = 0;
|
|
|
+static u16 discharger_lower_voltage = 0;
|
|
|
|
|
|
void health_init(void){
|
|
|
/* 5238如果有异常情况,比如短路,负载移除,通过这个handler上报 */
|
|
|
@@ -77,6 +79,7 @@ void health_log(void){
|
|
|
health_debug("hard short:%d\n", error_counts.hard_current_short);
|
|
|
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\n", discharger_lower_cell_voltage, discharger_lower_voltage);
|
|
|
}
|
|
|
|
|
|
bms_health_t *bms_health(){
|
|
|
@@ -189,12 +192,12 @@ void check_current_state(void){
|
|
|
}
|
|
|
|
|
|
/* 检测pack电压,cell电压,pack电压过低触发powerdown*/
|
|
|
-static debounce_t _discharger_lower_voltage = {.count = 0, .max_count = 10, .init_count = 0};
|
|
|
-static debounce_t _power_down_voltage = {.count = 0, .max_count = 10, .init_count = 0};
|
|
|
-static debounce_t _sigle_cell_discharger_lower_vol = {.count = 0, .max_count = 5, .init_count = 0};
|
|
|
-static debounce_t _sigle_cell_charger_max_vol = {.count = 0, .max_count = 15, .init_count = 0};
|
|
|
-static debounce_t _shut_discharger_lower_voltage = {.count = 0, .max_count = 20,};
|
|
|
-static debounce_t _shut_discharger_cell_lower_voltage = {.count = 0, .max_count = 20,};
|
|
|
+static debounce_t _discharger_lower_voltage = {.count = 0, .max_count = 20, .init_count = 0};
|
|
|
+static debounce_t _power_down_voltage = {.count = 0, .max_count = 20, .init_count = 0};
|
|
|
+static debounce_t _sigle_cell_discharger_lower_vol = {.count = 0, .max_count = 100, .init_count = 0};
|
|
|
+static debounce_t _sigle_cell_charger_max_vol = {.count = 0, .max_count = 20, .init_count = 0};
|
|
|
+static debounce_t _shut_discharger_lower_voltage = {.count = 0, .max_count = 20,.init_count = 0};
|
|
|
+static debounce_t _shut_discharger_cell_lower_voltage = {.count = 0, .max_count = 400,.init_count = 0};
|
|
|
|
|
|
static int judge_debounce(int input, debounce_t *d){
|
|
|
if (input) {
|
|
|
@@ -246,30 +249,29 @@ void check_voltage_state(void) {
|
|
|
if ((bms_state_get()->cell_min_vol <= min_discharger_cell_vol[_health.is_work_temp_normal])){
|
|
|
if (judge_debounce(!_health.sigle_cell_lower_voltage, &_sigle_cell_discharger_lower_vol)){
|
|
|
_health.sigle_cell_lower_voltage = 1;
|
|
|
- _sigle_cell_discharger_lower_vol.max_count = 30;//从欠压恢复可以稍微慢一点
|
|
|
+ discharger_lower_cell_voltage = bms_state_get()->cell_min_vol;
|
|
|
}
|
|
|
}else if ((bms_state_get()->cell_min_vol >= min_discharger_cell_recovery_vol[_health.is_work_temp_normal])){
|
|
|
if (judge_debounce(_health.sigle_cell_lower_voltage, &_sigle_cell_discharger_lower_vol)){
|
|
|
_health.sigle_cell_lower_voltage = 0;
|
|
|
- _sigle_cell_discharger_lower_vol.max_count = 5;
|
|
|
}
|
|
|
}
|
|
|
//check sigle pack's voltage for discharger
|
|
|
if (bms_state_get()->pack_voltage <= min_discharger_vol[_health.is_work_temp_normal]){
|
|
|
if (judge_debounce(!_health.discharger_lower_voltage, &_discharger_lower_voltage)){
|
|
|
_health.discharger_lower_voltage = 1;
|
|
|
- _discharger_lower_voltage.max_count = 30; //从欠压恢复可以稍微慢一点
|
|
|
+ discharger_lower_voltage = bms_state_get()->pack_voltage;
|
|
|
}
|
|
|
}else if (bms_state_get()->pack_voltage >= min_discharger_recovery_vol[_health.is_work_temp_normal]){
|
|
|
if (judge_debounce(_health.discharger_lower_voltage, &_discharger_lower_voltage)){
|
|
|
_health.discharger_lower_voltage = 0;
|
|
|
- _discharger_lower_voltage.max_count = 10;
|
|
|
}
|
|
|
}
|
|
|
//check for shutdown power
|
|
|
if ((bms_state_get()->cell_min_vol <= min_discharger_power_cell_vol[_health.is_work_temp_normal])){
|
|
|
if (judge_debounce(!_health.discharger_cell_shutpower_voltage, &_shut_discharger_cell_lower_voltage)){
|
|
|
_health.discharger_cell_shutpower_voltage = 1;
|
|
|
+ discharger_lower_cell_voltage = bms_state_get()->cell_min_vol;
|
|
|
}
|
|
|
}else if ((bms_state_get()->cell_min_vol >= min_discharger_power_recovery_cell_vol[_health.is_work_temp_normal])){
|
|
|
if (judge_debounce(_health.discharger_cell_shutpower_voltage, &_shut_discharger_cell_lower_voltage)){
|
|
|
@@ -277,11 +279,12 @@ void check_voltage_state(void) {
|
|
|
}
|
|
|
}
|
|
|
if ((bms_state_get()->pack_voltage <= min_discharger_power_vol[_health.is_work_temp_normal])){
|
|
|
- if (judge_debounce(!_health.discharger_cell_shutpower_voltage, &_shut_discharger_lower_voltage)){
|
|
|
+ if (judge_debounce(!_health.discharger_shutpower_voltage, &_shut_discharger_lower_voltage)){
|
|
|
_health.discharger_shutpower_voltage = 1;
|
|
|
+ discharger_lower_voltage = bms_state_get()->pack_voltage;
|
|
|
}
|
|
|
}else if ((bms_state_get()->pack_voltage >= min_discharger_power_recovery_vol[_health.is_work_temp_normal])){
|
|
|
- if (judge_debounce(_health.discharger_cell_shutpower_voltage, &_shut_discharger_lower_voltage)){
|
|
|
+ if (judge_debounce(_health.discharger_shutpower_voltage, &_shut_discharger_lower_voltage)){
|
|
|
_health.discharger_shutpower_voltage = 0;
|
|
|
}
|
|
|
}
|