Mastercam软件的后置处理文件及其设定方法
一、前言
Mastercam是一套应广泛的CAD/CAM/CAE软件包,它采用图形义互
式自动编程方法实现NC程序的编制。义互式编程是一种人机对话的编程方法,编程人员根据屏幕提示的内容,反复与计算机对话,选择菜单目录或计算机的提问,将所有的问题回答完毕后即可以生生成NC程序。NC程序的自动产生是受软件的后置处理功能控制的,不同的加工模块(如车削、铣削、线切割等)和不同的数控系统对应于不同的后处理文件。软件当前使用哪一个后处理文件,是在软件安装时设定的,而在具体应用软件进行编程之前,一般还需要对当前的后处理文件进行必要的修改和设定,以使其符合系统要求和使用者的编程习惯。有些用户在使用软件时由于不了解情况,没有对后处理文件进行修改,导致生成的NC程序中某些固定的地方经常出现一些多余的内容,或者总是漏掉某些词句,这样,在将程序传入数控机床之前,就必须对程序进行手工修改,如果没有全部更正,则可能造成事故。例如,某机床的控制系统采用G54工件坐标系定位,G90绝对坐标编程,要求生成的NC程序前面必须有G54G90设置,如果后处理文件的设置为G55G91,则每次生成的程序中含有G55G91,却不一定有G54G90,如果在加工时没有进行手工改正,则势必造成加工错误。
二、Mastercam软件的后置处理文件
后置处理文件简称后处理文件,是一种可以由用户以回答问题的形式自行修改的文件,其扩展名为.PST。在应用Mastercam软件的自动编程功能之前,必须先对这个文件进行编辑,才能在执行后处理程序时产生符合某种控制器需要和使用者习惯的NC程序,也就是说后处理程序可以将一种控制器的NC程序定义成该控制器所使用的格式。以FANUC系列的后处理为例,它既可以定义成惯用于FANUC3M控器所使用的格式,也可以定义成FANUC6M控制器所使用的格式,但不能用来定义其它系列的控制器。
不同系列的后处理文件在内容上略有不同,但其格式及主体部分是相似的,一般都包括以下几个部分。
1.Annotation(注释)对后处理文件及其设定方法作一般性介绍。
2.问题该部分为后处理文件的主要部分,FANUC系列的后处理文件中共包括200个问题,对这些问题的回答将决定将来输出的NC程序的格式。
3.Commands(指令)指令的作用是对它后面的变量施加影响。如oldvars和newvars指令,在回答问题3时若写于刀具号码变量t之前,则使用oldvars时将呼叫前一把刀具的号码,使用newvars时将呼叫现在所使用的刀具号码。
4.Variables(变量)给出了"问题"中所使用的各种变量的定义.FANUC系列的后处理文件中共定义了26个变量,如prog-n=程序号码,f=进给率,s=主轴转速,t=刀具号码等。
三、后处理文件的设定方法
1.后处理文件编辑的一般规则
对后处理文件的编辑和设定只需要对第(4)部分的"问题"进行回答。PST文件的每个问题前都有一个号码并在号码后加一个小数点。若问题前没有号码,那么这个问题在执行后处理时是被忽略不用的。回答号码20以前的问题时,需要在问题的下一行键入所回答的文字,而且回答的内容可以包括多行,20号以后问题均带有问号且回答时直接写在问号的后面,不得换行,这一类的问题常常是以"y""n"来回答。回答问题时用到变量,不能用引号,而字符串则必须包围在引号之中(如"G91G28GZ0M05"),引号中的文字将按字符串的原样写入程序中。变量和字符之间要用逗号隔开。
2.变量的使用
变量的定义在后处理文件的开头部分已经作了说明,使用时可通过查阅来了解变量的意义。变量在回答问题时一经使用,就会在生产的NC程序中表达确定的意义。如变量spindle-on,转速为正或0时定义为M03,为负时定义为M04,如果回答问题时使用了该变量,则会在NC程序的相应部分写出M03或M04。变量prog-n若写到问题1或2中,将对在NC程序规划时给定的程序中起作用。变量First-tool 用来呼叫程序中所使用中的第一把刀的号码,此变量通常用于程序结束时将使用中的刀具改变为第一把刀
的号码,以便在下一次执行程序时使用。next-tool用于无T字首的刀具号码,使用这个变量可在刀具被呼叫前,选择另一把刀来进行换刀。变量xr、yr、zr是用来定义程序中快速定位的X、Y、Z坐标位置,通常用于换刀和程序结束时使刀具返回机械原点。prev-x、prev-y、prev-z则是用来定义刀具所在的前一个X、Y、Z坐标的位置。其它变量的定义可参看文件开头的说明。
3.后处理文件的设置方法
后处理文件中的大部分问题一般不需要作修改,使用时,通常办需对其中固定的某几个问题进行编辑。下面以FANUC系列的.PST文件为例,来说明设定的方法。
(1)问题0的回答要用字符串,对于FANUC控制系统设置为"%"。
(2)以问题2的回答以例说明2、4、5问题的回答方法。假设在设定NC参数时所给的程序名为test1,程序号为1234,顺序号开始号码为100且增量值为2,刀具号为01,主轴转速为1500/mim,则.PST文件格式及产生的NC程序对照台下。
.PST文件格式NC程序
prog_mane test1
prog_n 1234
N,"G90 G54 G49 G40" N100 G90 G54 G49 G40
N,"G00 X0 Y0" N102 G00 X0Y0
N,"M06" M104 M06 T01
N,S,spindle_on N106 s1500 M03
(3)问题6是用来设定当铣削状态改变面刀具号码并不改变时,其使用的变量与问题2、4、5中所使用的变量相同。
(4)问题7、8、9控制NC参数屏幕中Text1、2、3所设定的文字。
(5)问题36要求规定进给速度值小数点后允许的位数,若写-1时则为整数。
(6)问题37高定的比例因数可使写到NC程序中的进给速度按此因数变化。
(7)问题38中要求设置快速进给速率的大小。
(8)问题42是若设定为e(表示圆弧插补指令中用R程序)时,问题53必须回答"Y",则系统在后处理时将自动大于180·圆弧打断为两段。
(9)问题50~55是使用权控制器中的cannedcycles指令(G81~G89)被使用于NC程序中。
(10)问题70是用来设定几何图形中线与线或线与圆弧之间的精确度,使其值保证连接外形时能自动连接。
(11)问题81~89是用于NC程序与数控机床传输与接受时的对数设定。
(12)当使用者在换马中使用权用next_tool变量时,问题120应回答为"Y"。当后处理系统执行时,电脑首先必须做一个刀具表,否则电脑无法了解在换刀要用到次一把刀时,什么刀具要来到一把刀的位置。
(13)问题190~196是用于设定刀具路径显示时的内定值。
(14)问题201~510中的杂项变量是在线切割后处理系统中使用的。
四、结束语
后置处理文件的编辑和设定,对CAD/CAM软件来说都是需要的。但是一般的使用者经常忽略这一点,面是在每次生成NC程序后去对程序进行修改,不仅浪费时间,而且容易出错导致事故。本文对Mastercam软伯的后处理文件进行了分析和讨论,介绍了其编辑和设定的方法。
-------------------------------------------------------
# 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的特征而设计的
#
#
# 欢迎各位试用此后处理程序,提供意见反馈,
# 地址: 福建漳州新华北路56号力佳股份有限公司吴桂凯
# 电话: 0596-******* (19:00-23:30)
# E-MAIL: wwggkk@https://www.doczj.com/doc/267486792.html,
# wwggkk@https://www.doczj.com/doc/267486792.html,
# --------------------------------------------------------------------------
# 修改日志:
# --------------------------------------------------------------------------
# Programmers Note:
# CNC 05/01/00 - Initial post setup, jce
# 2002-10-11 - 去掉自动换刀,吴桂凯
# 2002-10-12 - 增加中文注释,吴桂凯
# 2002-10-21 - 增加最大圆弧警告,吴桂凯
# 2002-11-05 - 修改坐标系为G54,吴桂凯
# --------------------------------------------------------------------------
# 特征:
# --------------------------------------------------------------------------
#
#
# 下列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 line
cant_tlchng : 1 #忽视cantext 入口on move with tlchng_aft newglobal : 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 #每次换刀时强制输出WCS
spaces : 1 #各指令之间插入的空格数
omitseq : no #省略序号
seqmax : 9999 #最大序号
stagetool : 0 #0 = 无预先备刀, 1 = 预备刀具
use_gear : 0 #输出齿轮交换代码,0=no,1=yes
max_speed : 6000 #最大主轴转速
min_speed : 1 #最小主轴转速
nobrk : no #Omit breakup of x, y & z rapid moves
progname : 1 #使用大写字母表示程序名
max_arc : 50000 #机床允许的最大圆弧半径
# --------------------------------------------------------------------------
# 旋转轴设定
# --------------------------------------------------------------------------
vmc : 1 # 0 = 卧式,1 = 立式
# --------------------------------------------------------------------------
# 允许钻孔固定循环功能
# --------------------------------------------------------------------------
usecandrill : yes #使用普通钻孔固定循环
usecanpeck : yes #使用啄式钻孔固定循环
usecanchip : yes #使用断屑钻孔固定循环
usecantap : yes #使用攻螺纹固定循环
usecanbore1 : yes #使用镗孔固定循环1
usecanbore2 : yes #使用镗孔固定循环2
usecanmisc1 : yes #使用杂项固定循环1
usecanmisc2 : yes #使用杂项固定循环2
# --------------------------------------------------------------------------
# 通用自定义变量初始化(不能改变!)
# --------------------------------------------------------------------------
xia : 0 #Formated absolute value for X incremental calculations yia : 0 #Formated absolute value for Y incremental calculations zia : 0 #Formated absolute value for Z incremental calculations
bld : 0 #单节删除激活
result : 0 #Return value for functions
sav_spc : 0 #Save spaces
sav_gcode : 0 #Gcode saved
sav_absinc : 0 #Absolute/Incremental Saved Value
sav_coolant : 0 #Coolant saved
toolchng : 1 #On a toolchange flag
spdir2 : 1 #Copy for safe spindle direction calculation
#Drill variables
drlgsel : -1 #Drill Select Initialize
drillref : 0 #Select drill reference
peckacel : 0 #Fractional percent to reduce peck2 when usecan.. : no drlgcode : 0 #Save Gcode in drill
sav_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 statements
fs2 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 place
fs2 10 0.2 0.2 #小数, absolute, 2 place
fs2 11 0.3 0.3 #小数, absolute, 3 place
fs2 12 0.4 0.4 #小数, absolute, 4 place
fs2 13 0.5 0.5 #小数, absolute, 5 place
fs2 14 0.3 0.3d #小数, delta, 3 place
fs2 15 0.2 0.1 #小数, absolute, 2/1 place
fs2 16 1 0 1 0n #整数, 强制输出
# 输出加工类型字符串定义
# --------------------------------------------------------------------------
# 字符串- 字符串标签必须由's' 开头,它们没有预先指派
# --------------------------------------------------------------------------
#Select operation note
sop00 "NULL" # String definition
sop01 "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 string
fstrsel 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"
strtextno
strcantext
# --------------------------------------------------------------------------
# 错误信息
# --------------------------------------------------------------------------
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 #圆弧插补CW
sg03 G03 #圆弧插补CCW
sg04 G04 #暂停
sgcode #Target for string
fstrsel sg00 gcode sgcode
# -------------------------------------------------------------------------- # 选择工作平面G 字串
sg17 G17 #XY 平面代码
sg19 G19 #YZ 平面代码
sg18 G18 #XZ 平面代码
sgplane #Target string
fstrsel sg17 plane sgplane
# -------------------------------------------------------------------------- #选择英制/米制字串
sg20 G20 #英制代码
sg21 G21 #米制代码
smetric #Target string
fstrsel sg20 met_tool smetric
# -------------------------------------------------------------------------- #选择参考点回归字串
sg28 G28 #第一参考点回归
sg30 G30 #第二参考点回归
sg28ref #Target string
fstrsel sg28 mi3 sg28ref
# -------------------------------------------------------------------------- # 切削补偿G 字串选择
scc0 G40 #切削补偿取消
scc1 G41 #切削左补偿
scc2 G42 #切削右补偿
sccomp #Target for string
fstrsel 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 string
fstrsel sg81 drlgsel sgdrill
# --------------------------------------------------------------------------
# 选择增量或绝对G字符串
sg90 G90 #绝对代码
sg91 G91 #增量代码
sgabsinc #Target string
fstrsel sg90 absinc sgabsinc
# --------------------------------------------------------------------------
#钻孔固定循环参考高度
sg98 G98 #Z轴回到起始高度
sg99 G99 #Z轴回到参考高度
sgdrlref #Target for string
fstrsel sg98 drillref sgdrlref # Drill cycle G string select
# --------------------------------------------------------------------------
# Generate string for spindle
sm04 M04 #主轴反转
sm05 M05 #主轴停止
sm03 M03 #主轴正转
spindle #Target for string
fstrsel sm04 spdir2 spindle
# --------------------------------------------------------------------------
# 冷却M 字符串选择
sm09 M09 #冷却液Off
sm08 M08 #冷却液喷射
sm08_1 M08 #冷却液喷雾
sm08_2 M08 #Coolant Tool
scoolant #Target for string
fstrsel sm09 coolant scoolant
# --------------------------------------------------------------------------
# 定义齿轮选择代码
flktbl 1 3 #Lookup table definition - table no. - no. entries 40 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 address
fmt P 4 p_wcs #WCS P address
fmt 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 numbers fmt 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 shift
fmt R 2 refht_a #Reference height
fmt 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 tool
tnote = t
toffnote = tloffno
tlngnote = tlngno
"(", *tnote, *tldia, *sopnote, ")", e
pstrtool #Comment for tool
if strtool <> sblank,
[
strtool = ucase(strtool)
*strtool, " "
]
pcomment #Comment from manual entry (must call pcomment2 if booleans) pcomment2
pcomment2 #Comment from manual entry
scomm = ucase (scomm)
if gcode = 1007, "(", scomm, ")"
else, "(", scomm, ")", e
# --------------------------------------------------------------------------
# 文件起始和刀具交换设置
# --------------------------------------------------------------------------
psof0 #Start of file for tool zero
psof
psof #Start of file for non-zero tool number
toolchng = one
if ntools = one,
[
#skip single tool outputs, stagetool must be on
stagetool = m_one
!next_tool
]
"%", e
*progno, e
"(PROGRAM NAME - ", progname, ")", e
"(DATE=Day-Month-Year - ", date, " TIME=Hr:Min - ", time, ")", e
ptoolcomment
pbld, n, *sgcode, *sgplane, "G40", "G49", "G80", "G54", *sgabsinc, *smetric, e
sav_absinc = absinc
pcom_moveb
absinc = zero
pcan1, pbld, n, *sgcode, *sgabsinc, pwcs, pfxout, pfyout, *zr, *speed, *spindle, pgear, strcantext, e
pe_inc_calc
ps_inc_calc
absinc = sav_absinc
pbld, n, sgabsinc, e
pretract #刀具路径末尾,换刀
sav_absinc = absinc
absinc = one
sav_coolant = coolant
coolant = zero
#cc_pos is reset in the toolchange here
cc_pos = zero
gcode = zero
pbld, n, sccomp, *sm05, e
absinc = sav_absinc
coolant = sav_coolant
peof0 #End of file for tool zero
peof
peof #End of file for non-zero tool
pretract
comment
#Remove pound character to output first tool with staged tools # #if stagetool = one, pbld, n, *first_tool, e
n, "M30", e
"%", e
pwcs #G54+ coordinate setting at toolchange
if workofs <> prv_workofs | (force_wcs & toolchng),
[
if workofs < 6,
[
g_wcs = workofs + 54
*g_wcs
]
else,
[
p_wcs = workofs - five
"G54.1", *p_wcs
]
]
!workofs
pgear #Find spindle gear from lookup table
if use_gear = one,
[
gear = frange (one, speed)
*gear
]
#换刀设置
pspindle #主轴转速计算for RPM
speed = abs(ss)
if maxss = zero | maxss > max_speed, maxss = max_speed if speed > max_speed, speed = maxss
if speed < min_speed, speed = min_speed
spdir2 = fsg3(spdir)
pq #Setup post based on switch settings
if stagetool = one, bldnxtool = one
if 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_m
vtol = vtol_m
maxfeedpm = maxfeedpm_m
]
ptoolend #刀具路径末尾,读取新刀具资料之前
!speed, !spdir2
ptlchg1002 #Call at actual toolchange, end last path here pspindle
if gcode = 1000,
[
#Null toolchange
]
else,
[
#Toolchange and Start of file
if gcode = 1002,
[
#Actual toolchange
pretract
]
if stagetool = one, prv_next_tool = m_one
prv_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, e
plinout #输出直线运动的NC指令- 进给
pcan1, pbld, n, sgplane, `sgcode, sgabsinc, pccdia,
pxout, pyout, pzout, feed, strcantext, scoolant, e
pcirout #输出圆弧插补的NC指令
if arcrad >= max_arc, result = mprint(saxiswarn) pcan1, pbld, n, sgplane, sgcode, sgabsinc, pccdia,
pxout, pyout, pzout, parc, feed, strcantext, scoolant, e
pcom_moveb #Common motion preparation routines, before pxyzcout
ps_inc_calc
pncoutput #Movement output
pcom_moveb
comment
pcan
if gcode = zero, prapidout
if gcode = one, plinout
if gcode > one & gcode < four, pcirout
pcom_movea
pcom_movea #Common motion preparation routines, after pcan2
pe_inc_calc
pdwl_spd #Call from NCI gcode 4
pspindle
comment
if prv_spdir2 <> spdir2, pbld, n, *sm05, e
if prv_speed <> speed | prv_spdir2 <> spdir2,
pbld, n, *speed, *spindle, pgear, e
pcan
if fmtrnd(dwell), pcan1, pbld, n, *sgcode, *dwell, strcantext, e
else, pcan1, pbld, n, strcantext, e
pcan2
prapid #输出直线运动的NC指令- 快速
pncoutput
pzrapid #输出直线运动的NC指令- 快速Z only
pncoutput
plin #输出直线运动的NC指令- 进给
pncoutput
pz #输出直线运动的NC指令- 进给Z only
pncoutput
pmx #输出NCI向量的NC指令
pncoutput
pcir #输出圆弧插补的NC指令
pncoutput
# -------------------------------------------------------------------------- # Motion output components 运动输出组成
# -------------------------------------------------------------------------- pbld #Canned text - 单节删除
if bld, '/'
pfbld #强制- 单节删除
"/"
pccdia #切削补偿
#Force Dxx#
if prv_cc_pos <> cc_pos & cc_pos, prv_tloffno = c9k sccomp
if cc_pos, tloffno
pfxout #Force X axis output
if absinc = zero, *xabs, !xinc
else, *xinc, !xabs
pxout #X output
if absinc = zero, xabs, !xinc
else, xinc, !xabs
pfyout #Force Y axis output
if absinc = zero, *yabs, !yinc
else, *yinc, !yabs
pyout #Y output
if absinc = zero, yabs, !yinc
else, yinc, !yabs
pfzout #Force Z axis output
if absinc = zero, *zabs, !zinc
else, *zinc, !zabs
pzout #Z output
if absinc = zero, zabs, !zinc
else, zinc, !zabs
parc #选择圆弧输出格式
if arcoutput = zero,
[
#圆弧输出为IJK
i, j, k
]
else,
[
#圆弧输出为R
if abs(sweep)<=180 | arcoutput=one, result = nwadrs(srad, arcrad) else, result = nwadrs(srminus, arcrad)
*arcrad
]
# --------------------------------------------------------------------------
# Drilling 钻孔
# -------------------------------------------------------------------------- pdrlcommonb #Canned Drill Cycle common call, before
if gcode = 81,
[
result = newfs (two, zinc)
if drillcyc = three, drlgsel = fsg1(-ss) + drillcyc * two
else, drlgsel = fsg2(dwell) + drillcyc * two
if initht <> refht, drillref = zero
else, drillref = one
prv_refht_a = c9k
prv_refht_i = c9k
]
z = depth
prv_zia = initht
feed = fr_pos
prv_dwell = zero
@dwell
pcom_moveb
comment
pcan
prdrlout #R drill position
refht_a = refht
refht_i = refht - initht
if absinc = zero, refht_a, !refht_i
else, refht_i, !refht_a
pdrill #钻孔固定循环
pdrlcommonb
pcan1, pbld, n, *sgdrlref, *sgdrill, pxout, pyout, pfzout, prdrlout, dwell, *feed, strcantext, e
pcom_movea
ppeck #啄式钻孔固定循环
pdrlcommonb
pcan1, pbld, n, *sgdrlref, *sgdrill, pxout, pyout, pfzout, prdrlout, *peck1, *feed, strcantext, e
pcom_movea
pchpbrk #断屑固定循环
pdrlcommonb
pcan1, pbld, n, *sgdrlref, *sgdrill, pxout, pyout, pfzout, prdrlout, *peck1, *feed, strcantext, e
pcom_movea
ptap #攻螺纹固定循环
pdrlcommonb
pcan1, pbld, n, *sgdrlref, *sgdrill, pxout, pyout, pfzout, prdrlout, *feed, strcantext, e
pcom_movea
pbore1 #镗孔固定循环#1
pdrlcommonb
pcan1, pbld, n, *sgdrlref, *sgdrill, pxout, pyout, pfzout, prdrlout, dwell, *feed, strcantext, e
pcom_movea
pbore2 #镗孔固定循环#2
pdrlcommonb
pcan1, pbld, n, *sgdrlref, *sgdrill, pxout, pyout, pfzout, prdrlout, *feed, strcantext, e
pcom_movea
pmisc1 #Canned Misc #1 Cycle
pdrlcommonb
pcan1, pbld, n, *sgdrlref, *sgdrill, pxout, pyout, pfzout, prdrlout, shftdrl, dwell, *feed, strcantext, e
pcom_movea
pmisc2 #Canned Misc #2 Cycle (User Option)
pdrill
pdrill_2 #Canned Drill Cycle, additional points
pdrlcommonb
pcan1, pbld, n, pxout, pyout, pzout, prdrlout, dwell,
feed, strcantext, e
pcom_movea
ppeck_2 #Canned Peck Drill Cycle
pdrill_2
pchpbrk_2 #Canned Chip Break Cycle
pdrill_2
ptap_2 #Canned Tap Cycle
pdrill_2
pbore1_2 #Canned Bore #1 Cycle
pdrill_2
pbore2_2 #Canned Bore #2 Cycle
pdrill_2
pmisc1_2 #Canned Misc #1 Cycle
pdrill_2
pmisc2_2 #Canned Misc #2 Cycle
pdrill_2
pdrlcst #自定义钻孔循环8 - 19 (user option)
#Use this postblock to customize drilling cycles 8 - 19
pdrlcommonb
"CUSTOMIZABLE DRILL CYCLE ", pfxout, pfyout, pfzout, e
pcom_movea
pdrlcst_2 #自定义钻孔循环8 - 19, additional points (user option) #Use this postblock to customize drilling cycles 8 - 19
pdrlcommonb
"CUSTOMIZABLE DRILL CYCLE ", pfxout, pfyout, pfzout, e
pcom_movea
pcanceldc #Cancel canned drill cycle
result = newfs (three, zinc)