840D常用编程实例.docx
《840D常用编程实例.docx》由会员分享,可在线阅读,更多相关《840D常用编程实例.docx(28页珍藏版)》请在冰豆网上搜索。
840D常用编程实例
精品文档
使用Φ200铣刀加工900×2000平面
XPM
N05G00G17G54G90Z200
N75G00Z100
N10X-110Y90
N80X-110Y90
N15M3S150F500
AAA:
Z0
/N20GOTOFAAA
N85G01X2000
N25Z4
N90Y270
N30G01X2000
N95X0
N35Y270
N100Y450
N40X0
N105X2000
N45Y450
N110Y630
N50X2000
N115X0
N55Y630
N120Y810
N60X0
N125X2000
N65Y810
N130G00Z100M05
N70X2000
N135M02
.
精品文档
图17
利用无限循环,使用Φ200铣刀加工900×2000平面XPM1
N05G00G17G54G90Z200
N10X-110Y90
N15M3S150F500
N20Z4
N25AAA:
G01X2000
N30Y=IC(180)
N35X0
N40Y=IC(180)
N45GOTOBAAA
N50M02
.
精品文档
图18
(2)条件转向
条件语句形式为:
“IF条件表达式GOTOB/GOTOF跳转标记名”。
当条件满足,程序将会跳转到指定的目标。
条件表达式所用的条件
运算符包括:
==(等于)、<>(不等于)、>(大于)、>=(大于等于)、<(小于)、<=(小于等于)、AND与、OR或、NOT非、XOR异或。
2
例如:
使用变量编程加工抛物线Y=0.5X
图19
PWX
R1=10
G00G54G90Z100
X10Y50
.
精品文档
M3S1000F200
Z0
AA:
R1=R1-0.1
G01X=R1Y=POT(R1)/2
IFR1>-10GOTOBAA
G00Z100M5
M02
左下角为:
X0、Y0
N05T1
N25R1=35
上面为:
Z0
N10G00G54G90Z200
N30XK1
Φ20铣刀加工
N15M03S2000F500
N35TRANS
螺旋铣孔
;1
;2
XK
N20TRANSX100Y100
N40TRANSX100Y900
.
精品文档
N45R1=35
TRANSX1400Y100
Z5
N50XK1
N100R1=25
G01G41X19D1
N55TRANS
N105XK1
Z0
;3
N110TRANS
G03X19Y0Z-20I-19J0TURN=9
N60TRANSX750Y900
;6
G03I-19
N65R1=30
TRANSX1400Y900
G01G40X0
N120R1=25
G00Z5
N125XK1
G01G41X=R1D1
N65XK1
N130TRANS
Z0
N70TRANS
G00Z200M05
G03X=R1Y0Z-20I=-R1J0TURN=9
;4
M02
G03I=-R1
N75TRANSX750Y100
G01G40X0
N80R1=30
G00Z200
N85XK1
子程序
M17
N90TRANS
XK1
;5
X0Y0
ZK(钻孔)
N05G00G54G90Z100
N10X0Y0
N15M03S500F100
N20MCALLCYCLE83(100,0,5,-55,,-8,,2,,,1)
N25HOLES2(0,0,300,100,10,35)
N30MCALL
N35G00Z100M05
M02
.
精品文档
GS(攻丝)
N05G00G54G90Z100
N10X0Y0
N15M03S50F125
N20MCALLCYCLE840(100,0,5,-55,,,4,3,1)
N25HOLES2(0,0,300,100,10,35)
N30MCALL
N35G00Z100M05
M02
椭圆参数方程:
X=30×COS(Θ)Y=20×SIN(Θ)
程序如下
O0001
R1=0
N005G00G54G90Z100
N010X60Y0
N015M03S600F500
N020Z-5
N025G42X45Y-15
N030G02X30Y0CR=15
AA:
R1=R1+1
N035G01X=30*COS(R1)Y=20*SIN(R1)
N040IFR1<360GOTOBAA
.
精品文档
N045G02X45Y15CR=15
N050G00G40X60Y0
N055Z200M05
M30
G54X0Y0孔中心,Z0上表面。
N30X=17-COS(R4)*6
R4:
角度变量(0°~90°)
N35G02I=COS(R4)*6-17
X=17-COS(R4)*6
N40IFR4<90GOTOBAA
Z=6*(SIN(R4)-1)
N45G00Z100M05
N50M02
程序
DYJ(倒圆角)
N05R4=0
N10G00G54G90Z100
N15X0Y0
N20Z3M03S4000F1000
AA:
R4=R4+2
N25G01Z=6*(SIN(R4)-1)程序(使用变量)
.
精品文档
DYJ(倒圆角)
R1=倒角孔直径
R2=倒角圆半径
R3=刀半径
R4=角度变量
N05G00G54G90Z200
N10X0Y0
N15Z3M03S4000F2000
AA:
R4=R4+2
N20G01Z=(SIN(R4)-1)*(R2+R3)
N25X=R1/2+R2-COS(R4)*(R2+R3)
N30G02I=COS(R4)*(R2+R3)-R1/2-R2
N35IFR4<90GOTOBAA
N40G00Z100M05
M02
.
精品文档
XYZ
N05T1G17
N10R1=0.01R2=0
N15G00G54G90Z100
N20X40Y0
N25Z=R2
N30M3S2000F1000
AA:
G01G42X=R1D1
N35G03I-R1
N40R1=R1+0.5R2=R2-1
N45G40G01X=40Z=R2
N50IFR1<25GOTOBAA
N55G00Z100M5
M02
.
精品文档
设定;Φ20中心为X0、Y0。
25尺寸右端为Z0。
使用Φ20、R0.8平面铣刀加工。
程序:
AAA
N05T1
N10G00G54G90Z100BB:
R1=R1+0.5
N15X0Y0N65Z=-15-COS(R1)×10
N20M03S3000F500N70G01G41X=10+SIN(R1)×10D1
N25Z5N75Y0
N30G01G41X10Y0D1N80G02I=-10-SIN(R1)×10
N35Z0N85G01Y-5
N40G02X10Y0Z-15I-10J0TURN=14N90G40X40
N45I-10N95Y5
N50G01G40X40N100IFR1<90GOTOBBB
N55Y5N105G00Z100M05
N60R1=0M02
.
精品文档
SR
N05R1=10(圆半径)
N10R2=4(刀半径)
N15R3=30(坐标旋转)
N20R10=0(变量)
N25G00G19G54G90Z200
N30ROTZ=R3
N35X101Y=-R1-R2
N40M3S2000F1500
N45Z=R1+5
N50G01Z=-R2
II:
R10=R10-0.2N55G01X=101+R10
N60G02Y=R1+R2CR=R1+R2
N65R10=R10-0.2
N70G01X=101+R10
N75G03Y=-R1-R2CR=R1+R2
N80IFR10>=0GOTOBII
N85ROT
N90G00G17Z200M05
M02
.
精品文档
DYJ
N05T1
N10R1=30R2=2R3=4R4=0
N20G00G54G90Z200
N25X=R1+R3+3Y5
N30M03S3000F2000
N35Z2
AA:
R4=R4+1.5
N40$TC_DP6[1,1]=(R3+R2)×COS(R4)-R2
N45G01Z=(R2+R3)×(SIN(R4)-1)
N50G42X=R1D1
N55Y20
N60G03X20Y30CR=10
N65G01X0
N70Y0
N75X30
N80Y5
N85X=R1+$TC_DP6[1,1]
N90IFR4<=90GOTOBAA
N95G00Z200M05
M02
.
精品文档
QQQN55Y0
N05CFTCPN60G03X0Y34CR=34
N10R1=0N65X0Y26CR=4
N15G00G54G90G64Z100N70G02X-26Y0CR=-26
N20X60Y-60N75G03X-34CR=4
N25M03S3000F2000N80G03X34Y0CR=34
AB:
R1=R1+3N85G01G40X60
N30R2=SIN(R1)×6N90Y-60
N35R3=COS(R1)×6N95IFR1<90GOTOBAB
N40$TC_DP6[1,1]=(R2-2)N100G90G0Z150M05
N45G01Z=R3-6M30
N50G42X34D1
.