Переглянути джерело

修改max_trq为max_torque

Signed-off-by: huhui <huhui@sharkgulf.com>
huhui 2 роки тому
батько
коміт
4f6c4e7931

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

@@ -25,8 +25,8 @@ void thro_torque_init(void) {
 	_torque.spd_filted = 0.0f;
 }
 
-static __INLINE float gear_rpm_torque(u8 trq, s16 max) {
-	return (float)trq/100.0f * max;
+static __INLINE float gear_rpm_torque(u8 torque, s16 max) {
+	return (float)torque/100.0f * max;
 }
 
 float thro_torque_gear_map(s16 rpm, u8 gear) {
@@ -39,14 +39,14 @@ float thro_torque_gear_map(s16 rpm, u8 gear) {
 		rpm = _current_gear->max_speed;
 	}
 	if (rpm <= 1000) {
-		return gear_rpm_torque(_current_gear->torque[0], _current_gear->max_trq);
+		return gear_rpm_torque(_current_gear->torque[0], _current_gear->max_torque);
 	}
 
 	for (int i = 1; i < CONFIG_GEAR_SPEED_TRQ_NUM; i++) {
 		if (rpm <= 1000 * (i + 1)) { //线性插值
-			float trq1 = gear_rpm_torque(_current_gear->torque[i-1], _current_gear->max_trq);
+			float trq1 = gear_rpm_torque(_current_gear->torque[i-1], _current_gear->max_torque);
 			float min_rpm = (i * 1000);
-			float trq2 = gear_rpm_torque(_current_gear->torque[i], _current_gear->max_trq);
+			float trq2 = gear_rpm_torque(_current_gear->torque[i], _current_gear->max_torque);
 			float max_rpm = (i + 1) * 1000;
 			if (trq1 > trq2) {
 				return f_map_inv((float)rpm, min_rpm, max_rpm, trq2, trq1);
@@ -55,7 +55,7 @@ float thro_torque_gear_map(s16 rpm, u8 gear) {
 			}
 		}
 	}
-	return gear_rpm_torque(_current_gear->torque[CONFIG_GEAR_SPEED_TRQ_NUM-1], _current_gear->max_trq);
+	return gear_rpm_torque(_current_gear->torque[CONFIG_GEAR_SPEED_TRQ_NUM-1], _current_gear->max_torque);
 }
 
 /* 获取油门开度 */

+ 2 - 2
Applications/foc/limit.c

@@ -139,7 +139,7 @@ static u16 _motor_limit(void) {
 			float delta_value = (prv_lim_value - (float)lim->limit_value);
 			float curr_value = prv_lim_value - (float)(temp - lim->enter_pointer)/delta_tmp * delta_value;
 			curr_value = fclamp(curr_value, 0, prv_lim_value);
-			lim_value = (u16)(((float)gear->max_trq * curr_value) / 100.0f);
+			lim_value = (u16)(((float)gear->max_torque * curr_value) / 100.0f);
 			mc_set_motor_lim_level(i + 1);
 			return lim_value;
 		}else {
@@ -196,7 +196,7 @@ static u16 _mos_limit(void) {
 			float delta_value = (prv_lim_value - (float)lim->limit_value);
 			float curr_value = prv_lim_value - (float)(temp - lim->enter_pointer)/delta_tmp * delta_value;
 			curr_value = fclamp(curr_value, 0, prv_lim_value);
-			lim_value = (u16)(((float)gear->max_trq * curr_value) / 100.0f);
+			lim_value = (u16)(((float)gear->max_torque * curr_value) / 100.0f);
 			mc_set_mos_lim_level(i + 1);
 			return lim_value;
 		}else {

+ 5 - 5
Applications/foc/mc_config.c

@@ -139,7 +139,7 @@ void mc_conf_load(void) {
 	do { \
 		conf.g_n[l].max_speed = CONFIG_Gear##l##_MaxSpeed;\
 		conf.g_n[l].max_idc = CONFIG_Gear##l##_MaxIdc;\
-		conf.g_n[l].max_trq = CONFIG_Gear##l##_MaxTorque;\
+		conf.g_n[l].max_torque = CONFIG_Gear##l##_MaxTorque;\
 		conf.g_n[l].zero_accl = CONFIG_Gear##l##_ZeroAccl;\
 		conf.g_n[l].accl_time = CONFIG_Gear##l##_NormalAccl;\
 		Gear_torque(l,0);Gear_torque(l,1);Gear_torque(l,2);Gear_torque(l,3);Gear_torque(l,4); \
@@ -151,7 +151,7 @@ void mc_conf_load(void) {
 		do { \
 			conf.g_l[l].max_speed = CONFIG_GearLow##l##_MaxSpeed;\
 			conf.g_l[l].max_idc = CONFIG_GearLow##l##_MaxIdc;\
-			conf.g_l[l].max_trq = CONFIG_GearLow##l##_MaxTorque;\
+			conf.g_l[l].max_torque = CONFIG_GearLow##l##_MaxTorque;\
 			conf.g_l[l].zero_accl = CONFIG_GearLow##l##_ZeroAccl;\
 			conf.g_l[l].accl_time = CONFIG_GearLow##l##_NormalAccl;\
 			GearLow_torque(l,0);GearLow_torque(l,1);GearLow_torque(l,2);GearLow_torque(l,3);GearLow_torque(l,4); \
@@ -441,7 +441,7 @@ int mc_conf_decode_gear(gear_t *g , u8 *buff) {
 	u8 *ori = buff;
 	for (int i = 0; i < CONFIG_MAX_GEARS; i++) {
 		g[i].max_speed = decode_s16(buff); buff += 2;
-		g[i].max_trq = decode_s16(buff); buff += 2;
+		g[i].max_torque = decode_s16(buff); buff += 2;
 		g[i].max_idc = decode_s16(buff); buff += 2;
 		g[i].zero_accl = decode_u16(buff); buff += 2;
 		g[i].accl_time = decode_u16(buff); buff += 2;
@@ -451,7 +451,7 @@ int mc_conf_decode_gear(gear_t *g , u8 *buff) {
 				g[i].torque[j] = 100;
 			}
 		}
-		g[i].max_trq = min(g[i].max_trq, conf.c.max_torque);
+		g[i].max_torque = min(g[i].max_torque, conf.c.max_torque);
 		g[i].max_idc = min(g[i].max_idc, conf.c.max_idc);
 	}
 	return buff - ori;
@@ -461,7 +461,7 @@ int mc_conf_encode_gear(gear_t *g, u8 *buff) {
 	u8 *ori = buff;
 	for (int i = 0; i < CONFIG_MAX_GEARS; i++) {
 		encode_s16(buff, g[i].max_speed); buff += 2;
-		encode_s16(buff, g[i].max_trq); buff += 2;
+		encode_s16(buff, g[i].max_torque); buff += 2;
 		encode_s16(buff, g[i].max_idc); buff += 2;
 		encode_u16(buff, g[i].zero_accl); buff += 2;
 		encode_u16(buff, g[i].accl_time); buff += 2;

+ 1 - 1
Applications/foc/mc_config.h

@@ -73,7 +73,7 @@ typedef struct {
 
 typedef struct {
 	s16 max_speed; //最大速度, rpm
-	s16 max_trq;   //最大扭矩
+	s16 max_torque;   //最大扭矩
 	s16 max_idc;   //最大母线电流
 	u16 zero_accl; //零速启动扭矩给定时间,防止翘头
 	u16 accl_time; //加速的扭矩斜坡时间

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

@@ -55,7 +55,7 @@ static m_contrl_t motor = {
 /* 无感运行的挡位,限制速度,母线电流,最大扭矩 */
 static gear_t sensorless_gear = {
 	.max_speed = CONFIG_SENSORLESS_MAX_SPEED,
-	.max_trq = CONFIG_SENSORLESS_MAX_TORQUE,
+	.max_torque = CONFIG_SENSORLESS_MAX_TORQUE,
 	.max_idc = CONFIG_SENSORLESS_MAX_IDC,
 	.zero_accl = 1500,
 	.accl_time = 1500,
@@ -219,15 +219,15 @@ static void _led_off_timer_handler(shark_timer_t *t) {
 static void mc_gear_vmode_changed(void) {
 	gear_t *gears = mc_get_gear_config();
 	if (gears != &sensorless_gear) {
-		sensorless_gear.max_trq = gears->max_trq;
+		sensorless_gear.max_torque = gears->max_torque;
 	}else { //slowly changed
 		eRamp_set_time(&(PMSM_FOC_Get()->rtLim.rpmLimRamp), CONFIG_SENSORLESS_RAMP_TIME, CONFIG_SENSORLESS_RAMP_TIME);
 		eRamp_set_time(&(PMSM_FOC_Get()->rtLim.DCCurrLimRamp), CONFIG_SENSORLESS_RAMP_TIME, CONFIG_SENSORLESS_RAMP_TIME);
 	}
 	PMSM_FOC_SpeedLimit((float)gears->max_speed);
 	PMSM_FOC_DCCurrLimit((float)min(gears->max_idc, motor.u_set.idc_lim));
-	PMSM_FOC_TorqueLimit((float)gears->max_trq);
-	sys_debug("change %d, %d, %d\n", gears->max_idc, gears->max_speed, gears->max_trq);
+	PMSM_FOC_TorqueLimit((float)gears->max_torque);
+	sys_debug("change %d, %d, %d\n", gears->max_idc, gears->max_speed, gears->max_torque);
 }
 
 static s16 mc_get_gear_idc_limit(void) {