• 沒有找到結果。

Sample Programming

StartPg MC_Axis000.DrvStatus.ServoReady Lock1

If StartPg is TRUE, check that the Servo Drive is ready.

Lock1

PWR

Error

Axis Axis

Enable Status

Busy MC_Power

ErrorID

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.

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#_mcNoDirection LREAL#50.0 LREAL#10.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 started.

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#_mcNoDirection _eMC_BUFFER_MODE#_mcBuffered LREAL#100.0 LREAL#20.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 After absolute positioning 1 is started, absolute positioning 2 is started with multi-execution of instructions.

MC_MoveAbsolute

3

Sample Programming 1

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#_mcNoDirection _eMC_BUFFER_MODE#_mcBuffered LREAL#200.0 LREAL#30.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 After absolute positioning 2 is started, absolute positioning 3 is started with multi-execution of instructions.

MC_Axis000 Mv_Abs3_Act

_eMC_BUFFER_MODE#_mcBuffered LREAL#250.0 LREAL#1000.0 LREAL#1000.0

Mv_Zero_Bsy Mv_Zero_Act Mv_Zero_Ca Mv_Zero_Err Mv_Zero_ErrID

Mv_Zero_D MV_ZERO

Jerk

Active

Axis Axis

Execute Done

Velocity Busy

Deceleration

Error BufferMode

MC_MoveZeroPosition

Acceleration

CommandAborted ErrorID

After absolute positioning 3 is started, the MC_MoveZeroPosition (High-speed Home) instruction is executed.

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_Zero_Ex BOOL FALSE The MV_ZERO instance of

MC_MoveZeroPosi-Name Data type Default Comment

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.

 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_D Mv_Abs3_Ex

Mv_Abs3_Bsy Mv_Abs3_Act

Mv_Zero_D Mv_Zero_Ex

Mv_Zero_Bsy Mv_Zero_Act

 Sample Programming

// Processing when input parameters are not set IF InitFlag = FALSE THEN

// MV_ABS1 parameters Mv_Abs1_Pos := LREAL#50.0;

Mv_Abs1_Vel := LREAL#10.0;

Mv_Abs1_Acc := LREAL#1000.0;

Mv_Abs1_Dec := LREAL#1000.0;

Mv_Abs1_Dir :=_eMC_DIRECTION#_mcNoDirection;

// MV_ABS2 parameters Mv_Abs2_Pos := LREAL#100.0;

Mv_Abs2_Vel := LREAL#20.0;

Mv_Abs2_Acc := LREAL#1000.0;

MC_MoveAbsolute

3

Sample Programming 1

Mv_Abs2_Dec := LREAL#1000.0;

Mv_Abs2_Dir :=_eMC_DIRECTION#_mcNoDirection;

Mv_Abs2_Bm :=_eMC_BUFFER_MODE#_mcBuffered;

// MV_ABS3 parameters Mv_Abs3_Pos := LREAL#200.0;

Mv_Abs3_Vel := LREAL#30.0;

Mv_Abs3_Acc := LREAL#1000.0;

Mv_Abs3_Dec := LREAL#1000.0;

Mv_Abs3_Dir :=_eMC_DIRECTION#_mcNoDirection;

Mv_Abs3_Bm :=_eMC_BUFFER_MODE#_mcBuffered;

// MV_ZERO parameters Mv_Zero_Vel := LREAL#250;

Mv_Zero_Acc := LREAL#1000.0;

Mv_Zero_Dec := LREAL#1000.0;

Mv_Zero_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.

IF Hm_D=TRUE THEN Mv_Abs1_Ex:=TRUE;

// 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_ZERO is executed with multi-execution of instructio ns.

IF Mv_Abs3_Act=TRUE THEN Mv_Zero_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 );

// MC_MoveAbsolute MV_ABS1(

Axis := MC_Axis000, Execute := Mv_Abs1_Ex, Position := Mv_Abs1_Pos, Velocity := Mv_Abs1_Vel, Acceleration := Mv_Abs1_Acc,

MC_MoveAbsolute

3

Sample Programming 1

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 );

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 );

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_MoveZeroPosition MV_ZERO(

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 );