Hello,
I am struggling to code in Structured Text a closed loop control motion control with Acceleration and Jerk limiting. Can anyone help me out more with the formulas and logical order:-
I am using a PID function block that is working perfectly and taking in a setpoint and actual value and the output is the position.
This output position (pos_cmd_out) is then velocity limited using the code below that is working perfectly.
My query is would acceleration limiting (and Jeck) be done after the velocity limiting (taking the velocity limited position command output - velocity_lmt_pos_cmd)?
I would have 2 setpoints, maximum acceleration and maximum jerk.
Any help putting me in the right direction would be great.
Thanks
(* Calculate allowed velocity per time step. Scan time (in Secs i.e. 1ms = 0.01) * velocity limit *)
max_velocity_step:= scan_time * max_velocity;
(* Calculate the command difference from the previous step *)
cmd_diff_per_step:=ABS(pos_cmd_out - pos_cmd_prev);
(* Check to see if position command need to be velocity limited *)
IF cmd_diff_per_step > max_velocity_step THEN
(* Command Velocity is being limited *)
velocity_limiting:=1;
(* Calculate direction of position that velocity limited *)
IF pos_cmd_out > pos_cmd_prev THEN
velocity_lmt_pos_cmd:=pos_cmd_prev + max_velocity_step;
ELSE
velocity_lmt_pos_cmd:=pos_cmd_prev - max_velocity_step;
END_IF
ELSE
(* Command Velocity is not being limited *)
velocity_limiting:=0;
velocity_lmt_pos_cmd:=pos_cmd_out;
END_IF
(* Record the previous velocity *)
pos_cmd_prev:=velocity_lmt_pos_cmd
I am struggling to code in Structured Text a closed loop control motion control with Acceleration and Jerk limiting. Can anyone help me out more with the formulas and logical order:-
I am using a PID function block that is working perfectly and taking in a setpoint and actual value and the output is the position.
This output position (pos_cmd_out) is then velocity limited using the code below that is working perfectly.
My query is would acceleration limiting (and Jeck) be done after the velocity limiting (taking the velocity limited position command output - velocity_lmt_pos_cmd)?
I would have 2 setpoints, maximum acceleration and maximum jerk.
Any help putting me in the right direction would be great.
Thanks
(* Calculate allowed velocity per time step. Scan time (in Secs i.e. 1ms = 0.01) * velocity limit *)
max_velocity_step:= scan_time * max_velocity;
(* Calculate the command difference from the previous step *)
cmd_diff_per_step:=ABS(pos_cmd_out - pos_cmd_prev);
(* Check to see if position command need to be velocity limited *)
IF cmd_diff_per_step > max_velocity_step THEN
(* Command Velocity is being limited *)
velocity_limiting:=1;
(* Calculate direction of position that velocity limited *)
IF pos_cmd_out > pos_cmd_prev THEN
velocity_lmt_pos_cmd:=pos_cmd_prev + max_velocity_step;
ELSE
velocity_lmt_pos_cmd:=pos_cmd_prev - max_velocity_step;
END_IF
ELSE
(* Command Velocity is not being limited *)
velocity_limiting:=0;
velocity_lmt_pos_cmd:=pos_cmd_out;
END_IF
(* Record the previous velocity *)
pos_cmd_prev:=velocity_lmt_pos_cmd