Parcourir la source

当设置限流、限速、限扭操作,从当前实际的母线电流、转速、扭矩开始做ramp处理,增加跟随性

Signed-off-by: kevin <huhui@sharkgulf.com>
kevin il y a 2 ans
Parent
commit
f7e75bdb69
1 fichiers modifiés avec 6 ajouts et 15 suppressions
  1. 6 15
      Applications/foc/core/controller.c

+ 6 - 15
Applications/foc/core/controller.c

@@ -636,11 +636,8 @@ void mot_contrl_set_dccurr_limit(mot_contrl_t *ctrl, float ibusLimit) {
 		ibusLimit = min(ibusLimit, ctrl->protlim.dc_curr);
 	}
 	ctrl->userlim.dc_curr = ibusLimit;
-	if (ABS(ctrl->dc_curr_filted) <= ibusLimit){
-		line_ramp_reset(&ctrl->ramp_dc_curr_lim, ctrl->userlim.dc_curr);
-	}else {
-		line_ramp_set_target(&ctrl->ramp_dc_curr_lim, ctrl->userlim.dc_curr);
-	}
+	line_ramp_reset(&ctrl->ramp_dc_curr_lim, ctrl->dc_curr_filted);//从当前实际母线电流开始做ramp
+	line_ramp_set_target(&ctrl->ramp_dc_curr_lim, ctrl->userlim.dc_curr);
 }
 
 void mot_contrl_set_vel_limit(mot_contrl_t *ctrl, float vel) {
@@ -648,11 +645,8 @@ void mot_contrl_set_vel_limit(mot_contrl_t *ctrl, float vel) {
 		vel = ctrl->hwlim.mot_vel;
 	}
 	ctrl->userlim.mot_vel = vel;
-	if (ABS(ctrl->foc.in.mot_velocity) <= vel) {
-		line_ramp_reset(&ctrl->ramp_vel_lim, ctrl->userlim.mot_vel);
-	}else {
-		line_ramp_set_target(&ctrl->ramp_vel_lim, ctrl->userlim.mot_vel);
-	}
+	line_ramp_reset(&ctrl->ramp_vel_lim, ctrl->foc.in.mot_velocity);//从当前实际转速做ramp
+	line_ramp_set_target(&ctrl->ramp_vel_lim, ctrl->userlim.mot_vel);
 }
 
 void mot_contrl_set_vel_limit_rttime(mot_contrl_t *ctrl, u32 time) {
@@ -669,11 +663,8 @@ void mot_contrl_set_torque_limit(mot_contrl_t *ctrl, float torque) {
 		torque = min(torque, ctrl->protlim.torque);
 	}
 	ctrl->userlim.torque = torque;
-	if (ABS(ctrl->target_torque) <= torque){
-		line_ramp_reset(&ctrl->ramp_torque_lim, ctrl->userlim.torque);
-	}else {
-		line_ramp_set_target(&ctrl->ramp_torque_lim, ctrl->userlim.torque);
-	}
+	line_ramp_reset(&ctrl->ramp_torque_lim, ctrl->target_torque_raw);//从当前给定的torque做ramp
+	line_ramp_set_target(&ctrl->ramp_torque_lim, ctrl->userlim.torque);
 }
 
 void mot_contrl_set_torque_limit_rttime(mot_contrl_t *ctrl, u32 time) {