Explorar o código

fix error for temp && capcity

Signed-off-by: huhui <huhui@sharkgulf.com>
huhui %!s(int64=5) %!d(string=hai) anos
pai
achega
c26e8f656c
Modificáronse 3 ficheiros con 7 adicións e 5 borrados
  1. 1 1
      Application/app/sox/measure.c
  2. 1 1
      Application/app/sox/soc.c
  3. 5 3
      Application/app/sox/state.c

+ 1 - 1
Application/app/sox/measure.c

@@ -181,6 +181,6 @@ int get_pack_temperature(int index){
 	delay_us(100);
 	uint16_t adc = adc_sample_avg(ADC_CHAN_TEMPERATURE_1 + index, 1);
 	TEMP_OPEN(0);
-	return get_temp_by_adc(adc);
+	return get_temp_by_adc((adc<<4)&0xFFFF);
 }
 

+ 1 - 1
Application/app/sox/soc.c

@@ -175,7 +175,7 @@ void soc_update(void){
 		_soc.coulomb_now = _soc.coulomb_min;
 	}
 	uint8_t old_cap = _soc.capacity;
-	_soc.capacity = ((_soc.coulomb_now - _soc.coulomb_min)/(_soc.coulomb_max - _soc.coulomb_min) + 0.5f) * 100;//ËÄÉáÎåÈë
+	_soc.capacity = ((_soc.coulomb_now - _soc.coulomb_min)/(_soc.coulomb_max - _soc.coulomb_min) + 0.005f) * 100;//ËÄÉáÎåÈë
 	if (_soc.capacity > 100){
 		_soc.capacity = 100;
 	}

+ 5 - 3
Application/app/sox/state.c

@@ -21,12 +21,10 @@ static void _current_notify(void);
 static void _voltage_notify(void);
 static void _temperature_notify(void);
 static u32 _bms_main_task_handler(void);
-static void _balance_timer_handler(shark_timer_t *t);
 static void _debug_timer_handler(shark_timer_t *t);
 
 static bms_state_t _bms_state;
 static shark_task_t _bms_main_task = {.handler = _bms_main_task_handler};
-static shark_timer_t _balance_timer = {.handler = _balance_timer_handler};
 
 static shark_timer_t _debug_timer = {.handler = _debug_timer_handler};
 
@@ -372,10 +370,14 @@ static void _current_notify(void){
 	soc_update(); //计算soc
 }
 
+#if (ALLOW_5238_BALANCE==1)
+
 /* 需要检查电芯的电压,如果发现有电芯电压过高,需要开启被动均衡 
  * 充电过程中考虑balance,主要是希望cell 电压扩散后,保证1. 单电芯不能过压, 2. 单电芯不能比平均电压过低,导致
  * 木桶效应,目标是电压最高的那个cell,尽量压制,不让电压再升高,或者升高的尽量慢一些
 */
+static shark_timer_t _balance_timer = {.handler = _balance_timer_handler};
+
 static debounce_t _cell_balance = {.count = 10, .max_count = 20};
 
 static void _balance_timer_handler(shark_timer_t *t){
@@ -411,7 +413,7 @@ static void check_cell_balance(uint8_t current_max_index){
 	}
 	_bms_state.cell_index_of_max_vol = current_max_index;	
 }
-
+#endif
 static uint8_t calc_cell_voltage(void){
 	uint16_t voltage = 0;
 	uint16_t max_cell = 0;