Pārlūkot izejas kodu

修改函数名

Signed-off-by: unknown <huhui@sharkgulf.com>
unknown 2 gadi atpakaļ
vecāks
revīzija
9c8469f03d

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

@@ -30,7 +30,7 @@ static __INLINE float gear_rpm_torque(u8 torque, s16 max) {
 }
 
 float thro_torque_gear_map(s16 rpm, u8 gear) {
-	gear_t *_current_gear = mc_get_gear_config_by_gear(gear);
+	gear_t *_current_gear = mc_gear_conf_by_gear(gear);
 	if (_current_gear == NULL) {
 		return 0;
 	}

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

@@ -247,7 +247,7 @@ m_contrl_t * mc_params(void) {
 	return &motor;
 }
 
-gear_t *mc_get_gear_config_by_gear(u8 n_gear) {
+gear_t *mc_gear_conf_by_gear(u8 n_gear) {
 	gear_t *gears;
 	if (!foc_observer_is_encoder()) { //无感模式,受限运行
 		return &sensorless_gear;
@@ -261,32 +261,32 @@ gear_t *mc_get_gear_config_by_gear(u8 n_gear) {
 }
 
 gear_t *mc_gear_conf(void) {
-	return mc_get_gear_config_by_gear(motor.n_gear);
+	return mc_gear_conf_by_gear(motor.n_gear);
 }
 
 static __INLINE float gear_rpm_2_torque(u8 torque, s16 max) {
 	return (float)torque/100.0f * max;
 }
 
-float mc_get_max_torque_with_gear_vel(s16 vel, u8 gear) {
-	gear_t *_current_gear = mc_get_gear_config_by_gear(gear);
-	if (_current_gear == NULL) {
+float mc_gear_max_torque(s16 vel, u8 gear_n) {
+	gear_t *gear = mc_gear_conf_by_gear(gear_n);
+	if (gear == NULL) {
 		return 0;
 	}
 
-	if (vel > _current_gear->max_speed) {
-		vel = _current_gear->max_speed;
+	if (vel > gear->max_speed) {
+		vel = gear->max_speed;
 	}
 	vel = ABS(vel);
 	if (vel <= 1000) {
-		return gear_rpm_2_torque(_current_gear->torque[0], _current_gear->max_torque);
+		return gear_rpm_2_torque(gear->torque[0], gear->max_torque);
 	}
 
 	for (int i = 1; i < CONFIG_GEAR_SPEED_TRQ_NUM; i++) {
 		if (vel <= 1000 * (i + 1)) { //线性插值
-			float trq1 = gear_rpm_2_torque(_current_gear->torque[i-1], _current_gear->max_torque);
+			float trq1 = gear_rpm_2_torque(gear->torque[i-1], gear->max_torque);
 			float min_rpm = (i * 1000);
-			float trq2 = gear_rpm_2_torque(_current_gear->torque[i], _current_gear->max_torque);
+			float trq2 = gear_rpm_2_torque(gear->torque[i], gear->max_torque);
 			float max_rpm = (i + 1) * 1000;
 			if (trq1 > trq2) {
 				return f_map_inv((float)vel, min_rpm, max_rpm, trq2, trq1);
@@ -295,7 +295,7 @@ float mc_get_max_torque_with_gear_vel(s16 vel, u8 gear) {
 			}
 		}
 	}
-	return gear_rpm_2_torque(_current_gear->torque[CONFIG_GEAR_SPEED_TRQ_NUM-1], _current_gear->max_torque);
+	return gear_rpm_2_torque(gear->torque[CONFIG_GEAR_SPEED_TRQ_NUM-1], gear->max_torque);
 }
 
 

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

@@ -102,7 +102,7 @@ bool mc_set_cruise_speed(bool rpm_abs, float target_rpm);
 void mc_set_idc_limit(s16 limit);
 void mc_set_rpm_limit(s16 limit);
 gear_t *mc_gear_conf(void);
-gear_t *mc_get_gear_config_by_gear(u8 n_gear);
+gear_t *mc_gear_conf_by_gear(u8 n_gear);
 void mc_set_motor_lim_level(u8 l);
 void mc_set_mos_lim_level(u8 l);
 void motor_debug(void);
@@ -117,7 +117,7 @@ bool mc_ind_motor_start(bool start);
 void mc_enable_brkshutpower(u8 shut);
 void mc_enable_tcs(bool enable);
 bool mc_set_target_vel(s16 vel);
-float mc_get_max_torque_with_gear_vel(s16 vel, u8 gear);
+float mc_gear_max_torque(s16 vel, u8 gear);
 
 static __INLINE mot_contrl_t *mot_contrl(void) {
 	return &motor.controller;

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

@@ -205,7 +205,7 @@ void throttle_detect(bool ready) {
 }
 
 static float _throttle_torque_for_accelerate(float ration) {
-	float max_torque = mc_get_max_torque_with_gear_vel((s16)_throttle.vel_filted, _throttle.gear);
+	float max_torque = mc_gear_max_torque((s16)_throttle.vel_filted, _throttle.gear);
 	float thro_torque = max_torque * ration;
 
 	float acc_r = 1.0f;
@@ -349,5 +349,5 @@ 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("thro: %f-%f\n", throttle_start_vol(), throttle_end_vol());
+	sys_debug("thro: %f-%f, %f\n", throttle_start_vol(), throttle_end_vol(), mc_gear_max_torque((s16)_throttle.vel_filted, _throttle.gear));
 }