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

用5238采集电流的时候,采集间隔5ms,每次采样总的间隔8ms

Signed-off-by: huhui <huhui@sharkgulf.com>
huhui 5 лет назад
Родитель
Сommit
7686cf1416
3 измененных файлов с 7 добавлено и 2 удалено
  1. 4 1
      Application/app/sox/measure_task.c
  2. 1 1
      Application/bsp/cs1180.c
  3. 2 0
      Application/bsp/shark_bsp.h

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

@@ -50,7 +50,7 @@ static struct means_task _current_voltage_task;
 static u32 current_voltage_task_handler(void);
 static void init_current_voltage_task(void){
 	_current_voltage_task._task.handler = current_voltage_task_handler;
-	_current_voltage_task.delay = 15;
+	_current_voltage_task.delay = 25;
 	_current_voltage_task.index = CELLS_NUM;
 	_measure_value.load_current = get_pack_current(&_measure_value.current_5238);
 	for (int i = 0; i < CELLS_NUM; i++){
@@ -74,6 +74,9 @@ static u32 current_voltage_task_handler(void){
 	_current_voltage_task.index = (_current_voltage_task.index + 1) % CELLS_NUM;
 	_measure_value.cell_vol[_current_voltage_task.index] = get_cell_voltage(_current_voltage_task.index) - bms_health()->internal_resistance[_current_voltage_task.index] * _measure_value.load_current/1000;
 	_voltage_notify();//֪ͨbms state ÓÐеĵçѹÊý¾Ý
+	if (abs(_measure_value.load_current) >= MIN_CURRENT_FOR_CS1180) {
+		return 5;
+	}
 	return _current_voltage_task.delay;
 }
 

+ 1 - 1
Application/bsp/cs1180.c

@@ -305,7 +305,7 @@ int cs1180_adc_set_gain_online(int gain){
 
 
 int cs1180_change_gain(int current){
-	if (abs(current) < 4000){ //4.5
+	if (abs(current) < MIN_CURRENT_FOR_CS1180){ //4.5
 		return cs1180_adc_set_gain_online(CS1180_GAIN_128X);
 	}/*else if (abs(current) < 12 * 1000){ //18
 		return cs1180_adc_set_gain_online(CS1180_GAIN_32X);

+ 2 - 0
Application/bsp/shark_bsp.h

@@ -41,6 +41,8 @@
 #define UART_NUM 1
 #endif
 
+#define MIN_CURRENT_FOR_CS1180 (4000)
+
 #define SMALL_CURRENT_R (28.0f)
 
 #define CELLS_NUM 15