Browse Source

解决获取相应挡位的最大扭矩错误

Signed-off-by: unknown <huhui@sharkgulf.com>
unknown 2 năm trước cách đây
mục cha
commit
03b111efd0
1 tập tin đã thay đổi với 1 bổ sung1 xóa
  1. 1 1
      Applications/foc/motor/motor.c

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

@@ -279,7 +279,7 @@ float mc_gear_max_torque(s16 vel, u8 gear_n) {
 		return gear_rpm_2_torque(gear->torque[0], gear->max_torque);
 	}
 	int vel_idx = vel / 1000;
-	if (vel >= CONFIG_GEAR_SPEED_TRQ_NUM -1 ) {
+	if (vel_idx >= CONFIG_GEAR_SPEED_TRQ_NUM -1 ) {
 		return gear_rpm_2_torque(gear->torque[CONFIG_GEAR_SPEED_TRQ_NUM-1], gear->max_torque);
 	}
 	float torque_1 = gear_rpm_2_torque(gear->torque[vel_idx-1], gear->max_torque);