|
|
@@ -232,6 +232,36 @@ static int _can_powerdown(void){
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
+static void _single_low_judge_current(bool set) {
|
|
|
+ if (!set){
|
|
|
+ bms_health()->b_flags &= ~(B_FLAGS_SINGLE_LOW_CURRENT | B_FLAGS_SINGLE_MID_CURRENT | B_FLAGS_SINGLE_BIG_CURRENT | B_FLAGS_SINGLE_LARGER_CURRENT);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (measure_value()->load_current < MAX_HA*1000/2) { // 0.5C ???
|
|
|
+ bms_health()->b_flags |= B_FLAGS_SINGLE_LOW_CURRENT;
|
|
|
+ }else if (measure_value()->load_current < MAX_HA*1000) { // 1C ???
|
|
|
+ bms_health()->b_flags |= B_FLAGS_SINGLE_MID_CURRENT;
|
|
|
+ }else if (measure_value()->load_current < MAX_HA * 1000 * 3/2) { // 1.5C ???
|
|
|
+ bms_health()->b_flags |= B_FLAGS_SINGLE_BIG_CURRENT;
|
|
|
+ }else {
|
|
|
+ bms_health()->b_flags |= B_FLAGS_SINGLE_LARGER_CURRENT;
|
|
|
+ }
|
|
|
+}
|
|
|
+static void _pack_low_judge_current(bool set) {
|
|
|
+ if (!set){
|
|
|
+ bms_health()->b_flags &= ~(B_FLAGS_PACK_LOW_CURRENT | B_FLAGS_PACK_MID_CURRENT | B_FLAGS_PACK_BIG_CURRENT | B_FLAGS_PACK_LARGER_CURRENT);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (measure_value()->load_current < MAX_HA*1000/2) {
|
|
|
+ bms_health()->b_flags |= B_FLAGS_PACK_LOW_CURRENT;
|
|
|
+ }else if (measure_value()->load_current < MAX_HA*1000) {
|
|
|
+ bms_health()->b_flags |= B_FLAGS_PACK_MID_CURRENT;
|
|
|
+ }else if (measure_value()->load_current < MAX_HA * 1000 * 3/2){
|
|
|
+ bms_health()->b_flags |= B_FLAGS_PACK_BIG_CURRENT;
|
|
|
+ }else {
|
|
|
+ bms_health()->b_flags |= B_FLAGS_PACK_LARGER_CURRENT;
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
void check_voltage_state(void) {
|
|
|
if (bms_state_get()->charging){ //check sigle cell's voltage for charger
|
|
|
@@ -257,10 +287,12 @@ 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;
|
|
|
+ _single_low_judge_current(true);
|
|
|
error_counts.cell_under_voltage++;
|
|
|
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])){
|
|
|
+ _single_low_judge_current(false);
|
|
|
if (judge_debounce(_health.sigle_cell_lower_voltage, &_sigle_cell_discharger_lower_vol)){
|
|
|
_health.sigle_cell_lower_voltage = 0;
|
|
|
}
|
|
|
@@ -269,10 +301,12 @@ void check_voltage_state(void) {
|
|
|
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;
|
|
|
+ _pack_low_judge_current(true);
|
|
|
error_counts.pack_under_voltage++;
|
|
|
discharger_lower_voltage = bms_state_get()->pack_voltage;
|
|
|
}
|
|
|
}else if (bms_state_get()->pack_voltage >= min_discharger_recovery_vol[_health.is_work_temp_normal]){
|
|
|
+ _pack_low_judge_current(false);
|
|
|
if (judge_debounce(_health.discharger_lower_voltage, &_discharger_lower_voltage)){
|
|
|
_health.discharger_lower_voltage = 0;
|
|
|
}
|