Преглед изворни кода

过压,欠压记录最大最小电芯电压和总压

Signed-off-by: huhui <huhui@sharkgulf.com>
huhui пре 4 година
родитељ
комит
893db73be2
2 измењених фајлова са 13 додато и 5 уклоњено
  1. 9 2
      Application/app/sox/health.c
  2. 4 3
      Application/app/sox/soc.c

+ 9 - 2
Application/app/sox/health.c

@@ -266,6 +266,13 @@ static void _pack_low_judge_current(bool set) {
 	}
 }
 
+static void push_cell_event(event_id_t id){
+	u32 max = ((bms_state_get()->cell_index_of_max_vol << 12) & 0xF000) | (bms_state_get()->cell_max_vol& 0x0FFF);
+	u32 min = ((bms_state_get()->cell_index_of_min_vol << 12) & 0xF000) | (bms_state_get()->cell_min_vol& 0x0FFF);
+
+	push_event(id, max << 16 | min);
+}
+
 void check_voltage_state(void) {
 	static uint16_t _charging = 0xFFFF;
 	if (_charging != bms_state_get()->charging) {
@@ -283,7 +290,7 @@ void check_voltage_state(void) {
 		if ((bms_state_get()->cell_max_vol>= SIGLE_CELL_MAX_CHARGER_VOLTAGE)){
 			if (judge_debounce(!_health.sigle_cell_over_voltage, &_sigle_cell_charger_max_vol)){
 				_health.sigle_cell_over_voltage = 1;
-				push_event(Cell_Over_Vol, bms_state_get()->cell_max_vol | (bms_state_get()->cell_index_of_max_vol << 16));
+				push_cell_event(Cell_Over_Vol);
 				sys_debug("sigle cell %d\n", bms_state_get()->cell_max_vol);
 			}
 		}else if ((bms_state_get()->cell_max_vol < SIGLE_CELL_MAX_CHARGER_VOLTAGE)){
@@ -299,7 +306,7 @@ 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;
-				push_event(Cell_Under_Vol, bms_state_get()->cell_min_vol | (bms_state_get()->cell_index_of_min_vol << 16));
+				push_cell_event(Cell_Under_Vol);
 				_single_low_judge_current(true);
 				error_counts.cell_under_voltage++;
 			}

+ 4 - 3
Application/app/sox/soc.c

@@ -330,7 +330,8 @@ static void _force_capacity_full(void){
 			push_event(Min_Cap_For_Full, (u32)curr_min_cap);
 		}
 	}
-	push_event(Charger_Full_cap, (u32)curr_real_cap);
+	u32 cap_x10 = (u32)(curr_real_cap / 3600.0f * 10);
+	push_event(Charger_Full_cap, (bms_state_get()->pack_voltage << 16) | (cap_x10 & 0xFFFF));
 	_soc.coulomb_now = _soc.coulomb_max;//充满后,当前容量设置为最大容量
 
 	force_full_ts = shark_get_seconds();
@@ -366,11 +367,11 @@ static int _soc_update_by_ocv(uint8_t prev_charge_status){
 					_soc.coulomb_min = _soc.coulomb_now * 0.9f;
 				}
 				_soc.coulomb_now = _soc.coulomb_min;
-				push_event(Min_Cap_For_DisCharger, (u32)_soc.coulomb_now);
-				soc_warning("calicablite coulomb_min %f\n", _soc.coulomb_min);
 			}else {
 				_soc.coulomb_now = _soc.coulomb_min;
 			}
+			u32 cap_x10 = (u32)(_soc.coulomb_now / 3600.0f * 10);
+			push_event(Min_Cap_For_DisCharger, (bms_state_get()->pack_voltage << 16) | (cap_x10 & 0xFFFF));
 			force_empty_ts = shark_get_seconds();
 			_soc.capacity = 0;
 			return 1;