Hello,
I am trying to control a servo drive and dynamically set its position. I control the drive via EtherCAT with a cycle time of 500us. I use the MC_MoveAbsolute block for this. The problem is that when using a PID controller, I generate the positions I want the drive to move to on an ongoing basis, and I would like the position to be set immediately. The MC_MoveAbsolute block must receive a rising edge to execute, and I would like the movement to be performed without waiting for this edge. I have created a function that generates a rising edge every 1 ms, but I am unable to change this time to 500 Β΅s because the TON function does not support times shorter than 1 ms. Below is the code to call the rising edge:
IF Exe = TRUE THEN
delay1(IN:=TRUE, PT:=T#1MS);
IF delay1.Q = TRUE THEN
Exe := FALSE;
delay1(IN:=FALSE);
END_IF
END_IF
Hello,
I am trying to control a servo drive and dynamically set its position. I control the drive via EtherCAT with a cycle time of 500us. I use the MC_MoveAbsolute block for this. The problem is that when using a PID controller, I generate the positions I want the drive to move to on an ongoing basis, and I would like the position to be set immediately. The MC_MoveAbsolute block must receive a rising edge to execute, and I would like the movement to be performed without waiting for this edge. I have created a function that generates a rising edge every 1 ms, but I am unable to change this time to 500 Β΅s because the TON function does not support times shorter than 1 ms. Below is the code to call the rising edge:
IF Exe = TRUE THEN
delay1(IN:=TRUE, PT:=T#1MS);
IF delay1.Q = TRUE THEN
Exe := FALSE;
delay1(IN:=FALSE);
END_IF
END_IF
END_IF
Here is the code for calling the MC_MoveAbsolute function:
MoveDegree(
Axis:= Tilt,
Execute:= Exe,
Position:= position_target - (base_angle_real * feedforward_turn),
Velocity:= vel,
Acceleration:= acc,
Deceleration:= dec,
Jerk:= jerk,
Direction:= MC_DIRECTION.shortest,
BufferMode:= MC_BUFFER_MODE.Aborting,
Done=> ,
Busy=> ,
Active=> ,
CommandAborted=> ,
Error=> ,
ErrorID=> );
I realize that there are probably better methods for performing this type of task. How can I implement motion with a dynamically changing setpoint?
THANKS
Hi kporter,
a more direct way would be to use SMC_FollowPosition to write the set positions directly to the servo drive.
This FB has reacts on changes of the fSetPosition on each call, without a need for a rising edge on Execute.
See https://content.helpme-codesys.com/en/libs/SM3_Basic/Current/SM3_Basic/POUs/Movement/Direct/SMC_FollowPosition.html.
Best regards,
Georg