Ver código fonte

通过内阻对cell电压补偿

Signed-off-by: huhui <huhui@sharkgulf.com>
huhui 5 anos atrás
pai
commit
1f66e8b613

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

@@ -13,7 +13,7 @@
 #define MIN_VOLTAGE_FOR_POWER_DOWN (2.1f * CELLS_NUM* 1000)
 #define SIGLE_CELL_LOWER_DISCHARGER_VOLTAGE (1820) //最小允许的电芯放电电压 1.8v, 考虑到采样的误差取 1.82
 
-#define SIGLE_CELL_MAX_CHARGER_VOLTAGE (3880)//最大允许充电电压,3.9v,考虑到采样的误差取 3.88
+#define SIGLE_CELL_MAX_CHARGER_VOLTAGE (3800)//最大允许充电电压,3.9v,考虑到采样的误差取 3.88
 
 static int8_t charger_normal_low_temp[PACK_TEMPS_NUM] = {0,0,0,0}; //正常的充电最低温度
 static int8_t charger_normal_high_temp[PACK_TEMPS_NUM] = {50,50,50,55}; //正常的充电最高温度
@@ -39,7 +39,7 @@ static float min_discharger_power_cell_vol[] = {2100, 2300}; //
 static float min_discharger_power_recovery_cell_vol[] = {2100, 2300}; //恢复能提供动力的最小电芯电压
 
 /*电池PowerDown的最小电压 */
-static float min_discharger_pdown_vol[] = {(2000 * CELLS_NUM), (2300 * CELLS_NUM)}; //power down的最小电压
+static float min_discharger_pdown_vol[] = {(2000 * CELLS_NUM), (2400 * CELLS_NUM)}; //power down的最小电压
 static float min_discharger_pdown_cell_vol[] = {1900, 2200};                        //power down的最小电芯电压
 
 /* health 模块,只检测状态,不做任何控制,如果有异常情况,控制中心会统一处理  */
@@ -57,7 +57,9 @@ void health_init(void){
 	ml5238_register_notify_handler(check_ml5238_state);
 	init_detect_timer();
 	set_log_level(MOD_HEALTH, L_debug);
-	_health.internal_resistance = 20; //毫欧,暂时用一个固定数据,后期需要计算R0=(U2-U1)/(I1-I2) - R1(R1为电路上的等效电阻+采样电阻)
+	for (int i = 0; i < CELLS_NUM; i++){
+		_health.internal_resistance[i] = 5;//毫欧,暂时用一个固定数据,后期需要计算R0=(U2-U1)/(I1-I2) - R1(R1为电路上的等效电阻+采样电阻)
+	}
 	_health.is_work_temp_lower = 1;
 }
 

+ 2 - 2
Application/app/sox/health.h

@@ -1,7 +1,7 @@
 #ifndef _HEALTH_H__
 #define _HEALTH_H__
 #include <stdint.h>
-
+#include "bsp/shark_bsp.h"
 /* 
  * xxx_over_temp: 깊刻법멕侊(侊똑법멕)
  * xxx_under_temp: 깊刻법됴侊(侊똑법됴)
@@ -35,7 +35,7 @@ typedef struct {
 	
 	uint32_t is_work_temp_lower:1;
 	uint32_t res2:11;
-	uint16_t internal_resistance;   //pack's internal resistance
+	uint8_t    internal_resistance[CELLS_NUM];   //cell's internal resistance
 }bms_health_t;
 
 bms_health_t *bms_health(void);

+ 3 - 1
Application/app/sox/measure_task.c

@@ -1,5 +1,6 @@
 #include "bsp/gpio.h"
 #include "app/sox/measure.h"
+#include "app/sox/health.h"
 #include "libs/shark_task.h"
 #include "libs/logger.h"
 #include "measure_task.h"
@@ -74,7 +75,8 @@ static u32 cell_task_handler(void){
 	if (bms_state_get()->pack_balancing){ //if balance, do'nt sample cell voltage
 		return _cell_task.delay;
 	}
-	_measure_value.cell_vol[_cell_task.index] = get_cell_voltage(_cell_task.index);
+	//用内阻对cell的电压进行补偿,充电减,放电加
+	_measure_value.cell_vol[_cell_task.index] = get_cell_voltage(_cell_task.index) - bms_health()->internal_resistance[_cell_task.index] * _measure_value.load_current/1000;
 	//measure_debug("cell[%d]=%f\n", _cell_task.index, _measure_value.cell_vol[_cell_task.index]/1000.0f);
 	_cell_task.index = (_cell_task.index + 1) % CELLS_NUM;
 	_voltage_notify();//通知bms state 有新的电压数据