Przeglądaj źródła

重新命名油门开度

Signed-off-by: unknown <huhui@sharkgulf.com>
unknown 2 lat temu
rodzic
commit
e733217959

+ 13 - 13
Applications/foc/core/thro_torque.c

@@ -15,7 +15,7 @@ static thro_torque_t _torque;
 void thro_torque_reset(void) {
 	_torque.accl = false;
 	_torque.thro_filted = 0.0f;
-	_torque.thro_ration = _torque.thro_ration_last = 0.0f;
+	_torque.throttle_opening = _torque.throttle_opening_last = 0.0f;
 	_torque.torque_req = _torque.torque_real = _torque.torque_acc_ = 0.0f;
 	_torque.gear = mc_get_internal_gear();
 }
@@ -81,8 +81,8 @@ static float _thro_torque_for_accelerate(float ration) {
 	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);
+	if (_torque.throttle_opening_last < 1.0f) {
+		acc_r = (ration - _torque.throttle_opening_last)/ (1.0f - _torque.throttle_opening_last);
 	}
 	acc_r = fclamp(acc_r, 0, 1.0f);
 	float acc_torque = _torque.torque_real + acc_r * (max_torque - _torque.torque_real);
@@ -106,14 +106,14 @@ static float _thro_torque_for_accelerate(float ration) {
 
 
 static float thro_torque_for_accelerate(void) {
-	return _thro_torque_for_accelerate(_torque.thro_ration);
+	return _thro_torque_for_accelerate(_torque.throttle_opening);
 }
 
 static float thro_torque_for_decelerate(void) {
-	if (_torque.thro_ration_last == 0.0f) {
+	if (_torque.throttle_opening_last == 0.0f) {
 		return 0;
 	}
-	float dec_r = _torque.thro_ration / _torque.thro_ration_last;
+	float dec_r = _torque.throttle_opening / _torque.throttle_opening_last;
 	dec_r = fclamp(dec_r, 0.0f, 1.0f);
 	return dec_r * _torque.torque_real;
 }
@@ -192,9 +192,9 @@ void thro_torque_process(u8 run_mode, float f_throttle) {
 	_torque.gear = mc_get_internal_gear();
 	LowPass_Filter(_torque.spd_filted, PMSM_FOC_GetSpeed(), THRO_RPM_LP_CEOF);
 
-	if (thro_r > _torque.thro_ration) {
+	if (thro_r > _torque.throttle_opening) {
 		if (!_torque.accl) {
-			_torque.thro_ration_last = _torque.thro_ration;
+			_torque.throttle_opening_last = _torque.throttle_opening;
 			_torque.torque_real = PMSM_FOC_Get()->in.s_targetTorque;
 			if (_torque.torque_real < 0) { //电子刹车的时候,扭矩可能为负
 				_torque.torque_real = 0;
@@ -202,9 +202,9 @@ void thro_torque_process(u8 run_mode, float f_throttle) {
 			_torque.torque_acc_ = 0;
 		}
 		_torque.accl = true;
-	}else if (thro_r < _torque.thro_ration) {
+	}else if (thro_r < _torque.throttle_opening) {
 		if (_torque.accl) {
-			_torque.thro_ration_last = _torque.thro_ration;
+			_torque.throttle_opening_last = _torque.throttle_opening;
 			_torque.torque_real = PMSM_FOC_Get()->in.s_targetTorque;
 			if (_torque.torque_real < 0) { //电子刹车的时候,扭矩可能为负
 				_torque.torque_real = 0;
@@ -213,12 +213,12 @@ void thro_torque_process(u8 run_mode, float f_throttle) {
 		_torque.accl = false;
 	}
 
-	_torque.thro_ration = thro_r;
+	_torque.throttle_opening = thro_r;
 	if (run_mode == CTRL_MODE_TRQ) {
 		thro_torque_request();
 	}else if (run_mode == CTRL_MODE_SPD) {
 		if (!mc_is_cruise_enabled()) {
-			float speed_Ref = PMSM_FOC_GetSpeedLimit() * _torque.thro_ration;
+			float speed_Ref = PMSM_FOC_GetSpeedLimit() * _torque.throttle_opening;
 			PMSM_FOC_Set_TgtSpeed(speed_Ref);
 		}
 	}else if (run_mode == CTRL_MODE_EBRAKE) {
@@ -253,5 +253,5 @@ float get_user_request_torque(void) {
 
 void thro_torque_log(void) {
 	sys_debug("accl %d, real %f, req %f\n", _torque.accl, _torque.torque_real, _torque.torque_req);
-	sys_debug("ration %f - %f - %f - %d\n", _torque.thro_ration, _torque.thro_ration_last, thro_torque_for_accelerate(), _torque.gear);
+	sys_debug("ration %f - %f - %f - %d\n", _torque.throttle_opening, _torque.throttle_opening_last, thro_torque_for_accelerate(), _torque.gear);
 }

+ 2 - 2
Applications/foc/core/thro_torque_unused.h

@@ -9,8 +9,8 @@ typedef struct {
 	float torque_acc_;
 	float thro_filted;
 	float spd_filted;
-	float thro_ration;
-	float thro_ration_last;
+	float throttle_opening;
+	float throttle_opening_last;
 	u8    gear;
 }thro_torque_t;
 

+ 8 - 8
Applications/foc/core/torque_unused.c

@@ -112,12 +112,12 @@ static float get_throttle_torque(float trq_ration) {
 }
 
 float get_thro_request_torque(void) {
-	return get_throttle_torque(torque_ctrl.thro_ration);
+	return get_throttle_torque(torque_ctrl.throttle_opening);
 }
 
-void request_torque(float thro_ration) {
+void request_torque(float throttle_opening) {
 	float curr_rpm = PMSM_FOC_GetSpeed();
-	float ref_torque = get_throttle_torque(thro_ration);
+	float ref_torque = get_throttle_torque(throttle_opening);
 #ifdef CONFIG_CRUISE_ENABLE_ACCL
 	if (mc_is_cruise_enabled() && mc_throttle_released()) {
 		return;
@@ -146,9 +146,9 @@ void request_torque(float thro_ration) {
 	}
 }
 
-void request_speed(float thro_ration) {
+void request_speed(float throttle_opening) {
 	if (!mc_is_cruise_enabled()) {
-		float speed_Ref = PMSM_FOC_GetSpeedLimit() * thro_ration;
+		float speed_Ref = PMSM_FOC_GetSpeedLimit() * throttle_opening;
 		PMSM_FOC_Set_TgtSpeed(speed_Ref);
 	}
 }
@@ -161,11 +161,11 @@ void throttle_process(u8 run_mode, float f_throttle) {
 	}else {
 		LowPass_Filter(torque_ctrl.throttle_value, f_throttle, THRO_REF_LP_CEOF);
 	}
-	torque_ctrl.thro_ration = throttle_ration(f_throttle);
+	torque_ctrl.throttle_opening = throttle_ration(f_throttle);
 	if (run_mode == CTRL_MODE_TRQ) {
-		request_torque(torque_ctrl.thro_ration);
+		request_torque(torque_ctrl.throttle_opening);
 	}else if (run_mode == CTRL_MODE_SPD) {
-		request_speed(torque_ctrl.thro_ration);
+		request_speed(torque_ctrl.throttle_opening);
 	}else if (run_mode == CTRL_MODE_EBRAKE) {
 		eCtrl_reset_Torque(0);
 		if (eCtrl_get_FinalCurrent() < 0.0001f && PMSM_FOC_GetSpeed() < CONFIG_MIN_RPM_EXIT_EBRAKE) {

+ 2 - 2
Applications/foc/core/torque_unused.h

@@ -6,7 +6,7 @@ typedef struct {
 	bool  accl;
 	float torque_req;
 	float throttle_value;
-	float thro_ration; //油门开度百分比
+	float throttle_opening; //油门开度百分比
 	float spd_filted;
 	u32   count;
 }torque_manager_t;
@@ -14,7 +14,7 @@ void torque_init(void);
 void torque_reset(void);
 void trq2dq_lookup(int rpm, float torque, DQ_t *dq_out);
 void throttle_process(u8 run_mode, float f_throttle);
-void request_torque(float thro_ration);
+void request_torque(float throttle_opening);
 void trq2dq_lookup_init(void);
 float get_thro_request_torque(void);
 

+ 2 - 2
Applications/foc/motor/motor.c

@@ -1354,7 +1354,7 @@ static void mc_process_epm_move(void) {
 		target_vel = -mc_conf()->c.max_epm_back_rpm;
 		target_trq = mc_conf()->c.max_epm_back_torque;
 	}else if (!motor.b_epm_cmd_move) {
-		target_vel = throttle_vol_to_open_ration(throttle_get_signal()) * 2.0f * (float)target_vel;
+		target_vel = throttle_vol_to_opening(throttle_get_signal()) * 2.0f * (float)target_vel;
 	}
 	motor.f_epm_trq = target_trq;
 	motor.f_epm_vel = target_vel;
@@ -1615,7 +1615,7 @@ void Sched_MC_mTask(void) {
 				float thro = throttle_get_signal();
 				if (motor.b_ignor_throttle) {
 					float r = (float)motor.u_throttle_ration/100.0f;
-					thro = throttle_open_ration_to_vol(r);
+					thro = throttle_opening_to_vol(r);
 				}
 				mc_process_throttle_torque(thro);
 			}

+ 17 - 17
Applications/foc/motor/throttle.c

@@ -20,7 +20,7 @@ static throttle_torque_t _throttle;
 
 void throttle_torque_reset(void) {
 	_throttle.accl = false;
-	_throttle.thro_ration = _throttle.thro_ration_last = 0.0f;
+	_throttle.throttle_opening = _throttle.throttle_opening_last = 0.0f;
 	_throttle.torque_req = _throttle.torque_real = _throttle.torque_acc_ = 0.0f;
 	_throttle.gear = mc_get_internal_gear();
 }
@@ -126,7 +126,7 @@ void throttle_force_detect(void) {
 }
 
 /* 获取转把电压对应的油门开度 */
-float throttle_vol_to_open_ration(float thro_val) {
+float throttle_vol_to_opening(float thro_val) {
 	if (thro_val <= throttle_start_vol()) {
 		return 0;
 	}
@@ -138,11 +138,11 @@ float throttle_vol_to_open_ration(float thro_val) {
 /* 获取油门开度 */
 float throttle_get_open_ration(void) {
 	float thro_val = throttle_get_signal();
-	return throttle_vol_to_open_ration(thro_val);
+	return throttle_vol_to_opening(thro_val);
 }
 
 /* 获取油门开度对应的转把电压 */
-float throttle_open_ration_to_vol(float r) {
+float throttle_opening_to_vol(float r) {
 	if (r == 0) {
 		return 0;
 	}else if (r > 1.0f) {
@@ -209,8 +209,8 @@ static float _throttle_torque_for_accelerate(float ration) {
 	float thro_torque = max_torque * ration;
 
 	float acc_r = 1.0f;
-	if (_throttle.thro_ration_last < 1.0f) {
-		acc_r = (ration - _throttle.thro_ration_last)/ (1.0f - _throttle.thro_ration_last);
+	if (_throttle.throttle_opening_last < 1.0f) {
+		acc_r = (ration - _throttle.throttle_opening_last)/ (1.0f - _throttle.throttle_opening_last);
 	}
 	acc_r = fclamp(acc_r, 0, 1.0f);
 	float acc_torque = _throttle.torque_real + acc_r * (max_torque - _throttle.torque_real);
@@ -234,32 +234,32 @@ static float _throttle_torque_for_accelerate(float ration) {
 
 
 static float throttle_torque_for_accelerate(void) {
-	return _throttle_torque_for_accelerate(_throttle.thro_ration);
+	return _throttle_torque_for_accelerate(_throttle.throttle_opening);
 }
 
 static float throttle_torque_for_decelerate(void) {
-	if (_throttle.thro_ration_last == 0.0f) {
+	if (_throttle.throttle_opening_last == 0.0f) {
 		return 0;
 	}
-	float dec_r = _throttle.thro_ration / _throttle.thro_ration_last;
+	float dec_r = _throttle.throttle_opening / _throttle.throttle_opening_last;
 	dec_r = fclamp(dec_r, 0.0f, 1.0f);
 	return dec_r * _throttle.torque_real;
 }
 
 float throttle_get_open_ration_filted(void) {
-	return _throttle.thro_ration;
+	return _throttle.throttle_opening;
 }
 
 #define THRO_RPM_LP_CEOF 0.01f
 float throttle_get_torque(mot_contrl_t * ctrl, float vol) {
-	float thro_r = throttle_vol_to_open_ration(vol);
+	float throttle_opening = throttle_vol_to_opening(vol);
 	float vel = mot_contrl_get_speed(ctrl);
 	_throttle.gear = mc_get_internal_gear();
 	LowPass_Filter(_throttle.vel_filted, vel, THRO_RPM_LP_CEOF);
 
-	if (thro_r > _throttle.thro_ration) {
+	if (throttle_opening > _throttle.throttle_opening) {
 		if (!_throttle.accl) {
-			_throttle.thro_ration_last = _throttle.thro_ration;
+			_throttle.throttle_opening_last = _throttle.throttle_opening;
 			_throttle.torque_real = _throttle.torque_req;
 			if (_throttle.torque_real < 0) { //电子刹车的时候,扭矩可能为负
 				_throttle.torque_real = 0;
@@ -267,9 +267,9 @@ float throttle_get_torque(mot_contrl_t * ctrl, float vol) {
 			_throttle.torque_acc_ = 0;
 		}
 		_throttle.accl = true;
-	}else if (thro_r < _throttle.thro_ration) {
+	}else if (throttle_opening < _throttle.throttle_opening) {
 		if (_throttle.accl) {
-			_throttle.thro_ration_last = _throttle.thro_ration;
+			_throttle.throttle_opening_last = _throttle.throttle_opening;
 			_throttle.torque_real = ctrl->target_torque_raw;
 			/* 如果扭矩给定的ramp没有结束,使用原始扭矩请求作为减扭矩的起始点 */
 			if (_throttle.torque_req - line_ramp_get_interp(&ctrl->input_torque) >= 10.0f ) {
@@ -281,7 +281,7 @@ float throttle_get_torque(mot_contrl_t * ctrl, float vol) {
 		}
 		_throttle.accl = false;
 	}
-	_throttle.thro_ration = thro_r;
+	_throttle.throttle_opening = throttle_opening;
 	if (_throttle.accl) {
 		return throttle_torque_for_accelerate();
 	}else {
@@ -348,6 +348,6 @@ float get_user_request_torque(void) {
 
 
 void throttle_log(void) {
-	sys_debug("r:%f, last %f, real:%f, req %f\n", _throttle.thro_ration, _throttle.thro_ration_last, _throttle.torque_real, _throttle.torque_req);
+	sys_debug("r:%f, last %f, real:%f, req %f\n", _throttle.throttle_opening, _throttle.throttle_opening_last, _throttle.torque_real, _throttle.torque_req);
 	sys_debug("thro: %f-%f, %f\n", throttle_start_vol(), throttle_end_vol(), mc_gear_max_torque((s16)_throttle.vel_filted, _throttle.gear));
 }

+ 4 - 4
Applications/foc/motor/throttle.h

@@ -12,8 +12,8 @@ typedef struct {
 	float torque_real;
 	float torque_acc_;
 	float vel_filted;
-	float thro_ration;
-	float thro_ration_last;
+	float throttle_opening;
+	float throttle_opening_last;
 	u8    gear;
 }throttle_torque_t;
 
@@ -33,8 +33,8 @@ void throttle_set_torque(mot_contrl_t * ctrl, float torque);
 float throttle_get_torque(mot_contrl_t * ctrl, float vol);
 float throttle_get_open_ration_filted(void);
 float get_user_request_torque(void);
-float throttle_open_ration_to_vol(float r);
-float throttle_vol_to_open_ration(float thro_val);
+float throttle_opening_to_vol(float r);
+float throttle_vol_to_opening(float thro_val);
 void throttle_torque_reset(void);
 #endif /* _THROTTLE_H__ */