Mastercam软件的后置处理文件及其设定方[1]txt___2005102119285237679
- 格式:doc
- 大小:102.50 KB
- 文档页数:27
Mastercam软件的后置处理文件及其设定方[1]txt___2005102119285237679.txt昨天是作废的支票;明天是尚未兑现的期票;只有今天才是现金,才能随时兑现一切。
人总爱欺骗自己,因为那比欺骗别人更容易。
Mastercam系统配置的是适应单一类型控制系统的通用后置处理,该后置处理提供了一种功能数据库模型,用户根据数控机床和数控系统的具体情况,可以对其数据库进行修改和编译,定制出适应某一数控机床的专用后置处理程序。
Mastercam系统后置处理文件的扩展名为PST,称为PST文件,它定义了切削加工参数、NC 程序格式、辅助工艺指令,设置了接口功能参数等,其结构由八个部分组成:1.注解程序每一列前有“#”符号表示该列为不影响程序执行的文字注解。
如:# mi2-Absolute, or Incremental positioning0=absolute1=incremental表示mi2定义编程时数值给定方式,若mi=0为绝对值编程,mi=1为增量值编程。
在这一部分里,定义了数控系统编程的所有准备功能G代码格式和辅助功能M代码格式。
2.程序纠错程序中可以插入文字提示来帮助纠错,并显示在屏幕上。
如:# Error messages (错误信息)psuberror # Arc output not allowed"ERROR-WRONG AXIS USED IN AXIS SUBSTITUTION", e如果展开图形卷成旋转轴时,轴替换出错,则在程序中会出现上面引号中的错误提示。
3.定义变量的数据类型、使用格式和常量赋值如规定G代码和M代码是不带小数点的两位整数,多轴加工中心的旋转轴的地址代码是A、B 和C,圆弧长度允许误差为0.002,系统允许误差为0.00005,进给速度最大值为10m/min等。
4.定义问题可以根据机床加工需要,插入一个问题给后置处理程序执行。
如定义NC程序的目录,定义启动和退出后置处理程序时的C-Hook程序名。
5.字符串列表字符串起始字母为s,可以依照数值选取字符串,字符串可以由两个或更多的字符来组成。
字符串sg17,表示指定XY加工平面,NC程序中出现的是G17,scc1表示刀具半径左补偿,NC程序中出现的是G41,字符串sccomp代表刀具半径补偿建立或取消。
6.自定义单节可以让使用者将一个或多个NC码作有组织的排列。
自定义单可以是公式、变量、特殊字符串等:pwcs # G54+ coordinate setting at toolchangeif mil >1, pwcs_g54表示用pwcs单节指代#G54+在换刀时坐标设定值,mil定义为工件坐标系(G54~G59)7.预先定义的单节使用者可按照数控程序规定的格式将一个或多个NC代码作有组织的排列,编排成一条程序段。
8.系统问答后置处理软件提出了五组问题,供使用者回答,可按照注解文字、赋值变量、字符串等内容,根据使用的机床、数控系统进行回答。
设计后置处理文件,一般是按照NC程序的结构模块来进行。
根据NC程序的功能,后置处理文件分成六个模块如下:1.文件头文件头部分设定程序名称和编号,此外,SINUMERIK 810D系统还必须指定NC程序存放路径,并按照以下格式输出:“%_N_(程序名及编号)_(路径)”。
NC程序可存放在主程序、子程序和工作程序目录下,扩展名分别为:MPF、SPF、WPD,一般放在工作程序目录下。
因此经修改的Pst文件格式为:Pheader # Start of file" %_N_", progname, "_WPD" (程序名、存放目录)2.程序起始在程序开始,要完成安全设定、刀具交换、工件坐标系的设定、刀具长度补偿、主轴转速控制、冷却液控制等,并可显示编程者、编程日期、时间等注解。
修改后的有刀具号Pst文件开头格式如下:# Start of file for non-zero tool number......pspindle (主轴转速计算)pcom_movbtl (移动设备)ptoolcomment (刀具参数注解)......pbld, n, *sgcode, *sgplane, "G40", "G80", *sgabsinc(快进、XY加工平面、取消刀补、取消固定循环、绝对方式编程)if mil <=one, pg92_rtrnz, pg92_rtrn, pg92_g92 (返回参考点)......pbld, n, *sgcode, *sgabsinc, pwcs, pfxout, pfyout, pfcout, *speed, *spindle, pgear, pcan1(快进至某位置、坐标系编置、主轴转速等)pbld, n, pfzout, *tlngno, scoolant, [ if stagetool=one, *next_tool](安全高度、刀长补偿、开冷却液)pcom_movea (加工过程)3.刀具交换刀具交换执行前,须完成返回参考点、主轴停止动作,然后换刀,接着完成刀具长度补偿、安全设定、主轴转速控制。
Pst文件中用自定义单节ptlchg指代换刀过程,编辑修改后的程序如下:Ptlchg # Tool change......ptoolcomment (新刀参数注解)comment (插入注解)if stagetool <> two, pbld, n, *t, e (判断、选刀)n, "M6" (换刀)pindex (输出地址)pbld, n, *sgcode, *sgabsinc, pwcs, pfxout, pfyout, pfcout, *speed, *spindle, pgear, pcan1(快进至某位置、坐标系偏置、主轴转速等)pbld, n, pfzout, *tlngno, "M7", [if stagetool=one, *next_tool](安全高度、刀长补偿号、开冷却液)pcom_movea (加工过程)4.加工过程这一过程是快速移动、直线插补、圆弧插补、刀具半径补偿等基本加工动作。
对于几乎所有系统,这些加工动作的程序指令基本相同。
只是注意SINUMERIK 810D系统的刀具长度补偿值由字母D后加两位数字调用,不需要G43/G44指令;而半径补偿值则由G41/G42调用,不需要再接地址代码。
用G40取消刀具长度和刀具半径补偿。
5.切削循环Mastercam软件提供了6种内定的孔加工固定循环方式:一般钻削(Drill/Cbore)、深孔啄钻(Peck Drill)、断屑钻(Chip Break)、右攻丝(Tap)、精镗孔(Bore#1)、粗镗孔(Bore #2),通过杂项选项(Misc #1/Misc #2)可设定左攻丝、背镗孔、盲孔镗孔、盲孔铰孔等循环,并采用G73~G89代码来表示。
如对于深孔钻削固定循环,Mastercam采用的格式为:G83 X_Y_Z_R_Q_F;而SINUMERIK 810D 系统用CYCLE83指代深孔钻削循环,其NC程序要求给出循环加工所有参数,输出格式为:CYCLE83(RTP,RFP,SDIS,DP,DPR,FDEP,FDPR,DAM,DTB,DTS,FRF,VARI)在pst文件中需按SINUMERIK 810D系统格式进行定义、修改和编写。
6.程序结尾程序结尾一般情况下是取消刀补、关冷却液、主轴停止、执行回参考点,程序停止等动作。
下面是修改后的pst程序结尾:Ptoolend_t #End of tool path, toolchange......pbld, n, sccomp, "M5", *scoolant, e (取消刀补、主轴停止、关冷却液)pbld, n, *sg74, "Z1=0. X1=0. Y1=0.", e (返回参考点)if mi2=one, pbld, n, *sg74, "X1=0.", "Y1=0.", protretinc, eelse, protretabs (程序结束)nigefego发帖: 63积分: 9于2003-03-08 00:14 [信息] [悄悄话] [引用] [搜索] [复制] [收藏] 第 2 楼--------------------------------------------------------------------------------例子中文说明:[转贴]# POST 名称 : wgkG54# 类型 : MILL# 机床名称 : GENERIC FANUC# 控制器名称 : GENERIC FANUC# 描述 : GENERIC FANUC 3 AXIS MILL POST# Associated Post : NONE# 车/铣复合 : NO# 4-axis/Axis subs. : NO# 五轴 : NO# 子程序支持 : NO# 自动换刀 : NO# 工作坐标系 : G54# Executable : MP 8.00#### 这个POST支持FANUC控制器普通三轴铣床的的G 代码输出,# 不支持自动换刀,有最大圆弧报警# 它来源于MP-EZ.PST# 是针对Mastercam Mill V8的特征而设计的### -------------------------------------------------------------------------- # 修改日志:# -------------------------------------------------------------------------- # Programmers Note:# CNC 05/01/00 - Initial post setup, jce# 2002-10-11 - 去掉自动换刀,xxx# 2002-10-12 - 增加中文注释,xxx# 2002-10-21 - 增加最大圆弧警告,xxx# 2002-11-05 - 修改坐标系为G54,xxx# -------------------------------------------------------------------------- # 特征:# -------------------------------------------------------------------------- ### 下列 Misc.(杂项) 必须使用整数:## mi2 - 绝对或增量坐标 at top level# 0 = 绝对# 1 = 增量## mi3 - 选择G28或G30来执行参考点回归.# 0 = G28, 1 = G30## Canned text:# 在轮廓点里插入"cantext".以允许/禁止下列Mastercam里许可的功能,# Entering cantext on a contour point from within Mastercam allows the# following functions to enable/disable.# Cantext 值:# 1 = Stop = 输出 "M00" 停止码# 2 = Ostop = 输出 "M01" 选择停止码# 3 = Bld on = 在 NC 单节打开单节删除码(\)# 4 = bLd off = 在 NC 单节关闭单节删除码(\)### 钻孔:# 在这个 POST 里支持所有的钻孔方法.## 附加注意事项:# 1) G54 calls are generated where the work offset entry of 0 = G54,# 1 = G55, etc.# 2) 由NCI变量"met_tool"决定是否使用米制## 3) 以增量方式从换刀起始位置计算运动量.# 起始位置通常定义为所有换刀时刀具所处的最后位置# Incremental mode calculates motion from home position at toolchanges.# The home position is used to define the last position of the tool# for all toolchanges.# 4) 变量 'absinc' 现已被预先定义, 设定 mi2 (杂项整数)以定义# 绝对/增量程序输出.## -------------------------------------------------------------------------- # Debugging and Factory Set Program Switches 调试和加工设置程序切换# -------------------------------------------------------------------------- m_one : -1 #定义常数zero : 0 #定义常数one : 1 #定义常数two : 2 #定义常数three : 3 #定义常数four : 4 #定义常数five : 5 #定义常数c9k : 9999 #定义常数fastmode : 1 #Posting 速度最佳化bug1 : 2 #0=不显示, 1=普通列表框, 2=编辑器bug2 : -30 #Append postline labels, non-zero is column position?bug3 : 0 #Append whatline no. to each NC line?bug4 : 1 #Append NCI line no. to each NC line?whatno : yes #不执行 whatline branches(分枝)? (leave as yes)get_1004 : 1 #Find gcode 1004 with getnextop?rpd_typ_v7 : 0 #Use Version 7 style contour flags/processing?strtool_v7 : 2 #Use Version 7+ toolname?tlchng_aft : 2 #Delay call to toolchange until move linecant_tlchng : 1 #忽视 cantext 入口 on move with tlchng_aftnewglobal : 1 #全局变量错误检测getnextop : 0 #建立下一个变量表# -------------------------------------------------------------------------- # 一般输出设置# -------------------------------------------------------------------------- sub_level : 1 #允许自动子程序支持breakarcs : no #在各象限分割圆弧arcoutput : 0 #0= IJK,1= R不带符号,2= R (超过180度时带负号)arctype : 2 #圆弧中心 1=abs, 2=St-Ctr, 3=Ctr-St, 4=unsigned inc.arccheck : 1 #检测小圆弧,转化为直线atol : .01 #arccheck=2时的角度公差ltol : .002 #arccheck=1时的长度公差vtol : .0001 #系统公差maxfeedpm : 500 #进给速度极限 (英寸/分钟)ltol_m : .05 #arccheck=1时的长度公差,米制vtol_m : .0025 #系统公差,米制maxfeedpm_m : 10000 #进给速度极限毫米/分钟force_wcs : yes #每次换刀时强制输出WCSspaces : 1 #各指令之间插入的空格数omitseq : no #省略序号seqmax : 9999 #最大序号stagetool : 0 #0 = 无预先备刀, 1 = 预备刀具use_gear : 0 #输出齿轮交换代码,0=no,1=yesmax_speed : 6000 #最大主轴转速min_speed : 1 #最小主轴转速nobrk : no #Omit breakup of x, y & z rapid movesprogname : 1 #使用大写字母表示程序名max_arc : 50000 #机床允许的最大圆弧半径# --------------------------------------------------------------------------# 旋转轴设定# -------------------------------------------------------------------------- vmc : 1 # 0 = 卧式, 1 = 立式# -------------------------------------------------------------------------- # 允许钻孔固定循环功能# -------------------------------------------------------------------------- usecandrill : yes #使用普通钻孔固定循环usecanpeck : yes #使用啄式钻孔固定循环usecanchip : yes #使用断屑钻孔固定循环usecantap : yes #使用攻螺纹固定循环usecanbore1 : yes #使用镗孔固定循环1usecanbore2 : yes #使用镗孔固定循环2usecanmisc1 : yes #使用杂项固定循环1usecanmisc2 : yes #使用杂项固定循环2# -------------------------------------------------------------------------- # 通用自定义变量初始化(不能改变!)# -------------------------------------------------------------------------- xia : 0 #Formated absolute value for X incremental calculationsyia : 0 #Formated absolute value for Y incremental calculationszia : 0 #Formated absolute value for Z incremental calculationsbld : 0 #单节删除激活result : 0 #Return value for functionssav_spc : 0 #Save spacessav_gcode : 0 #Gcode savedsav_absinc : 0 #Absolute/Incremental Saved Valuesav_coolant : 0 #Coolant savedtoolchng : 1 #On a toolchange flagspdir2 : 1 #Copy for safe spindle direction calculation#Drill variablesdrlgsel : -1 #Drill Select Initializedrillref : 0 #Select drill referencepeckacel : 0 #Fractional percent to reduce peck2 when usecan.. : nodrlgcode : 0 #Save Gcode in drillsav_dgcode : 0 #Drill gcode saved# -------------------------------------------------------------------------- # 格式列表 - n=nonmodal, l=leading, t=trailing, i=inc, d=delta## --------------------------------------------------------------------------#定义英制/米制坐标格式列表fs2 1 0.7 0.6 #小数, absolute, 7 place, default for initialize (fs2 2 0.4 l1.3 #小数, absolute, 4/3 place (x,y,z)fs2 3 0.4 l1.3d #小数, delta, 4/3 place (i,j,k)#Common format statementsfs2 4 1 0 1 0 #整数, 无前缀fs2 5 2 0 2 0l #整数, 强制两位前缀fs2 6 3 0 3 0l #整数, 强制三位前缀fs2 7 4 0 4 0l #整数, 强制四位前缀fs2 9 0.1 0.1 #小数, absolute, 1 placefs2 10 0.2 0.2 #小数, absolute, 2 placefs2 11 0.3 0.3 #小数, absolute, 3 placefs2 12 0.4 0.4 #小数, absolute, 4 placefs2 13 0.5 0.5 #小数, absolute, 5 placefs2 14 0.3 0.3d #小数, delta, 3 placefs2 15 0.2 0.1 #小数, absolute, 2/1 placefs2 16 1 0 1 0n #整数, 强制输出# 输出加工类型字符串定义# -------------------------------------------------------------------------- # 字符串 - 字符串标签必须由 's' 开头,它们没有预先指派# -------------------------------------------------------------------------- #Select operation notesop00 "NULL" # String definitionsop01 "CONTOUR" # " "sop02 "CONTOUR" # " "sop03 "DRILL CYCLE" # " "sop04 "POCKET...." # " "sop05 "RULED....." # " "sop06 "2D-SWEPT.." # " "sop07 "3D-SWEPT.." # " "sop08 "REVOLVED.." # " "sop09 "LOFT......" # " "sop10 "COONS....." # " "sop11 "TRIM ....." # " "sop12 "FLOWLINE.." # " "sop13 "SURFACE_FINISH" # " "sop14 "SURFACE_ROUGH" # " "sop15 "POINT....." # " "sop16 "DRILL-5AX."sop17 "CURVE-5AX."sop18 "SWARF-5AX."sop19 "flat MILL"sop20 "op20?....."sopnote # Target stringfstrsel sop00 opcode sopnote# -------------------------------------------------------------------------- # NC 输出的字符串和字符串选择定义# --------------------------------------------------------------------------#Address string definitions 位址串定义strm "M"strn "N"stro "O"strp "P"srad "R"srminus "R-"sblank#Cantext 字符串定义 (spaces must be padded here)sm00 "M00"sm01 "M01"strtextnostrcantext# -------------------------------------------------------------------------- # 错误信息# -------------------------------------------------------------------------- saxiswarn " WARNING-THE RAD OF ARC IS TOO LARGE"# -------------------------------------------------------------------------- # 一般的 G 和 M 代码串选择表 General G and M Code String select tables# -------------------------------------------------------------------------- # 运动 G 代码选择sg00 G00 #快速定位sg01 G01 #直线进给sg02 G02 #圆弧插补 CWsg03 G03 #圆弧插补 CCWsg04 G04 #暂停sgcode #Target for stringfstrsel sg00 gcode sgcode# -------------------------------------------------------------------------- # 选择工作平面 G 字串sg17 G17 #XY 平面代码sg19 G19 #YZ 平面代码sg18 G18 #XZ 平面代码sgplane #Target stringfstrsel sg17 plane sgplane# -------------------------------------------------------------------------- #选择英制/米制字串sg20 G20 #英制代码sg21 G21 #米制代码smetric #Target stringfstrsel sg20 met_tool smetric# -------------------------------------------------------------------------- #选择参考点回归字串sg28 G28 #第一参考点回归sg30 G30 #第二参考点回归sg28ref #Target stringfstrsel sg28 mi3 sg28ref# -------------------------------------------------------------------------- # 切削补偿 G 字串选择scc0 G40 #切削补偿取消scc1 G41 #切削左补偿scc2 G42 #切削右补偿sccomp #Target for stringfstrsel scc0 cc_pos sccomp# -------------------------------------------------------------------------- # 钻孔固定循环字符串选择sg81 G81 #钻孔 - 无暂停sg81d G82 #钻孔 - 有暂停sg83 G83 #啄式钻孔 - 无暂停sg83d G83 #啄式钻孔 - 有暂停sg73 G73 #断屑 - 无暂停sg73d G73 #断屑 - 有暂停sg84 G84 #攻螺纹 - 右手sg84d G74 #攻螺纹 - 左手sg85 G85 #镗孔 #1 - 无暂停sg85d G89 #镗孔 #1 - 有暂停sg86 G86 #镗孔 #2 - 无暂停sg86d G86 #镗孔 #2 - 有暂停sgm1 G76 #misc #1 - 无暂停sgm1d G76 #misc #1 - 有暂停sgm2 G81 #misc #2 - 无暂停sgm2d G82 #misc #2 - 有暂停sgdrill #Target for stringfstrsel sg81 drlgsel sgdrill# -------------------------------------------------------------------------- # 选择增量或绝对 G字符串sg90 G90 #绝对代码sg91 G91 #增量代码sgabsinc #Target stringfstrsel sg90 absinc sgabsinc# -------------------------------------------------------------------------- #钻孔固定循环参考高度sg98 G98 #Z轴回到起始高度sg99 G99 #Z轴回到参考高度sgdrlref #Target for stringfstrsel sg98 drillref sgdrlref # Drill cycle G string select# -------------------------------------------------------------------------- # Generate string for spindlesm04 M04 #主轴反转sm05 M05 #主轴停止sm03 M03 #主轴正转spindle #Target for stringfstrsel sm04 spdir2 spindle# -------------------------------------------------------------------------- # 冷却 M 字符串选择sm09 M09 #冷却液 Offsm08 M08 #冷却液喷射sm08_1 M08 #冷却液喷雾sm08_2 M08 #Coolant Toolscoolant #Target for stringfstrsel sm09 coolant scoolant# -------------------------------------------------------------------------- # 定义齿轮选择代码flktbl 1 3 #Lookup table definition - table no. - no. entries40 0 #底速齿轮档41 400 #中速齿轮档42 2250 #高速齿轮档# --------------------------------------------------------------------------# 刀具交换 / NC输出变量格式# -------------------------------------------------------------------------- fmt T 4 t #刀具号fmt T 4 first_tool #第一把使用的刀具fmt T 4 next_tool #下一把使用的刀具fmt D 4 tloffno #直径偏移号fmt H 4 tlngno #长度偏移号fmt G 4 g_wcs #WCS G addressfmt P 4 p_wcs #WCS P addressfmt S 4 speed #主轴转速fmt M 4 gear #Gear range# -------------------------------------------------------------------------- fmt N 4 n #序号fmt X 2 xabs #X 坐标输出fmt Y 2 yabs #Y 坐标输出fmt Z 2 zabs #Z 坐标输出fmt X 3 xinc #X 坐标输出fmt Y 3 yinc #Y 坐标输出fmt Z 3 zinc #Z 坐标输出fmt I 3 i #x 轴方向上的圆弧中心描述fmt J 3 j #y 轴方向上的圆弧中心描述fmt K 3 k #z 轴方向上的圆弧中心描述fmt R 2 arcrad #圆弧半径fmt F 15 feed #进给率fmt P 11 dwell #暂停fmt M 5 cantext #Canned text# -------------------------------------------------------------------------- #Move comment (pound) to output colon with program numbersfmt O 7 progno #Program number#fmt ":" 7 progno #Program number# -------------------------------------------------------------------------- fmt Q 2 peck1 #First peck increment (positive)fmt Q 2 shftdrl #Fine bore tool shiftfmt R 2 refht_a #Reference heightfmt R 2 refht_i #Reference height# -------------------------------------------------------------------------- fmt "TOOL:" 4 tnote # 注释格式fmt " DIA. OFF:" 4 toffnote # 注释格式fmt " LEN.:" 4 tlngnote # 注释格式fmt " DIA.:" 1 tldia # 注释格式# -------------------------------------------------------------------------- # Tool Comment / Manual Entry Section 刀具注释/手工输入部分# --------------------------------------------------------------------------ptoolcomment #Comment for tooltnote = ttoffnote = tloffnotlngnote = tlngno"(", *tnote, *tldia, *sopnote, ")", epstrtool #Comment for toolif strtool <> sblank,[strtool = ucase(strtool)*strtool, " "]pcomment #Comment from manual entry (must call pcomment2 if booleans)pcomment2pcomment2 #Comment from manual entryscomm = ucase (scomm)if gcode = 1007, "(", scomm, ")"else, "(", scomm, ")", e# --------------------------------------------------------------------------# 文件起始和刀具交换设置# -------------------------------------------------------------------------- psof0 #Start of file for tool zeropsofpsof #Start of file for non-zero tool numbertoolchng = oneif ntools = one,[#skip single tool outputs, stagetool must be onstagetool = m_one!next_tool]"%", e*progno, e"(PROGRAM NAME - ", progname, ")", e"(DATE=Day-Month-Year - ", date, " TIME=Hr:Min - ", time, ")", eptoolcommentpbld, n, *sgcode, *sgplane, "G40", "G49", "G80", "G54", *sgabsinc, *smetric, esav_absinc = absincpcom_movebabsinc = zeropcan1, pbld, n, *sgcode, *sgabsinc, pwcs, pfxout, pfyout, *zr, *speed, *spindle, pgear, strcantext, epe_inc_calcps_inc_calcabsinc = sav_absincpbld, n, sgabsinc, epretract #刀具路径末尾,换刀sav_absinc = absincabsinc = onesav_coolant = coolantcoolant = zero#cc_pos is reset in the toolchange herecc_pos = zerogcode = zeropbld, n, sccomp, *sm05, eabsinc = sav_absinccoolant = sav_coolantpeof0 #End of file for tool zeropeofpeof #End of file for non-zero toolpretractcomment#Remove pound character to output first tool with staged tools # #if stagetool = one, pbld, n, *first_tool, en, "M30", e"%", epwcs #G54+ coordinate setting at toolchangeif workofs <> prv_workofs | (force_wcs & toolchng),[if workofs < 6,[g_wcs = workofs + 54*g_wcs]else,[p_wcs = workofs - five"G54.1", *p_wcs]]!workofspgear #Find spindle gear from lookup tableif use_gear = one,[gear = frange (one, speed)*gear]#换刀设置pspindle #主轴转速计算 for RPMspeed = abs(ss)if maxss = zero | maxss > max_speed, maxss = max_speed if speed > max_speed, speed = maxssif speed < min_speed, speed = min_speedspdir2 = fsg3(spdir)pq #Setup post based on switch settingsif stagetool = one, bldnxtool = oneif arctype = one | arctype = four,[result = newfs(two, i)result = newfs(two, j)result = newfs(two, k)]else,[result = newfs(three, i)result = newfs(three, j)result = newfs(three, k)]pheader #文件开始前调用if met_tool = one, #米制常量和变量调整[ltol = ltol_mvtol = vtol_mmaxfeedpm = maxfeedpm_m]ptoolend #刀具路径末尾,读取新刀具资料之前!speed, !spdir2ptlchg1002 #Call at actual toolchange, end last path herepspindleif gcode = 1000,[#Null toolchange]else,[#Toolchange and Start of fileif gcode = 1002,[#Actual toolchangepretract]if stagetool = one, prv_next_tool = m_oneprv_xia = vequ(xh)prv_feed = c9k]# -------------------------------------------------------------------------- # Motion NC output 运动 NC 输出# -------------------------------------------------------------------------- #绝对方式输出的变量为 xabs, yabs, zabs.#增量方式输出的变量为 xinc, yinc, zinc.# -------------------------------------------------------------------------- prapidout #输出直线运动的NC指令 - 快速pcan1, pbld, n, sgplane, `sgcode, sgabsinc, pccdia,pxout, pyout, pzout, strcantext, scoolant, eplinout #输出直线运动的NC指令 - 进给pcan1, pbld, n, sgplane, `sgcode, sgabsinc, pccdia,pxout, pyout, pzout, feed, strcantext, scoolant, epcirout #输出圆弧插补的NC指令if arcrad >= max_arc, result = mprint(saxiswarn)pcan1, pbld, n, sgplane, sgcode, sgabsinc, pccdia,pxout, pyout, pzout, parc, feed, strcantext, scoolant, epcom_moveb #Common motion preparation routines, beforepxyzcoutps_inc_calcpncoutput #Movement outputpcom_movebcommentpcanif gcode = zero, prapidoutif gcode = one, plinoutif gcode > one & gcode < four, pciroutpcom_moveapcom_movea #Common motion preparation routines, afterpcan2pe_inc_calcpdwl_spd #Call from NCI gcode 4pspindlecommentif prv_spdir2 <> spdir2, pbld, n, *sm05, eif prv_speed <> speed | prv_spdir2 <> spdir2,pbld, n, *speed, *spindle, pgear, epcanif fmtrnd(dwell), pcan1, pbld, n, *sgcode, *dwell, strcantext, e else, pcan1, pbld, n, strcantext, epcan2prapid #输出直线运动的NC指令 - 快速pncoutputpzrapid #输出直线运动的NC指令 - 快速 Z onlypncoutputplin #输出直线运动的NC指令 - 进给pncoutputpz #输出直线运动的NC指令 - 进给 Z onlypncoutputpmx #输出NCI向量的NC指令pncoutputpcir #输出圆弧插补的NC指令pncoutput# -------------------------------------------------------------------------- # Motion output components 运动输出组成# -------------------------------------------------------------------------- pbld #Canned text - 单节删除if bld, '/'pfbld #强制 - 单节删除"/"pccdia #切削补偿#Force Dxx#if prv_cc_pos <> cc_pos & cc_pos, prv_tloffno = c9ksccompif cc_pos, tloffnopfxout #Force X axis outputif absinc = zero, *xabs, !xincelse, *xinc, !xabspxout #X outputif absinc = zero, xabs, !xincelse, xinc, !xabspfyout #Force Y axis outputif absinc = zero, *yabs, !yincelse, *yinc, !yabspyout #Y outputif absinc = zero, yabs, !yincelse, yinc, !yabspfzout #Force Z axis outputif absinc = zero, *zabs, !zincelse, *zinc, !zabspzout #Z outputif absinc = zero, zabs, !zincelse, zinc, !zabsparc #选择圆弧输出格式if arcoutput = zero,[#圆弧输出为 IJKi, j, k]else,[#圆弧输出为 Rif abs(sweep)<=180 | arcoutput=one, result = nwadrs(srad, arcrad)else, result = nwadrs(srminus, arcrad)*arcrad]# -------------------------------------------------------------------------- # Drilling 钻孔# -------------------------------------------------------------------------- pdrlcommonb #Canned Drill Cycle common call, beforeif gcode = 81,[result = newfs (two, zinc)if drillcyc = three, drlgsel = fsg1(-ss) + drillcyc * twoelse, drlgsel = fsg2(dwell) + drillcyc * twoif initht <> refht, drillref = zeroelse, drillref = oneprv_refht_a = c9kprv_refht_i = c9k]z = depthprv_zia = inithtfeed = fr_posprv_dwell = zero@dwellpcom_movebcommentpcanprdrlout #R drill positionrefht_a = refhtrefht_i = refht - inithtif absinc = zero, refht_a, !refht_ielse, refht_i, !refht_apdrill #钻孔固定循环pdrlcommonbpcan1, pbld, n, *sgdrlref, *sgdrill, pxout, pyout, pfzout, prdrlout, dwell, *feed, strcantext, epcom_moveappeck #啄式钻孔固定循环pdrlcommonbpcan1, pbld, n, *sgdrlref, *sgdrill, pxout, pyout, pfzout, prdrlout, *peck1, *feed, strcantext, epcom_moveapchpbrk #断屑固定循环pdrlcommonbpcan1, pbld, n, *sgdrlref, *sgdrill, pxout, pyout, pfzout, prdrlout, *peck1, *feed, strcantext, epcom_moveaptap #攻螺纹固定循环pdrlcommonbpcan1, pbld, n, *sgdrlref, *sgdrill, pxout, pyout, pfzout, prdrlout, *feed, strcantext, epcom_moveapbore1 #镗孔固定循环 #1pdrlcommonbpcan1, pbld, n, *sgdrlref, *sgdrill, pxout, pyout, pfzout, prdrlout, dwell, *feed, strcantext, epcom_moveapbore2 #镗孔固定循环 #2pdrlcommonbpcan1, pbld, n, *sgdrlref, *sgdrill, pxout, pyout, pfzout, prdrlout, *feed, strcantext, epcom_moveapmisc1 #Canned Misc #1 Cyclepdrlcommonbpcan1, pbld, n, *sgdrlref, *sgdrill, pxout, pyout, pfzout, prdrlout, shftdrl, dwell, *feed, strcantext, epcom_moveapmisc2 #Canned Misc #2 Cycle (User Option)pdrillpdrill_2 #Canned Drill Cycle, additional pointspdrlcommonbpcan1, pbld, n, pxout, pyout, pzout, prdrlout, dwell,feed, strcantext, epcom_moveappeck_2 #Canned Peck Drill Cyclepdrill_2pchpbrk_2 #Canned Chip Break Cyclepdrill_2ptap_2 #Canned Tap Cyclepdrill_2pbore1_2 #Canned Bore #1 Cyclepdrill_2pbore2_2 #Canned Bore #2 Cyclepdrill_2pmisc1_2 #Canned Misc #1 Cyclepdrill_2pmisc2_2 #Canned Misc #2 Cyclepdrill_2pdrlcst #自定义钻孔循环 8 - 19 (user option)#Use this postblock to customize drilling cycles 8 - 19pdrlcommonb"CUSTOMIZABLE DRILL CYCLE ", pfxout, pfyout, pfzout, epcom_moveapdrlcst_2 #自定义钻孔循环 8 - 19, additional points (user option) #Use this postblock to customize drilling cycles 8 - 19pdrlcommonb"CUSTOMIZABLE DRILL CYCLE ", pfxout, pfyout, pfzout, epcom_moveapcanceldc #Cancel canned drill cycleresult = newfs (three, zinc)z = inithtprv_zia = inithtpxyzcout!zabs, !zincprv_gcode = zeropbld, n, "G80", e# -------------------------------------------------------------------------- # Canned Text# -------------------------------------------------------------------------- pcan #Canned text - before output callstrcantext = sblankif cant_no > zero,[if cant_pos1 = zero, pcant_1if cant_pos2 = zero, pcant_2if cant_pos3 = zero, pcant_3if cant_pos4 = zero, pcant_4if cant_pos5 = zero, pcant_5if cant_pos6 = zero, pcant_6if cant_pos7 = zero, pcant_7if cant_pos8 = zero, pcant_8if cant_pos9 = zero, pcant_9if cant_pos10 = zero, pcant_10pbld, n, strcantext, estrcantext = sblank]pcan1 #Canned text - with movestrcantext = sblankif cant_no > zero,[if cant_pos1 = one, pcant_1if cant_pos2 = one, pcant_2if cant_pos3 = one, pcant_3if cant_pos4 = one, pcant_4if cant_pos5 = one, pcant_5if cant_pos6 = one, pcant_6if cant_pos7 = one, pcant_7if cant_pos8 = one, pcant_8if cant_pos9 = one, pcant_9if cant_pos10 = one, pcant_10]if cstop, strcantext = strcantext + sm00if cgstop, strcantext = strcantext + sm01#Output of strcantext occurs at the end of the output linepcan2 #Canned text - after output callstrcantext = sblankif cant_no > zero,[if cant_pos1 = two, pcant_1 if cant_pos2 = two, pcant_2 if cant_pos3 = two, pcant_3 if cant_pos4 = two, pcant_4 if cant_pos5 = two, pcant_5 if cant_pos6 = two, pcant_6 if cant_pos7 = two, pcant_7 if cant_pos8 = two, pcant_8 if cant_pos9 = two, pcant_9 if cant_pos10 = two, pcant_10 pbld, n, strcantext, estrcantext = sblank]pcant_1 #Canned text - output callcantext = cant_val1pcant_outpcant_2 #Canned text - output callcantext = cant_val2pcant_outpcant_3 #Canned text - output callcantext = cant_val3pcant_outpcant_4 #Canned text - output callcantext = cant_val4pcant_outpcant_5 #Canned text - output callcantext = cant_val5pcant_outpcant_6 #Canned text - output callcantext = cant_val6pcant_outpcant_7 #Canned text - output callcantext = cant_val7pcant_out。