Просмотр исходного кода

欠压后,24小时充满电,校准最小容量

Signed-off-by: huhui <huhui@sharkgulf.com>
huhui 4 лет назад
Родитель
Сommit
a54c9dabf8
1 измененных файлов с 12 добавлено и 8 удалено
  1. 12 8
      Application/app/sox/soc.c

+ 12 - 8
Application/app/sox/soc.c

@@ -14,14 +14,15 @@ static soc_t _soc;
 static uint8_t chargering = 0;
 static uint8_t chargering = 0;
 static u64     current_sample_ts = 0; //ms
 static u64     current_sample_ts = 0; //ms
 static u32     force_full_ts = 0xFFFFFFFF; //s
 static u32     force_full_ts = 0xFFFFFFFF; //s
-static float     soc_delta_time = 0;
-static float     max_soc_delta_time = 0;
+static u32     force_empty_ts = 0xFFFFFFFF; //s
+static float   soc_delta_time = 0;
+static float   max_soc_delta_time = 0;
 static float _charger_coefficient = 1.0f;
 static float _charger_coefficient = 1.0f;
 static float _discharger_coefficient = 1.0f;
 static float _discharger_coefficient = 1.0f;
 static uint32_t charger_remain_time = 0;
 static uint32_t charger_remain_time = 0;
 static const float _discharger_gain[] = {1.0f/*>0度*/, 1.002f/*-2<t<=0*/, 1.005f/*-5<t<=-2*/, 1.008f/*-10<t<=-5*/, 1.02f/*-15<t<=-10*/, 1.04f/*-20<t<=-15*/};
 static const float _discharger_gain[] = {1.0f/*>0度*/, 1.002f/*-2<t<=0*/, 1.005f/*-5<t<=-2*/, 1.008f/*-10<t<=-5*/, 1.02f/*-15<t<=-10*/, 1.04f/*-20<t<=-15*/};
 #define MAX_TIME_FULL_TO_EMPTY (5 * 24 * 3600) //充满到欠压5天内达到,可以校准最小电量
 #define MAX_TIME_FULL_TO_EMPTY (5 * 24 * 3600) //充满到欠压5天内达到,可以校准最小电量
-#define MAX_TIME_EMPTY_TO_FULL (8 * 24 * 3600) //充满到欠压5天内达到,可以校准最小电量
+#define MAX_TIME_EMPTY_TO_FULL (24 * 3600) //欠压到充满24小时内达到,可以校准最小电量
 #define DEFALUT_MAX_COULOMB (MAX_HA * 3600.0f)
 #define DEFALUT_MAX_COULOMB (MAX_HA * 3600.0f)
 #define DEFALUT_MIN_COULOMB (25.0f * 3600.0f)
 #define DEFALUT_MIN_COULOMB (25.0f * 3600.0f)
 #define FULL_MAX_VOLTAGE_CHARGING (54000)//mV
 #define FULL_MAX_VOLTAGE_CHARGING (54000)//mV
@@ -62,6 +63,8 @@ void soc_init(void){
 	}else {
 	}else {
 		if (_soc.capacity == 100) {
 		if (_soc.capacity == 100) {
 			force_full_ts = shark_get_seconds() + 1;
 			force_full_ts = shark_get_seconds() + 1;
+		}else if (_soc.capacity == 0) {
+			force_empty_ts = shark_get_seconds() + 1;
 		}
 		}
 	}
 	}
 	if (soc_get_version() != SOC_CURRENT_VERSION) {
 	if (soc_get_version() != SOC_CURRENT_VERSION) {
@@ -270,7 +273,7 @@ static __inline__ int can_modify_min_cap(void){
 		return 0;
 		return 0;
 	}
 	}
 	if (shark_get_seconds() > force_full_ts){
 	if (shark_get_seconds() > force_full_ts){
-		if ((shark_get_seconds() - force_full_ts) > MAX_TIME_FULL_TO_EMPTY) {
+		if ((shark_get_seconds() - force_full_ts) >= MAX_TIME_FULL_TO_EMPTY) {
 			return 0;
 			return 0;
 		}else {
 		}else {
 			return 1;
 			return 1;
@@ -280,11 +283,11 @@ static __inline__ int can_modify_min_cap(void){
 }
 }
 
 
 static __inline__ int can_modify_min_when_full(void){
 static __inline__ int can_modify_min_when_full(void){
-	if (force_full_ts == 0) {
+	if (force_empty_ts == 0) {
 		return 0;
 		return 0;
 	}
 	}
-	if (shark_get_seconds() > force_full_ts){
-		if ((shark_get_seconds() - force_full_ts) > MAX_TIME_EMPTY_TO_FULL) {
+	if (shark_get_seconds() > force_empty_ts){
+		if ((shark_get_seconds() - force_empty_ts) >= MAX_TIME_EMPTY_TO_FULL) {
 			return 0;
 			return 0;
 		}else {
 		}else {
 			return 1;
 			return 1;
@@ -347,7 +350,7 @@ static int _soc_update_by_ocv(uint8_t prev_charge_status){
 	}
 	}
 	if (!chargering){
 	if (!chargering){
 		if (_soc.capacity && _soc_is_under_voltage()) {
 		if (_soc.capacity && _soc_is_under_voltage()) {
-			soc_warning("judge calib min col %d - %d\n", shark_get_seconds(), force_full_ts);
+			soc_warning("judge calib min col %d - %d\n", shark_get_seconds(), force_empty_ts);
 			if (can_modify_min_cap()){
 			if (can_modify_min_cap()){
 				push_event(Min_Cap_For_DisCharger, (u32)_soc.coulomb_now);
 				push_event(Min_Cap_For_DisCharger, (u32)_soc.coulomb_now);
 				if (health_is_low_current()) {
 				if (health_is_low_current()) {
@@ -364,6 +367,7 @@ static int _soc_update_by_ocv(uint8_t prev_charge_status){
 			}else {
 			}else {
 				_soc.coulomb_now = _soc.coulomb_min;
 				_soc.coulomb_now = _soc.coulomb_min;
 			}
 			}
+			force_empty_ts = shark_get_seconds();
 			_soc.capacity = 0;
 			_soc.capacity = 0;
 			return 1;
 			return 1;
 		}	
 		}