serwis - 2 days ago

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

IF Exe = FALSE THEN
delay(IN:=TRUE, PT:=T#1MS);
    IF delay.Q = TRUE THEN
        Exe := TRUE;
        delay(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