Execute := Mv_Zero_Ex, Velocity := Mv_Zero_Vel, Acceleration := Mv_Zero_Acc, Deceleration := Mv_Zero_Dec, BufferMode := Mv_Zero_Bm, Done => Mv_Zero_D,
Busy => Mv_Zero_Bsy, Active => Mv_Zero_Act,
CommandAborted => Mv_Zero_Ca, Error => Mv_Zero_Err,
ErrorID => Mv_Zero_ErrID );
Operation Example
In this sample, multi-execution of absolute positioning instructions is used to position in a range of 0°
to 360°. The actual position returns to 0° once it exceeds the range of 0° to 360°.
Multi-execution of instructions is performed when the Active (Controlling) output variable from the pre-vious instruction is TRUE. For single-axis operation, multi-execution is possible for only one instruc-tion.
In this sample, multi-execution of instructions is executed with BufferMode (Buffer Mode Selection) set to Buffered.
Shortest-way positioning is performed.
0°
360°
90°
180° 120°
290° 300°
If you specify 0° (home), 90°, 120°, or 290°, the axis will move to that position.
The rotation direction in this instance is in the shorter rotation direction. The travel velocity is 250°/s.
The sample programming performs positioning with a shortest way specification from 290° to 90° to 120° and then to home (0°).
Ladder Diagram
Main Variables
Name Data type Default Comment
MC_Axis000 _sAXIS_REF --- Axis Variable for axis 1.
MC_Axis000.MFaultLvl.Active BOOL FALSE TRUE while there is a minor fault level error for axis 1.
MC_Axis000.Details.Homed BOOL FALSE TRUE when home is defined for axis 1.
Pwr_Status BOOL FALSE This variable is assigned to the Status output
variable from the PWR instance of the MC_Pow-er instruction. This variable changes to TRUE when the Servo is turned ON.
StartPg BOOL FALSE The Servo is turned ON if this variable is TRUE
and EtherCAT process data communications are established.
Timing Chart
Pwr_Status Hm_D Hm_Bsy Mv_Abs1_D Mv_Abs1_Bsy Mv_Abs1_Act Mv_Abs2_D Mv_Abs2_Bsy Mv_Abs2_Act Mv_Abs3_D Mv_Abs3_Bsy Mv_Abs3_Act Mv_Abs4_D Mv_Abs4_Bsy Mv_Abs4_Act
MC_Axis000 Command velocity
Time
Sample Programming
StartPg MC_Axis000.DrvStatus.Ready Lock1
If StartPg is TRUE, check that the Servo Drive is ready.
PWR
Error
Axis Axis
Enable Status
Busy MC_Power
ErrorID
Lock1 MC_Axis000 Pwr_Status
Pwr_Bsy Pwr_Err Pwr_ErrID If the Servo Drive is ready, the Servo is turned ON.
FaultHandler MC_Axis000.MFaultLvl.Active
FaultHandler EN
If a minor fault level error occurs for axis 1, the error handler for the device (FaultHandler) is executed.
Program the FaultHandler according to the device.
MC_MoveAbsolute
3
Sample Programming 2
HM
Axis Axis
Execute
Error ErrorID CommandAborted MC_Home
Done Busy MC_Axis000
Pwr_Status Hm_D
Hm_Bsy Hm_Ca Hm_Err Hm_ErrID MC_Axis000.Details.Homed
If the Servo is ON and home is not defined, the Home instruction is executed.
BufferMode
MV_ABS1
Deceleration
Active
Axis Axis
Execute Done
Position Busy
Acceleration
Error Jerk
Direction
MC_MoveAbsolute
Velocity
CommandAborted ErrorID MC_Axis000
Hm_D
_eMC_DIRECTION#_mcShortestWay LREAL#290.0 LREAL#250.0 LREAL#1000.0 LREAL#1000.0
Mv_Abs1_Bsy Mv_Abs1_Act Mv_Abs1_Ca Mv_Abs1_Err Mv_Abs1_ErrID
Mv_Abs1_D After home is defined, absolute positioning 1 is executed to move to 290.0°.
The shortest way is specified for the motion direction.
BufferMode
MV_ABS2
Deceleration
Active
Axis Axis
Execute Done
Position Busy
Acceleration
Error Jerk
Direction
MC_MoveAbsolute
Velocity
CommandAborted ErrorID MC_Axis000
Mv_Abs1_Act
_eMC_DIRECTION#_mcShortestWay _eMC_BUFFER_MODE#_mcBuffered LREAL#90.0 LREAL#250.0 LREAL#1000.0 LREAL#1000.0
Mv_Abs2_Bsy Mv_Abs2_Act Mv_Abs2_Ca Mv_Abs2_Err Mv_Abs2_ErrID
Mv_Abs2_D Absolute positioning 2 is executed with multi-execution of instructions to move from 290.0° to 90.0°.
The shortest way is used for the motion direction.
BufferMode
MV_ABS3
Deceleration
Active
Axis Axis
Execute Done
Position Busy
Acceleration
Error Jerk
Direction
MC_MoveAbsolute
Velocity
CommandAborted ErrorID MC_Axis000
Mv_Abs2_Act
_eMC_DIRECTION#_mcShortestWay _eMC_BUFFER_MODE#_mcBuffered LREAL#120.0 LREAL#250.0 LREAL#1000.0 LREAL#1000.0
Mv_Abs3_Bsy Mv_Abs3_Act Mv_Abs3_Ca Mv_Abs3_Err Mv_Abs3_ErrID
Mv_Abs3_D Absolute positioning 3 is executed with multi-execution of instructions to move from 90.0° to 120.0°.
The shortest way is used for the motion direction.
BufferMode
MV_ABS4
Deceleration
Active
Axis Axis
Execute Done
Position Busy
Acceleration
Error Jerk
Direction
MC_MoveAbsolute
Velocity
CommandAborted ErrorID MC_Axis000
Mv_Abs3_Act
_eMC_DIRECTION#_mcShortestWay _eMC_BUFFER_MODE#_mcBuffered LREAL#0.0 LREAL#250.0 LREAL#1000.0 LREAL#1000.0
Mv_Abs4_Bsy Mv_Abs4_Act Mv_Abs4_Ca Mv_Abs4_Err Mv_Abs4_ErrID
Mv_Abs4_D Absolute positioning 4 is executed with multi-execution of instructions to move from 120.0° to 0.0°.
The shortest way is used for the motion direction.
Structured Text (ST)
Main Variables
Name Data type Default Comment
MC_Axis000 _sAXIS_REF --- Axis Variable for axis 1.
MC_Axis000.MFaultLvl.Active BOOL FALSE TRUE while there is a minor fault level error for axis 1.
MC_Axis000.Details.Homed BOOL FALSE TRUE when home is defined for axis 1.
Pwr_Status BOOL FALSE This variable is assigned to the Status output
variable from the PWR instance of the MC_Pow-er instruction. This variable changes to TRUE when the Servo is turned ON.
StartPg BOOL FALSE The Servo is turned ON if this variable is TRUE
and EtherCAT process data communications are established.
Hm_Ex BOOL FALSE The HM instance of MC_Home is executed
when this variable changes to TRUE.
Mv_Abs1_Ex BOOL FALSE The MV_ABS1 instance of MC_MoveAbsolute is
executed when this variable changes to TRUE.
Mv_Abs2_Ex BOOL FALSE The MV_ABS2 instance of MC_MoveAbsolute is
executed when this variable changes to TRUE.
Mv_Abs3_Ex BOOL FALSE The MV_ABS3 instance of MC_MoveAbsolute is
executed when this variable changes to TRUE.
Mv_Abs4_Ex BOOL FALSE The MV_ABS4 instance of MC_MoveAbsolute is
executed when this variable changes to TRUE.
InitFlag BOOL FALSE This variable indicates if it is necessary to set
the input parameters.
Input parameters are set when this variable is FALSE. When setting the input parameters is completed, this variable changes to TRUE.
MC_MoveAbsolute
3
Sample Programming 2
Timing Chart
Pwr_Status Hm_Ex Hm_D Hm_Bsy Mv_Abs1_Ex Mv_Abs1_D Mv_Abs1_Bsy Mv_Abs1_Act Mv_Abs2_Ex Mv_Abs2_D Mv_Abs2_Bsy Mv_Abs2_Act Mv_Abs3_Ex Mv_Abs3_D Mv_Abs3_Bsy Mv_Abs3_Act Mv_Abs4_Ex Mv_Abs4_D Mv_Abs4_Bsy Mv_Abs4_Act
MC_Axis000 Command velocity
Time
Sample Programming
// Processing when input parameters are not set IF InitFlag = FALSE THEN
// MV_ABS1 parameters Mv_Abs1_Pos := LREAL#290.0;
Mv_Abs1_Vel := LREAL#250.0;
Mv_Abs1_Acc := LREAL#1000.0;
Mv_Abs1_Dec := LREAL#1000.0;
Mv_Abs1_Dir := _eMC_DIRECTION#_mcShortestWay;
// MV_ABS2 parameters Mv_Abs2_Pos := LREAL#90.0;
Mv_Abs2_Acc := LREAL#1000.0;
Mv_Abs2_Dec := LREAL#1000.0;
Mv_Abs2_Dir := _eMC_DIRECTION#_mcShortestWay;
Mv_Abs2_Bm := _eMC_BUFFER_MODE#_mcBuffered;
// MV_ABS3 parameters Mv_Abs3_Pos := LREAL#120.0;
Mv_Abs3_Vel := LREAL#250.0;
Mv_Abs3_Acc := LREAL#1000.0;
Mv_Abs3_Dec := LREAL#1000.0;
Mv_Abs3_Dir := _eMC_DIRECTION#_mcShortestWay;
Mv_Abs3_Bm := _eMC_BUFFER_MODE#_mcBuffered;
// MV_ABS4 parameters Mv_Abs4_Pos := LREAL#0.0;
Mv_Abs4_Vel := LREAL#250.0;
Mv_Abs4_Acc := LREAL#1000.0;
Mv_Abs4_Dec := LREAL#1000.0;
Mv_Abs4_Dir := _eMC_DIRECTION#_mcShortestWay;
Mv_Abs4_Bm := _eMC_BUFFER_MODE#_mcBuffered;
// Change InitFlag to TRUE after setting the input parameters.
InitFlag := TRUE;
END_IF;
// If StartPg is TRUE and the Servo Drive is ready, the Servo is turned ON.
// If the Servo Drive is not ready, the Servo is turned OFF.
IF (StartPg=TRUE)
AND (MC_Axis000.DrvStatus.Ready=TRUE) THEN Pwr_En:=TRUE;
ELSE
Pwr_En:=FALSE;
END_IF;
// Processing for a minor fault level error
// Program the FaultHandler according to the device.
IF MC_Axis000.MFaultLvl.Active=TRUE THEN FaultHandler();
END_IF;
// If the Servo is ON and home is not defined, the Home instruction is executed.
IF (Pwr_Status=TRUE) AND (MC_Axis000.Details.Homed=FALSE) THEN Hm_Ex:=TRUE;
END_IF;
// After home is defined, MV_ABS1 is executed.
MC_MoveAbsolute
3
Sample Programming 2
IF Hm_D=TRUE THEN Mv_Abs1_Ex:=TRUE;
END_IF;
// After MV_ABS1 is started, MV_ABS2 is executed with multi-execution of instructio ns.
IF Mv_Abs1_Act=TRUE THEN Mv_Abs2_Ex:=TRUE;
END_IF;
// After MV_ABS2 is started, MV_ABS3 is executed with multi-execution of instructio ns.
IF Mv_Abs2_Act=TRUE THEN Mv_Abs3_Ex:=TRUE;
END_IF;
// After MV_ABS3 is started, MV_ABS4 is executed with multi-execution of instructio ns.
IF Mv_Abs3_Act=TRUE THEN Mv_Abs4_Ex:=TRUE;
END_IF;
// MC_Power PWR(
Axis := MC_Axis000, Enable := Pwr_En, Status => Pwr_Status, Busy => Pwr_Bsy, Error => Pwr_Err, ErrorID => Pwr_ErrID );
// MC_Home HM(
Axis := MC_Axis000, Execute := Hm_Ex, Done => Hm_D, Busy => Hm_Bsy,
CommandAborted => Hm_Ca, Error => Hm_Err,
ErrorID => Hm_ErrID );
// Absolute positioning (1) MV_ABS1(
Axis := MC_Axis000,
Position := Mv_Abs1_Pos, Velocity := Mv_Abs1_Vel, Acceleration := Mv_Abs1_Acc, Deceleration := Mv_Abs1_Dec, Direction := Mv_Abs1_Dir, Done => Mv_Abs1_D,
Busy => Mv_Abs1_Bsy, Active => Mv_Abs1_Act,
CommandAborted => Mv_Abs1_Ca, Error => Mv_Abs1_Err,
ErrorID => Mv_Abs1_ErrID );
// Absolute positioning (2) MV_ABS2(
Axis := MC_Axis000, Execute := Mv_Abs2_Ex, Position := Mv_Abs2_Pos, Velocity := Mv_Abs2_Vel, Acceleration := Mv_Abs2_Acc, Deceleration := Mv_Abs2_Dec, Direction := Mv_Abs2_Dir, BufferMode := Mv_Abs2_Bm, Done => Mv_Abs2_D,
Busy => Mv_Abs2_Bsy, Active => Mv_Abs2_Act,
CommandAborted => Mv_Abs2_Ca, Error => Mv_Abs2_Err,
ErrorID => Mv_Abs2_ErrID );
// Absolute positioning (3) MV_ABS3(
Axis := MC_Axis000, Execute := Mv_Abs3_Ex, Position := Mv_Abs3_Pos, Velocity := Mv_Abs3_Vel, Acceleration := Mv_Abs3_Acc, Deceleration := Mv_Abs3_Dec, Direction := Mv_Abs3_Dir, BufferMode := Mv_Abs3_Bm, Done => Mv_Abs3_D,
Busy => Mv_Abs3_Bsy, Active => Mv_Abs3_Act,
CommandAborted => Mv_Abs3_Ca, Error => Mv_Abs3_Err,
ErrorID => Mv_Abs3_ErrID
MC_MoveAbsolute
3
Sample Programming 2
);
// Absolute positioning (4) MV_ABS4(
Axis := MC_Axis000, Execute := Mv_Abs4_Ex, Position := Mv_Abs4_Pos, Velocity := Mv_Abs4_Vel, Acceleration := Mv_Abs4_Acc, Deceleration := Mv_Abs4_Dec, Direction := Mv_Abs4_Dir, BufferMode := Mv_Abs4_Bm, Done => Mv_Abs4_D,
Busy => Mv_Abs4_Bsy, Active => Mv_Abs4_Act,
CommandAborted => Mv_Abs4_Ca, Error => Mv_Abs4_Err,
ErrorID => Mv_Abs4_ErrID );