ERRSWITCH = 3
'全部信息输出
BASE(0,1,2,3)
'选择 X Y Z U,G01 里面有指定,不能随意修改
RAPIDSTOP(2)
WAIT IDLE
DPOS = 0,0,0,0
ATYPE=1,1,1,1
'脉冲方式步进或伺服
UNITS = 100,100,100,100
'脉冲当量,每 MM100 脉冲
SPEED = 200,200,200,200
ACCEL = 2000,2000,2000,2000
DECEL = 2000,2000,2000,2000
MERGE = ON
'启动连续插补
CORNER_MODE = 2
'启动拐角减速
DECEL_ANGLE = 15 * (PI/180)
STOP_ANGLE = 45 * (PI/180)
G_INIT()
'G 初始化
WHILE 1
'循环运动
IF IN(0) = ON THEN
'输入 0 有效启动运动
'走一个方框
G91 '相对位置
G01 X100 Y0
'运动轨迹
G01 X0 Y100
G01 X-100 Y0
G01 X0 Y-100
WAIT IDLE
'等待运动停止
DELAY(100)
'延时
ENDIF
WEND
END
'使得本文件自动运行时退出,避免重复执行后方的 SUB 文件
'相对位置模式
GLOBAL SUB G_INIT()
DIM coor_rel
coor_rel = 1
'相对位置模式
END SUB
GLOBAL GSUB G01(X Y Z U)
TRACE "G01 entered, distance:" sub_para(0),sub_para(1),sub_para(2),sub_para(3)'调试输出
IF coor_rel THEN
MOVE(sub_para(0),sub_para(1),sub_para(2),sub_para(3))
'相对位置
ELSE
LOCAL xdis, ydis, zdis, udis
IF sub_ifpara(0) THEN
'判断是否有参数传入 SUB
xdis = sub_para(0)
ELSE
xdis = ENDMOVE_BUFFER(0)
ENDIF
IF sub_ifpara(1) THEN
ydis = sub_para(1)
ELSE
ydis = ENDMOVE_BUFFER(1)
ENDIF
IF sub_ifpara(2) then
zdis = sub_para(2)
ELSE
zdis = ENDMOVE_BUFFER(2)
ENDIF
IF sub_ifpara(3) then
udis = sub_para(3)
ELSE
udis = ENDMOVE_BUFFER(3)
ENDIF
MOVEABS(xdis,ydis,zdis,udis)
'绝对位置
ENDIF
END SUB
'绝对位置模式
GLOBAL GSUB G90()
TRACE "G90 entered"
coor_rel = 0
END SUB
'相对
GLOBAL GSUB G91()
TRACE "G91 entered"
coor_rel = 1
END SUB
'延时
GLOBAL GSUB G04(P)
TRACE "G04 entered"
IF sub_ifpara(0) THEN
DELAY (sub_para(0))
ELSE
ENDIF
END SUB
GLOBAL GSUB G00(X Y Z U)
TRACE "G00 entered, distance:" sub_para(0),sub_para(1),sub_para(2),sub_para(3)'调试输出
IF coor_rel THEN
MOVE(sub_para(0),sub_para(1),sub_para(2),sub_para(3))
ELSE
LOCAL xdis, ydis, zdis, udis
IF sub_ifpara(0) THEN
xdis = sub_para(0)
ELSE
xdis = ENDMOVE_BUFFER(0)
ENDIF
IF sub_ifpara(1) then
ydis = sub_para(1)
ELSE
ydis = ENDMOVE_BUFFER(1)
ENDIF
IF sub_ifpara(2) THEN
zdis = sub_para(2)
ELSE
zdis = ENDMOVE_BUFFER(2)
ENDIF
IF sub_ifpara(3) THEN
udis = sub_para(3)
ELSE
udis = ENDMOVE_BUFFER(3)
ENDIF
MOVEABS(xdis,ydis,zdis,udis)
ENDIF
END SUB
楼主最近还看过