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

扭矩加速时间通过接口获取

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

+ 5 - 0
Applications/foc/core/controller.h

@@ -296,6 +296,11 @@ static __INLINE bool mot_contrl_ebrk_is_running(mot_contrl_t *ctrl) {
 static __INLINE float mot_contrl_get_final_torque(mot_contrl_t *ctrl) {
 	return ctrl->input_torque.target;
 }
+
+static __INLINE u32 mot_contrl_get_torque_acc_time(mot_contrl_t *ctrl) {
+	return ctrl->input_torque.time;
+}
+
 static __INLINE void line_ramp_init(lineramp_t *line, float time) {
 	line->target = 0;
 	line->interpolation = 0;

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

@@ -308,7 +308,7 @@ void throttle_set_torque(mot_contrl_t * ctrl, float torque) {
 		/* 处理加速ramp时间的变化,需要缓慢变小,变大可以立即处理,
 		*  加速时间缓慢变小可以防止突然大扭矩加速
 		*/
-		u16 now_ramp_time = ctrl->input_torque.time;
+		u16 now_ramp_time = mot_contrl_get_torque_acc_time(ctrl);
 		u16 next_ramp_time = mc_get_gear_config()->accl_time;
 		if (curr_vel < CONFIG_ZERO_SPEED_RAMP_RMP) {
 			next_ramp_time = mc_get_gear_config()->zero_accl;