|
|
@@ -485,7 +485,7 @@ static void _balance_timer_handler(shark_timer_t *t);
|
|
|
|
|
|
static shark_timer_t _balance_timer = {.handler = _balance_timer_handler};
|
|
|
|
|
|
-static debounce_t _cell_balance = {.count = 10, .max_count = 20};
|
|
|
+static debounce_t _cell_balance = {.count = 0, .max_count = 10, .init_count = 0};
|
|
|
|
|
|
static void _balance_timer_handler(shark_timer_t *t){
|
|
|
ml5238_cell_start_balance(0);
|
|
|
@@ -506,23 +506,19 @@ static void check_cell_balance(uint8_t current_max_index){
|
|
|
}
|
|
|
return;
|
|
|
}
|
|
|
- if ((!_bms_state.pack_balancing && _bms_state.cell_min_vol <= CELL_FUSION_VOLTAGE) || _bms_state.pack_balancing){
|
|
|
+ if ((!_bms_state.pack_balancing && _bms_state.cell_max_vol < MAX_CELL_VOLTAGE_FOR_BALACNE) || _bms_state.pack_balancing){
|
|
|
return;
|
|
|
}
|
|
|
if (_bms_state.cell_max_vol >= MAX_CELL_VOLTAGE_FOR_BALACNE){
|
|
|
debounce_inc(_cell_balance);
|
|
|
}else {
|
|
|
- debounce_dec(_cell_balance);
|
|
|
+ debounce_reset(_cell_balance);
|
|
|
}
|
|
|
if (!_bms_state.pack_balancing && debounce_reach_max(_cell_balance)){
|
|
|
_bms_state.pack_balancing = 1;
|
|
|
- }else if (_bms_state.pack_balancing && debounce_reach_zero(_cell_balance)){
|
|
|
- _bms_state.pack_balancing = 0;
|
|
|
- ml5238_cell_start_balance(0);
|
|
|
- }
|
|
|
- if (_bms_state.pack_balancing){
|
|
|
ml5238_cell_start_balance(get_balance_mask(current_max_index));
|
|
|
shark_timer_post(&_balance_timer, 30 * 1000); //stop balance after 30s
|
|
|
+ debounce_reset(_cell_balance);
|
|
|
}
|
|
|
_bms_state.cell_index_of_max_vol = current_max_index;
|
|
|
}
|