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

加速的时候,需要通过直接的油门开度修正计算的加速扭矩

Signed-off-by: huhui <huhui@sharkgulf.com>
huhui 2 лет назад
Родитель
Сommit
5db8297c86
2 измененных файлов с 19 добавлено и 2 удалено
  1. 18 2
      Applications/foc/core/thro_torque.c
  2. 1 0
      Applications/foc/core/thro_torque.h

+ 18 - 2
Applications/foc/core/thro_torque.c

@@ -14,7 +14,7 @@ void thro_torque_reset(void) {
 	_torque.accl = false;
 	_torque.thro_filted = 0.0f;
 	_torque.thro_ration = _torque.thro_ration_last = 0.0f;
-	_torque.torque_req = _torque.torque_real = 0.0f;
+	_torque.torque_req = _torque.torque_real = _torque.torque_acc_ = 0.0f;
 	_torque.gear = mc_get_internal_gear();
 }
 
@@ -80,6 +80,8 @@ float thro_get_ration(float f_thro) {
 
 static float _thro_torque_for_accelerate(float ration) {
 	float max_torque = thro_torque_gear_map((s16)_torque.spd_filted, _torque.gear);
+	float thro_torque = max_torque * ration;
+
 	float acc_r = 1.0f;
 	if (_torque.thro_ration_last < 1.0f) {
 		acc_r = (ration - _torque.thro_ration_last)/ (1.0f - _torque.thro_ration_last);
@@ -89,7 +91,20 @@ static float _thro_torque_for_accelerate(float ration) {
 	if (acc_torque < 0) {
 		acc_torque = 0;
 	}
-	return acc_torque;
+	/*
+	   直接获取油门开度对应的加速扭矩thro_torque 不小于间接计算得到的 acc_torque
+	   如果差值在正负5以上,需要step 补偿
+	*/
+	float torque_acc_ = thro_torque - acc_torque;
+	float step = 0.01f;
+	if (ABS(torque_acc_) < 5) {
+		torque_acc_ = 0;
+	}else {
+		float acc_t = mc_get_gear_config()->n_accl_time;
+		step = torque_acc_ / (acc_t + 0.00001f);
+	}
+	step_towards(&_torque.torque_acc_, torque_acc_, step);
+	return (acc_torque + _torque.torque_acc_);
 }
 
 
@@ -203,6 +218,7 @@ void thro_torque_process(u8 run_mode, float f_throttle) {
 			if (_torque.torque_real < 0) { //电子刹车的时候,扭矩可能为负
 				_torque.torque_real = 0;
 			}
+			_torque.torque_acc_ = 0;
 			acc_r = thro_r;
 			acc_r_last = _torque.thro_ration_last;
 			acc_trq = _torque.torque_real;

+ 1 - 0
Applications/foc/core/thro_torque.h

@@ -6,6 +6,7 @@ typedef struct {
 	bool  accl;
 	float torque_req;
 	float torque_real;
+	float torque_acc_;
 	float thro_filted;
 	float spd_filted;
 	float thro_ration;