MasterCAM后处理文件的修改
MasterCAM系统缺省的后处理文件为MPFAN.PST,适用于FANUC(法兰克、发那科)数控代码的控制器。其它类型的控制器需选择对应的后处理文件。
由于实际使用需要,用缺省的后处理文件时,输出的NC文件不能直接用于加工T 蚴牵?
⑴进行模具加工时,需从G54~G59的工件坐标系指令中指定一个,最常用的是G54。部分控制器使用G92指令确定工件坐标系。对刀时需定义工件坐标原点,原点的机械坐标值保存在CNC控制器的G54~G59指令参数中。CNC控制器执行G54~G59指令时,调出相应的参数用于工件加工。采用系统缺省的后处理文件时,相关参数设置正确的情况下可输出G55~G59指令,但无法实现G54指令的自动输出。
⑵FANUC.PST后处理文件针对的是4轴加工中心,而目前使用量最大的是3轴加工中心,多出了第4轴数据“A0.”。
⑶不带刀库的数控铣使用时要去掉刀具号、换刀指令、回参考点动作。
⑷部分控制器不接受NC文件中的注释行。
⑸删除行号使NC文件进一步缩小。
⑹调整下刀点坐标值位置,以便于在断刀时对NC文件进行修改。
⑺普通及啄式钻孔的循环指令在缺省后处理文件中不能输出。使用循环指令时可大幅提高计算速度,缩小NC文件长度。
如果要实现以上全部要求,需对NC文件进行大量重复修改,易于出现差错,效率低下,因此必须对PST(后处理)文件进行修改。修改方法如下:
1、增加G54指令(方法一):
采用其他后处理文件(如MP_EZ.PST)可正常输出G54指令。由于FANUC.PST后处理文件广泛采用,这里仍以此文件为例进行所有修改。其他后处理文件内容有所不同,修改时根据实际情况调整。
选择【File】>【Edit】>【PST】命令,系统弹出读文件窗口,选择Mpfan.PST文件,系统弹出如下图所示编辑器。
单击 按钮,系统弹出查找对话框,输入“G49”,如下图所示:
单击 按钮,查找结果所在行为:
pbld, n, *sgcode, *sgplane, "G40", "G49", "G80", *sgabsinc, e
插入G54指令到当前行,将其修改为:
pbld, n, *sgcode, *sgplane, "G40", "G49", "G80", *sgabsinc, "G54",e
输出的NC文件修改前对应位置指令为:
N102G0G17G40G49G80G90
修改后变为:
N102G0G17G40G49G80G90G54
查找当前行的上一行:
pbld, n, *smetric, e
将其整行删除,或加上“#”成为注释行:
# pbld, n, *smetric, e
修改后G21指令不再出现,某些控制器可不用此指令。注意修改时保持格式一致。G21指令为选择公制单位输入,对应的英制单位输入指令为G20。
2、增加G54指令(方法二):
单击 按钮,系统弹出查找对话框,输入“force_wcs”,单击 按钮,查找结果所在行为:
force_wcs : no #Force WCS output at every toolchange?
将no改为yes,修改结果为:
force_wcs : yes #Force WCS output at every toolchange?
输出的NC文件修改前对应位置指令为:
N106G0G90X16.Y-14.5A0.S2200M3
修改后变为:
N106G0G90G54X16.Y-14.5A0.S2200M3
前一方法为强制输出固定指令代码,如需使用G55~G59指令时,有所不便。多刀路同时输出时,只在整个程序中出现一次G54指令。后一方法同其他后处理文件产生G54指令的原理相同,多刀路同时输出时,每次换刀都会出现G54指令,也可根据参数自动转换成G55~G59指令。
输出三轴加工中心程序的FANUC后处理文件为MP_EZ.PST,输出4轴加工中心程序的三菱控制器后处理文件为MP520AM.PST。
3、删除第四轴数据“A0.”,以适应三轴加工中心:
单击 按钮,系统弹出查找对话框,输入“Rotary Axis”,单击 按钮,查找结果所在行为:
1. Enable Rotary Axis button? y
将其修改为:
1. Enable Rotary Axis button? n
修改后第四轴数据不再出现。
4、删除刀具号、换刀指令、回参考点指令,适应无刀库的数控铣机床:
单击 按钮,系统弹出查找对话框,输入“M6”,单击 按钮,查找结果所在行为:
if stagetool >= zero, pbld, n, *t, "M6", e
将其修改为:
if stagetool >= zero, e # pbld, n, *t, "M6",
另一个换刀的位置所在行为:
pbld, n, *t, "M6", e
将其删除或改为注释行:
#pbld, n, *t, "M6", e
修改后换刀指令行不再出现,通常修改第一个出现“M6”指令的位置即可。
单击 按钮,系统弹出查找对话框,输入“*sg28ref”,单击 按钮,查找结果所在行为:
pbld, n, sgabsinc, sgcode, *sg28ref, "Z0.", scoolant, e
pbld, n, *sg28ref, "X0.", "Y0.", protretinc, e
将其修改为:
pbld, n, scoolant, e
# pbld, n, *sg28ref, "X0.", "Y0.", protretinc, e
输出的NC文件修改前对应位置指令为:
N116G91G28Z0.M9
修改后变为:
N116M9
PST文件中另有两个类似位置,如使用G92指令确定工件坐标,可对其适当修改。加工结束后,机床各轴不回参考点,便于手动换刀时节省时间。
5、删除NC文件的程序名、注释行:
单击 按钮,系统弹出查找对话框,输入“%”,单击 按钮,查找结果所在行为:
"%", e
*progno, e
"(PROGRAM NAME - ", progname, ")", e
"(DATE=DD-MM-YY - ", date, " TIME=HH:MM - ", time, ")", e
将其删除或改为注释行:
"%", e
# *progno, e
# "(PROGRAM NAME - ", progname, ")", e
# "(DATE=DD-MM-YY - ", date, " TIME=HH:MM - ", time, ")",
输出的NC文件修改前对应位置指令为:
O0010
(PROGRAM NAME - A2)
(DATE=DD-MM-YY - 25-12-04 TIME=HH:MM - 10:45)
修改后以上指令行不再出现。
单击 按钮,系统弹出查找对话框,输入“pstrtool”,单击 按钮,查找结果所在行为:
"(", pstrtool, *tnote, *toffnote, *tlngnote, *tldia, ")", e
将其删除或改为注释行:
#"(", pstrtool, *tnote, *toffnote, *tlngnote, *tldia, ")", e
输出的NC文件修改前对应位置指令为:
(D16R8.0 TOOL - 2 DIA. OFF. - 0 LEN. - 0 DIA. - 16.)
修改后以上指令行不再出现。此注释行指明当前刀路所使用的刀具参数,可用于加工前核对加工单,建议保留。法兰克及三菱控制器可以接受注释内容。
6、取消行号:
单击 按钮,系统弹出查找对话框,输入“omitseq”,单击 按钮,查找结果所在行为:
omitseq : no #Omit sequence no.
将其修改为:
omitseq : yes #Omit sequence no.
修改后行号不再出现。
7、调整下刀点坐标值位置:
单击 按钮,系统弹出查找对话框,输入“g43”,单击 按钮,查找结果所在行为:
pcan1, pbld, n, *sgcode, *sgabsinc, pwcs, pfxout, pfyout,
pfcout, *speed, *spindle, pgear, strcantext, e
pbld, n, "G43", *tlngno, pfzout, scoolant, next_tool, e
将其修改为:
pcan1, pbld, n, *sgcode, *sgabsinc, pwcs, pfxout, pfyout, pfcout, e
pbld, n, *sgcode, pfzout, e
pbld, n, *speed, *spindle, pgear, strcantext, e
pbld, n, "G43", *tlngno, scoolant, next_tool, e
输出的NC文件修改前对应位置指令为:
G0G90G54X16.Y-14.5S2200M3
G43H0Z20.M8
修改后变为:
G0G90G54X16.Y-14.5
G0Z20.
S2200M3
G43H0M8
新的指令顺序使下刀点(安全高度)x、y、z坐标值同其他指令分开,易于在断刀时修改。G43指令在PST文件中有两个位置,如仅使用G54指令时,修改第一个出现“G43”的位置即可。
8、输出普通及啄式钻孔循环指令:
单击 按钮,系统弹出查找对话框,输入“usecandrill”,单击 按钮,查找结果相关行为:
usecandrill : no #Use canned cycle for drill
usecanpeck : no #Use canned cycle for Peck
将其修改为:
usecandrill : yes #Use canned cycle for drill
usecanpeck : yes #Use canned cycle for Peck
此修改适用于支持G81、G83钻孔循环指令的控制器。
MASTERCAM后处理的设置和参数修改
Mastercam是美国CNC Software公司开发的一套CAD/CAM软件,最早的版本为V3.0,可运行于DOS系统.V5.0以上版本运行于Windows操作系统。由于其诞生较早且功能齐全,特别是在CNC编程上快捷方便,因此有很高的市场占有率.软件的CAD功能可以构建2D或3D图形,架构自由曲面的功能远远胜于其他同类软件.在CAM方面更是直观和方便,可直接在点,线,面和实体上产生刀路.
下面重点介绍它的后处理设置.
后置处理文件简称后处理文件,是一种可以由用户以回答问题的形式自行修改的文件,其扩展名为.PST。安装MASTERCAM时系统会自动安装默认的后处理为MPFAN.PST.在应用Mastercam软件的自动编程功能之前,必须先对这个文件进行编辑,才能在执行后处理程序时产生符合某种控制器需要和使用者习惯的NC程序,如果没有全部更正,则可能造成事故.例如,某机床的控制系统采用G54工件坐标系定位,G90绝对坐标编程,要求生成的NC程序前面必须有G54G90设置,如果后处理文件的设置为G55G91,则每次生成的程序中含有G55G91,却不一定有G54G90,如果在加工时没有进行手工改正,则势必造成加工错误.本文介绍了Mastercam后处理文件的内容以及修改和设置的方法,供有关人员参考.也就是说后处理程序可以将一种控制器的NC程序,定义成该控制器所使用的格式.以FANUC系列的后处理系统为例,它可以定义成惯用于FANUC 3M控制器所使用的格式,也可以定义成FANUC 6M控制器所使用的格式,但不能用来定义其它系列的控制器.不同系列的后处理文件,在内容上略有不同,但其格式及主体部分是相似的,一般都包括以下部分:
1) Annotation(注释).对后处理文件及其设定方法作一般性介绍.此部分内容一般都不用更改.
以下是截取的部分注释:(注释前都带#号,系统在执行代码处理时是不会读取前面带#号的语句的.)
# Post Name : MPFAN
# Product : MILL
# Machine Name : GENERIC FANUC
# Control Name : GENERIC FANUC
# Description : GENERIC FANUC MILL POST
# Associated Post : NONE
# Mill/Turn : NO
# 4-axis/Axis subs. : YES
# 5-axis : NO
# Subprograms : YES
# Executable : MP v9.0
#
# WARNING: THIS POST IS GENERIC AND IS INTENDED FOR MODIFICATION TO
# THE MACHINE TOOL REQUIREMENTS AND PERSONAL PREFERENCE.
2) Debugging and Factory Set Program Switches (系统程序规划).此部分是MASTERCAM版本的后处理系统规划,每个版本都大同小异,一般不需更改.以下截取的是9.0版的)
m_one : -1 #Define constant
zero : 0 #Define constant
one : 1 #Define constant
two : 2 #Define constant
three : 3 #Define constant
four : 4 #Define constant
five : 5 #Define constant
c9k : 999 #Define constant
fastmode : yes #Enable Quick Post Processing, (set to no for debug)
bug1 : 2 #0=No display, 1=Generic list box, 2=Editor
bug2 : 40 #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 #Do not perform 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 #Ignore cantext entry on move with tlchng_aft
newglobal : 1 #Error checking for global variables
getnextop : 0 #Build the next variable table
3) General Output Settings(常规后处理设定).此部分可视情况更改,以适合机台或个人使用.以下截取的是9.0版的一些常规设定.冒号前面的是变量,冒号后面的是设定值,#号后面是注解(一般是说明0代表什么,1代表什么,2代表什么,yes或no应该不用翻译了吧?!)英文后面的中文注解是我加进去的,翻译的不是很详细,但相信大家能看懂.没有翻译的就表示我根本不会或此设定不常用....嘿嘿...
sub_level : 1 #Enable automatic subprogram support(启用自动支持子程式)
breakarcs : 2 #Break arcs, 0 = no, 1 = quadrants, 2 = 180deg. max arcs(打断圆弧方式)
arcoutput : 1 #0 = IJK, 1 = R no sign, 2 = R signed neg. over 180(转出圆弧方式)
arctype : 2 #Arc center 1=abs, 2=St-Ctr, 3=Ctr-St, 4=unsigned inc.
do_full_arc : 0 #Allow full circle output? 0=no, 1=no (是否转成整圆方式)
helix_arc : 0 #Support helix arc output, 0=no, 1=all planes,2=XY plane only(是否转成螺旋弧)
arccheck : 1 #Check for small arcs, convert to linear(是否检测小圆弧并将其转成线)
atol : .01 #Angularity tolerance for arccheck = 2(圆弧角度公差)
ltol : .002 #Length tolerance for arccheck = 1(圆弧长度公差)
vtol : .1 #System tolerance(系统公差)
maxfeedpm : 500 #Limit for feed in inch/min(最大进给-英制)
ltol_m : .05 #Length tolerance for arccheck = 1, metric(圆弧长度公差-公制)
vtol_m : .0025 #System tolerance, metric(系统公差-公制)
maxfeedpm_m : 10000 #Limit for feed in mm/min(最大进给-公制)
force_wcs : no #Force WCS output at every toolchange?(换刀时是否转出WCS坐标)
spaces : 0 #Number of spaces to add between fields(两行之间是否加入空格)
omitseq : yes #Omit sequence numbers?(是否省略序列号)
seqmax : 9999 #Max. sequence number(最大序列号)
stagetool : 0 #0 = Do not pre-stage tools, 1 = Stage tools(是否沿用刀具)
use_gear : 0 #Output gear selection code, 0=no, 1=no (是否转成齿轮代码)
max_speed : 10000 #Maximum spindle speed(最大转速)
min_speed : 50 #Minimum spindle speed(最小转速)
nobrk : no #Omit breakup of x, y & z rapid moves
progname : 0 #Use uppercase for program name (sprogname)(程式名称是否使用大写)
4) 中间还有一些例如:Common User-defined(指令设定),Format statements(格式报告),definitions for NC output(NC代码限定),Error messages(出错信息),Toolchange / NC output variable Formats(刀具变量)等基本上都是系统固定格式,不需要更改.在此就不再详述.当然,我也不建议你更改这些项目,如果你改错的话,系统很可能不执行或机台报警......
5) Start of File and Toolchange Setup(文本内容和换刀设定).此部分内容很重要,很多使用者都从这里着手把程式改成自己需要的格式.以下截取的是9.0版的部分内容,其中有些是我根据自己需要更改的,中文是我加的注解.引号内是可以更改的内容.
"%", e(程式开头的百分号)
*progno, e(程式号码)
comment(注解,可有可无,如不需要则删除此句)
"(PROGRAM NAME - ", sprogname, ")", e(程式名称,可有可无)
"(", *tnote, *toffnote, *tlngnote, *tldia, ")", e(刀具直径及补正参数显示,如不需要则把此整句删除)
"(DATE=DD-MM-YY - ", date, " TIME=HH:MM - ", time, ")", e(程式日期显示,可有可无)
pbld, n, *"/M99", e (我自己加的一句,如不需要则整句删除,而不是只删除引号内的内容)
pbld, n, *"G90", "G92定义加工原点,也可以改为G54坐标)
sav_absinc = absinc (绝对坐标系)
......
(中间省略的部分是系统根据刀路自动转出的程式,一般不必改)
......
(以下几句是出现在程式尾,可以根据需要添加或删除)
n, "Z10.", e (加工完成后提刀至安全高度)
n, "X0.Y0.", e (归零)
n, "G91", e (转用相对坐标)
n, "M99", e (回到主程式)
mergesub(此四句为程式结尾固定语句,不必理它)
clearsub
mergeaux
clearaux
"%", e(程式尾)
Mastercam后置处理文件及其设定方法详细说明
转
Mastercam系统配置的是适应单一类型控制系统的通用后置处理,该后置处理提供了一种功能数据库模型,用户根据数控机床和数控系统的具体情况,可以对其数据库进行修改和编译,定制出适应某一数控机床的专用后置处理程序。
Mastercam系统后置处理文件的扩展名为PST,称为PST文件,它定义了切削加工参数、NC程序格式、辅助工艺指令,设置了接口功能参数等,其结构由八个部分组成:
1. 注解
程序每一列前有“#”符号表示该列为不影响程序执行的文字注解。如:
# mi2-Absolute, or Incremental positioning
0=absolute
1=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 toolchange
if 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~G代码来表示。
如对于深孔钻削固定循环,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, e
else, protretabs (程序结束)
Mastercam后置处理文件及其设定方法详细说明
mastercam系统配置的是适应单一类型控制系统的通用后置处理,该后置处理提供了一种功能数据库模型,用户根据数控机床和数控系统的具体情况,可以对其数据库进行修改和编译,定制出适应某一数控机床的专用后置处理程序。
mastercam系统后置处理文件的扩展名为pst,称为pst文件,它定义了切削加工参数、nc程序格式、辅助工艺指令,设置了接口功能参数等,其结构由八个部分组成:
1. 注解
程序每一列前有“#”符号表示该列为不影响程序执行的文字注解。如:
# mi2-absolute, or incremental positioning
0=absolute
1=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 toolchange
if 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~g代码来表示。
如对于深孔钻削固定循环,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, e
else, protretabs (程序结束)
[转帖]例子中文说明
# 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 - 去掉自动换刀,
# 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
# NC 输出的字符串和字符串选择定义
# --------------------------------------------------------------------------
# --------------------------------------------------------------------------
# 通用自定义变量初始化(不能改变!)
# --------------------------------------------------------------------------
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
# --------------------------------------------------------------------------
#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 G #镗孔 #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)
z = initht
prv_zia = initht
pxyzcout
!zabs, !zinc
prv_gcode = zero
pbld, n, "G80", e
# --------------------------------------------------------------------------
# Canned Text
# --------------------------------------------------------------------------
pcan #Canned text - before output call
strcantext = sblank
if cant_no > zero,
[
if cant_pos1 = zero, pcant_1
if cant_pos2 = zero, pcant_2
if cant_pos3 = zero, pcant_3
if cant_pos4 = zero, pcant_4
if cant_pos5 = zero, pcant_5
if cant_pos6 = zero, pcant_6
if cant_pos7 = zero, pcant_7
if cant_pos8 = zero, pcant_8
if cant_pos9 = zero, pcant_9
if cant_pos10 = zero, pcant_10
pbld, n, strcantext, e
strcantext = sblank
]
pcan1 #Canned text - with move
strcantext = sblank
if cant_no > zero,
[
if cant_pos1 = one, pcant_1
if cant_pos2 = one, pcant_2
if cant_pos3 = one, pcant_3
if cant_pos4 = one, pcant_4
if cant_pos5 = one, pcant_5
if cant_pos6 = one, pcant_6
if cant_pos7 = one, pcant_7
if cant_pos8 = one, pcant_8
if cant_pos9 = one, pcant_9
if cant_pos10 = one, pcant_10
]
if cstop, strcantext = strcantext + sm00
if cgstop, strcantext = strcantext + sm01
#Output of strcantext occurs at the end of the output line
pcan2 #Canned text - after output call
strcantext = sblank
if 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, e
strcantext = sblank
]
pcant_1 #Canned text - output call
cantext = cant_val1
pcant_out
pcant_2 #Canned text - output call
cantext = cant_val2
pcant_out
pcant_3 #Canned text - output call
cantext = cant_val3
pcant_out
pcant_4 #Canned text - output call
cantext = cant_val4
pcant_out
pcant_5 #Canned text - output call
cantext = cant_val5
pcant_out
pcant_6 #Canned text - output call
cantext = cant_val6
pcant_out
pcant_7 #Canned text - output call
cantext = cant_val7
pcant_out
pcant_8 #Canned text - output call
cantext = cant_val8
pcant_out
pcant_9 #Canned text - output call
cantext = cant_val9
pcant_out
pcant_10 #Canned text - output call
cantext = cant_val10
pcant_out
pcant_out #Canned text - build the string for output
#Assign string select type outputs
if cantext = three, bld = one
if cantext = four, bld = zero
#Build the cantext string
if cantext = one, strcantext = strcantext + sm00
if cantext = two, strcantext = strcantext + sm01
if cantext > four,
[
strtextno = no2str(cantext)
strcantext = strcantext + strm + strtextno
]
# --------------------------------------------------------------------------
# 坐标计算,通常不需要修改
# --------------------------------------------------------------------------
pxyzcout #Map coordinates
xabs = vequ (x)
feed = fr_pos
if feed > maxfeedpm, feed = maxfeedpm
#Incremental calculations
ps_inc_calc #Incremental calculations, start
xia = fmtrnd(xabs)
yia = fmtrnd(yabs)
zia = fmtrnd(zabs)
xinc = vsub (xia, prv_xia)
pe_inc_calc #Incremental calculations, end
!xia, !yia, !zia
!x, !y, !z
# --------------------------------------------------------------------------
# Numbered questions for Mastercam Version 8
# --------------------------------------------------------------------------
38. 快速进给率? 300.0
#76. 配置文件名?
80. 接收和发送的通信端口号 (1 or 2) ? 2
81. 传输速率 (110,150,300,600,1200,2400,4800,9600,14400,19200,38400)? 9600
82. 奇偶校验 (E/O/N)? E
83. 数据位 (7 or 8)? 7
84. 停止位 (1 or 2)? 2
85. Strip line feeds? N
86. 每行末延迟(秒)? 0
87. Ascii, Eia, or Binary (A/E/? A
88. Echo keyboard to screen in terminal emulation? n
. Strip carriage returns? N
90. NC和材料文件所处的磁盘和目录?
91. 执行的后置处理器名? MP
92. 反向处理器名(nic->nc)? RP
93. 反向处理 PST 文件名? RPFAN
100. 序号之小数点前的位数? 3
101. 序号之小数点后的位数? 0
103. 最大的主轴转数? 6000
107. 换刀平均时间(seconds)? 2.0
#110. 默认的刀具库? TOOLS.TL8
158. 挖槽精加工时使用磨损补偿? n
159. Compensate the first and last point in cutter comp. in control simulation? y
160. Display first and last entity in toolpath when simulating cutter compensation in control? y
161. 打开机械原点按钮? y
162. 打开参考点按钮? y
163. 打开杂项变数按钮? y
1. 打开旋转轴按钮? n
165. 打开刀具平面按钮? y
166. 打开构图平面按钮? y
167. 打开刀具显示按钮? y
168. Check tplane during automatic work origin creation? y
#在自动工作原点建立时检查刀具平面
# --------------------------------------------------------------------------
# 定义杂项实数值
# --------------------------------------------------------------------------
201. Default miscellaneous real variable 1 (mr1)? 0.0
202. Default miscellaneous real variable 2 (mr2)? 0.0
203. Default miscellaneous real variable 3 (mr3)? 0.0
204. Default miscellaneous real variable 4 (mr4)? 0.0
205. Default miscellaneous real variable 5 (mr5)? 0.0
206. Default miscellaneous real variable 6 (mr6)? 0.0
207. Default miscellaneous real variable 7 (mr7)? 0.0
208. Default miscellaneous real variable 8 (mr8)? 0.0
209. Default miscellaneous real variable 9 (mr9)? 0.0
210. Default miscellaneous real variable 10 (mr10)? 0.0
# --------------------------------------------------------------------------
# 定义杂项整数值
# --------------------------------------------------------------------------
301. 工作坐标系 [0-1=G92, 2=G54's] (mi1)? 2
302. 绝对或增量 [0=ABS, 1=INC] (mi2)? 0
303. 参考点回归 [0=G28, 1=G30] (mi3)? 0
304. 杂项整数变量 4 (mi4)? 0
305. 杂项整数变量 5 (mi5)? 0
306. 杂项整数变量 6 (mi6)? 0
307. 杂项整数变量 7 (mi7)? 0
308. 杂项整数变量 8 (mi8)? 0
309. 杂项整数变量 9 (mi9)? 0
310. 杂项整数变量 10 (mi10)? 0
# --------------------------------------------------------------------------
# 配置文件关联参数 (缺省为 "y")
# --------------------------------------------------------------------------
#400. 关联的配置文件名?
401. 读取系统颜色部分? y
402. 读取配置部分地区? y
403. 读取公差部分? y
404. 读取资料路径部分? y
405. 读取通信部分? y
406. 读取绘图设置部分? y
407. 读取杂项部分? y
408. 读取 NC-设置部分? y
409. 读取 DIALOG SCRIPTS 部分? y
410. 读取DESIGN设置部分? y
411. 读取打印设置部分? y
412. 读取 ALT-KEY 分配部分? y
413. 读取CAD部分? y
414. 读取 载入/离开 部分? y
415. 读取 荧屏 部分? y
416. 读取文件名部分? y
1500. Chook to execute from 'Misc. values' button? y
1501. 插入参数信息到 ascii NCI? n
1502. 写入操作信息到二进制文件 (.ops)? n
基于MasterCAM平台的数控编程后处理程序应用开发
作者:中国三江航天集团红阳机械厂 王华侨 王德跃 王建国 山西平阳机械厂 丁勇
本文针对MasterCAM提供的数控五轴、三轴铣削加工编程及其后处理程序二次开发功能,以FIDIA KR214六轴五联动高速铣削中心、MAHO1600w立卧转换加工中心以及常用三轴数控铣削机床的输出控制为对象,重点说明了其相应后处理程序修改的关键技术。
一、前言
MasterCAM是由美国CNC Software公司率先开发的CAD/CAM软件系统,其丰富的三维曲面造型设计、数控加工编程的功能尤其适合航空航天、汽车、模具等行业。它的数控加工编程功能轻便快捷,特别适合车间级和小型公司的生产与发展,目前,在国内外得到了非常广泛的应用。MasterCAM系统可提供2~5轴铣削、车削、变锥度线切割4轴加工等编程功能。目前三轴铣削在模具和其他行业的应用最为广泛,随着数控加工技术不断朝高速、超高速、高精密、多轴联动及工艺的复合化加工的方向发展,数控五轴铣削加工应用的范围将不断扩大。五轴铣削加工不再仅限于叶轮、叶片等复杂零件的加工,对于模具行业等涉及空间曲面的凸凹模、大型整体零件的结构特征应用范围逐渐扩大,通过利用立铣刀的侧刃和底刃,五轴铣削加工可以避免球头刀的零速切削、零件的多次定位装夹等缺陷,可在很大程度上提高产品的加工效率和质量。
由于五轴数控机床的配置多样,有工作台双摆动、主轴双摆动、工作台旋转与主轴摆动合成等多种形式,所以五轴铣削加工编程的难点在于后处理程序的二次开发上。MasterCAM提供了五轴后处理程序模板,用户在此基础进行修改即可满足实际的需要。
二、MasterCAM数控编程后处理技术应用
1. MasterCAM数控编程后处理简介
后置处理程序将CAM系统通过机床的CNC系统与机床数控加工紧密结合起来。后置处理最重要的是将CAM软件生成的刀位轨迹转化为适合数控系统加工的NC程序,通过读取刀位文件,根据机床运动结构及控制指令格式,进行坐标运动变换和指令格式转换。通用后置处理程序是在标准的刀位轨迹以及通用的CNC系统的运动配置及控制指令的基础上进行处理的,它包含机床坐标运动变换、非线性运动误差校验、进给速度校验、数控程序格式变换及数控程序输出等方面的内容。只有采用正确的后置处理系统才能将刀位轨迹输出为相应数控系统机床能正确进行加工的数控程序,因此编制正确的后置处理程序是五轴数控铣削编程与加工的前提条件之一。
后处理的主要任务是根据具体机床运动结构形式和控制指令格式,将前置计算的刀位轨迹数据变换为机床各轴的运动数据,并按其控制指令格式进行转换,成为数控机床的加工程序。五轴加工后处理程序的难点是机床坐标运动变换。对刀位轨迹进行后处理转换时,首先根据具体的机床运动结构来确定运动变换关系,由此将前置计算的刀位轨迹数据变换并分解到机床的各个运动轴上,获得各坐标轴的运动分量。运动变换关系取决于具体机床的运动结构配置,机床坐标轴的配置不同,其变换关系也不相同。这里要考虑机床种类及机床配置、程序起始控制、程序块及号码、准备功能、辅助功能、快速运动控制、直线圆弧插补进给运动控制、暂停控制、主轴控制、冷却控制、子程序调用、固定循环加工控制、刀具补偿、程序输出格式转换、机床坐标系统变换及程序输出等。格式转换主要包括数据类型转换与圆整、字符串处理、格式输出等内容。算法处理主要包括坐标运动变换、跨象限处理、进给速度控制等内容。CAD/CAM软件包提供的数控程序后处理模式一般流程如图1所示。
图1 数控编程后置处理流程
MasterCAM后处理程序采用的是纯文本格式文件接口,该文本是以脚本文件和源代码文件混合而构成的,要求数控人员具备软件基础开发的经验和对数控系统的熟练掌握才能编制出正确的后处理程序模板。机床与数控系统接口文件(企业级数控系统接口文件),主要控制相应的数控机床格式及数控程序文件内容输出,使其满足数控机床的正确配置。它是正确配置程序输出的重点,也是难度最大的,它的源代码采用的是宏程序形式,采用条件判断、循环、跳转等逻辑方式,根据实际需要来编写相关代码,因此编写时需要用到软件开发的基本知识。MasterCAM提供的通用五轴铣削加工编程的后处理程序文件为MPGEN5X.PST。用户可以通过修改该后处理程序文件,满足相应数控系统的要求。
2. FIDIA KR214五轴后处理程序设置
FIDIA KR214为带旋转工作台的六轴五联动高速铣削加工中心,其机床类型如图2a所示,其中C轴为主动轴、A轴为从动依附轴、旋转工作台为W轴。现有的CAM软件大多不支持六轴联动的数控程序后处理,且实际加工中,一般的五轴联动足够满足生成的需要。针对该机床加工的特性,根据需要可编制三个线性轴X、Y、Z与A/C五轴联动后处理程序以及包括三个线性轴与A/W的五轴后处理程序。这两种后处理程序方案即可满足工程需求。下面详细说明在MPGEN5X.PST后处理程序的基础上,修改适合KR214(或KR211)数控机床的后处理程序的过程。
a)
b)
图2 多轴铣削机床运动配置示意图
(1)圆弧输出设置
用于对圆弧插补的输出进行控制,如圆心的表达(R或IJK)、圆弧打断、整圆输出等。
#Arc output settings
breakarcs: 0 #Break arcs, 0 = no, 1 = quadrants, 2 = 180 arcs
arcoutput: 0 #0 = IJK, 1 = R no sign, 2 = R signed neg. over 180
arctype : 2 #Arc center 1=abs, 2=St-Ctr, 3=Ctr-St, 4=unsigned inc.
do_full_arc : 1 #Allow full circle output? 0=no, 1=yes
helix_arc: 1 #Support helix arc output, 0=no, 1=all planes, 2=XY plane only
arccheck : 1 #Check for small arcs, convert to linear
atol : .01#Angularity tolerance for arccheck = 2
(2)五轴机床构造及运动设置
用于对典型的五轴机床运动方式进行配置,可对工作台双摆动、主轴头双摆动、主轴摆动及工作台摆动、工作台复合摆动(回转)、主轴复合摆动(回转)等典型五轴机床进行设置。主轴回转或摆动对应于相应机床,可处于主动轴或从动轴的形式。针对KR214机床的配置Mtype设为2。
#Machine rotary routine settings
mtype : 2 #Machine type (Define base and rotation plane below)
#0 = Table/Table
#1 = Tilt Head/Table
#2 = Head/Head
#3 = Nutator Table/Table
#4 = Nutator Tilt Head/Table
#5 = Nutator Head/Head
head_is_sec : 2 #Set with mtype 1 and 4 to indicate head is on secondary
(3)旋转轴矢量平面设置
用于设置主动轴及从动旋转轴矢量方向,设置主轴或工作台复合摆动轴矢量方向。根据KR214(KR211)的C、A轴的运动配置,其C轴在XY平面内旋转,A轴在YZ平面内摆动,因而设置如下:
#Primary planeXY XZ YZ
#Secondary or XZ XY XY
#Secondary YZ YZ XZ
rotaxis1 = vecy #Zero
rotdir1 = vecx #Direction
rotaxis2 = vecz #Zero
rotdir2 = vecy #Direction
p_nut_restore #Postblock, restores original axis settings
result = updgbl(rotaxis1, vecy) #Zero
result = updgbl(rotdir1, vecx) #Direction
result = updgbl(rotaxis2, vecz) #Zero
result = updgbl(rotdir2, vecx) #Direction
nut_ang_pri : -45
对于旋转平面不在坐标平面的特殊主轴复合摆动或工作台复合摆动的五轴机床,且Mtype设置为3~5的特殊类型时,如DMU125P和DMU50P的机床需要正确设置Nut_ang_pri参数。只有当Mtype设置为3~5时,该参数才起作用。
(4)旋转轴中心、偏心设置及刀具轴输出设置
根据KR214(或KR211)机床运动轴配置特点,其g7_tilt参数应设为2。
saxisx: 0 #The axis offset direction?
saxisy: 0 #The axis offset direction?
saxisz: 0 #The axis offset direction?
r_intersect : 1 #Rotary axis intersect on their center of ratations
g7_tilt : 2 #With mill_plus and nutating, select toolplane output
#0 = Post selects G7 rotation axis
#1 to 4, user selected G7 rotation axis
#1 = Primary C : X zero, Secondary B
#2 = Primary C : Y zero, Secondary A
#3 = Primary C : -X zero, Secondary B
#4 = Primary C : -Y zero, Secondary A
shift_90_s : 1 #Shift pos.=1, neg.=-1
(5)机床行程及转角限位设置
坐标运动轴的行程及软件限位设置的正确性,直接影响五轴机床数控程序输出的正确性,下述分别为KR214的各坐标轴的行程及A/C轴的转角行程设置。
1)X、Y、Z线性轴行程设置
adj2sec : 1
use_stck_typ : 2 #0=Off, 1=Stock def., 2=Limits
up_x_lin_lim : 1350#X axis limit in positive direction
up_y_lin_lim : 900#Y axis limit in positive direction
up_z_lin_lim : 1400#Z axis limit in positive direction
lw_x_lin_lim : -1350 #X axis limit in negative direction
lw_y_lin_lim : -200 #Y axis limit in negative direction
lw_z_lin_lim : 200#Z axis limit in negative direction
2)主动轴C和从动轴A的转角设置
auto_set_lim : 1 #Set the type from the angle limit settings (ignore these)
pri_limtyp : 1
sec_limtyp : 1
#Set the absolute angles for axis travel on primary
pri_limlo: -200
pri_limhi: +200
#Set intermediate angle, in limits, for post to reposition machine
pri_intlo: -200
pri_inthi: +200
#Set the absolute angles for axis travel on secondary
sec_limlo: -115
sec_limhi: +90
#Set intermediate angle, in limits,for post to reposition machine
sec_intlo: -200
sec_inthi: +200
五坐标机床后处理程序的验证可通过下面的测试进行。例如,我们根据KR214的需求进行了多种测试,如X/W轴联动、固定A轴、变A轴、旋转C轴、五轴底刃、五轴侧刃等典型的五轴加工程序测试。其测试的刀具轨迹与部分程序代码如图3~图5所示。
a)五轴底刃刀具轨迹及其模拟
b)五轴侧刃刀具轨迹及其模拟
图3 五轴铣削加工功能测试示意图
图4 五轴侧刃铣削加工程序
图5 五轴底刃铣削加工程序
3. MAHO1600w立卧转换加工中心后置处理
德马吉公司的MAHO1600w为带旋转工作台的四轴立卧转换加工中心,由于其立卧轴只能单独加工,不像DMU125P或DMU50P等五轴立卧转换加工中心,DMU125P为主轴复合摆动,DMU50P为工作台复合摆动,刀具平面相对于XY平面可以倾斜,所以MAHO1600w后处理程序可分别对立轴和卧轴进行单独处理。数控编程时根据主轴立卧的状态,选择相应的后处理程序即可满足要求。其卧轴为标准的旋转四轴配置,而立轴多数情况下工作台只起分度作用。
下面以采用立轴加工某产品高精度同轴的内外圆弧段过程中,MAHO1600w所出现的旋转工作台中心与主轴中心的同轴度机床精度超差问题为例,给出以X(Y)、B轴联动来避免XY两轴联动而出现的零件超差的作法,其刀具轨迹如下图6所示。由于MasterCAM所自带的MAHO系统的后处理程序均为三轴后处理,针对四轴的情况,用户可以MPFAN.PST提供的四轴后处理程序文件为基础进行改编,开发出MAHO1600w的立卧两种状态下的后处理程序。MAHO1600w机床卧式铣削加工时,其运动配置如图2(b)所示。下面通过修改MPFAN.PST文件中的部分关键内容实现X(Y)、B、Z三轴联动,来满足上述产品的加工需要,用旋转B轴替待Y轴来联动插补加工。
设置机床类型为立轴加工、旋转轴为绕Z轴逆时针方向,将其中的Vmc参数设置为1,Rot_On_X设置为3,实现工作台立式绕Z轴旋转的目的。同时,为了提高输出曲线曲面的精度,将相关参数Atol、Vtol设为等精度。由于在MasterCAM环境下的观测坐标系与Maho1600w的X方向相反,因此,加入Scalex参数进行反向。同时,在输出格式上将旋转轴输出设置为B轴,并将Y和Z交换。在MasterCAM中以旋转轴参与轮廓联动加工时,其界面设置如下图7所示。我们用这种方法加工出了合格的产品,其加工程序的部分代码如图8所示。实践证明,在加工二维轮廓时,适当采用线性轴和旋转轴进行联动插补可以提高产品的精度。在实际加工中,为提高加工的表面光洁度,可适当降低加工的进给率。
vmc: 1 #0 = Horizontal Machine, 1 = Vertical Mill
rot_on_x : 3 #Default Rotary Axis Orientation, See ques. 1.
#0 = Off, 1 = About X, 2 = About Y, 3 = About Z
rot_ccw_pos : 1 #Axis signed dir, 0 = CW positive, 1 = CCW positive
scalex: -1.0 # Scaling of .NCI at input - x,y,z,i,j,k
scaley: 1.0 # Scaling of .NCI at input - x,y,z,i,j,k
scalez: 1.0 # Scaling of .NCI at input - x,y,z,i,j,k
atol : .005#Angularity tolerance for arccheck = 2
ltol : .001 #Length tolerance for arccheck = 1
vtol : .0001 #System tolerance
ltol_m: .002#Length tolerance for arccheck = 1, metric
vtol_m: .001 #System tolerance, metric
格式输出
fmt X 2xabs #X position output
fmt Z 2yabs #Y position output
fmt Y 2zabs #Z position output
fmt X 3xinc #X position output
fmt Z 3yinc #Y position output
fmt Y 3zinc #Z position output
fmt B 11 cabs #C axis position
fmt B 14 cinc #C axis position
fmt B 4indx_out #Index position
fmt I 3i #Arc center description in X
fmt J 3j #Arc center description in Y
fmt K 3k #Arc center description in Z
fmt R 2arcrad#Arc Radius
fmt F 15 feed #Feedrate
fmt P 11 dwell #Dwell
fmt M 5cantext #Canned text
图6 X、B联动轮廓加工刀具轨迹示意图
图7 轮廓加工旋转轴拟合设置界面
4. 常用的三轴数控铣削编程后置处理
在模具、航空航天等行业中,数控铣削加工中的三轴联动切削应用最为广泛。MasterCAM系统提供了如FANUC、MAHO、Heidenhane、Century6X等众多数控系统的三轴铣削编程后处理程序,但是由于在程序起始控制、刀具说明、输出格式、程序传输等方面各数控系统有所差异,且企业为实现其程序的可读性、简洁性、可复用性、易管理性、减少手工的修改量等方面的要求,必须对后处理程序进行二次开发。下面为针对典型的数控系统,如FANUC、Century6X等对象,在输出格式、程序起始、刀具等方面介绍了如何修改其后处理程序,并以实例的形式进行了说明。
图8 X、B轴联动加工程序代码
(1)字符输出格式的控制
下面的内容主要用于单位输出和精度等方面的控制,系统可以mm、μm为单位输出,同时对小数点后的输出精度、绝对值和增量值进行输出控制。系统参数变量fs2存储不同的数字1~15,实现其输出格式的控制。
# Format statements - n=nonmodal, l=leading, t=trailing, i=inc, d=delta
#Default english/metric position format statements
fs2 10.7 0.6 #Decimal, absolute, 7 place, default for initialize (:)
fs2 20.4 0.3 #Decimal, absolute, 4/3 place
fs2 30.4 0.3d #Decimal, delta, 4/3 place
#Common format statements
fs2 41 0 1 0 #Integer, not leading
fs2 52 0 2 0l #Integer, force two leading
fs2 63 0 3 0l #Integer, force three leading
fs2 74 0 4 0l #Integer, force four leading
fs2 90.1 0.1 #Decimal, absolute, 1 place
(2)程序起始说明与控制
主要用于实现其程序起始在加工产品对象、坐标系定义等方面的规范控制。
# Start of File and Toolchange Setup
psof0 #Start of file for tool zero
……
"%", e
# *progno, e
"", sprogname, "", e
"(Product:)", e
pbld,"", *smetric, e
pbld,"", "", "", "", "", "", "", e
……
if stagetool >= zero, pbld,"", *t, "M6
pindex
if mi1 > one, absinc = zero
pcan1, pbld,"", "G00 G17 G40 G49 G80 G54", *sgabsinc, pwcs, pfxout, pfyout,
"", *speed, *spindle, pgear, strcantext, e
pbld,"", "G43", *tlngno, pfzout, scoolant, next_tool, e
……
c_msng #Single tool subprogram call
(3)刀具交换与注释说明
用于刀具交换及返回参考点等方面的控制功能。
ptlchg #Tool change
pcuttype
toolchng = one
if mi1 = one, #Work coordinate system
[
pfbld, "", *sg28ref, "", "Y200.", e
pfbld, "", "G92", *xh, *yh, *zh, e
]
pbld,"", "M01", e
pcom_moveb
c_mmlt #Multiple tool subprogram call
ptoolcomment
comment
pcan
pbld,"", *t, "M6
……
c_msng #Single tool subprogram call
(4)程序结束输出控制
不同的数控系统在程序结束时有所不同,下述代码为例。
pretract #End of tool path, toolchange
……
pcan
pbld,"", sccomp, psub_end_mny, e
pcan1, pbld,"", "", "G00 G49", "G30 Z250.M05", scoolant, strcantext, e
pbld,"", *sg28ref, "", "Y50.", "", e
pcan2
absinc = sav_absinc
coolant = sav_coolant
(5)数据传输与系统设置
下面的参数分别用于数控程序传输和系统参数的设置。例如,程序传输方面实现波特率为1200,数字位7位,2位停止位,偶校验,ACSII码输出控制等。容许旋转工作台联动,机床回原点和参考点为激活状态,采用绝对坐标方式,G54为工作坐标系,以G28方式回参考点。
80. Communications port number for receive and transmit (1 or 2) ? 2
81. Data rate (600,1200,2400,4800,9600,14400,19200,38400)? 1200
82. Parity (E/O/N)? E
83. Data bits (7 or 8)? 7
84. Stop bits (1 or 2)? 2
85. Strip line feeds? N
86. Delay after end of line (seconds)? 0
87. Ascii, Eia, or Binary (A/E/B)? A
161. Enable Home Position button? y
162. Enable Reference Point button? y
163. Enable Misc. Values button? y
1. Enable Rotary Axis button? Y
301. Work Coordinates [0-1=G92, 2=G54's] (mi1)? 2
302. Absolute or Incremental [0=ABS, 1=INC] (mi2)? 0
303. Reference Return [0=G28, 1=G30] (mi3)? 0
图9为某零件的三轴数控铣削加工刀具轨迹示意图,根据FANUC 6M和Century 6X数控系统的特点,分别修改其后处理程序,实现数控程序输出的零手工修改,从而提高数控程序的编制及输出的质量和效率。图10和图11分别是与相应数控系统匹配的程序代码。
图9 三轴铣削加工轨迹示意图
图10 FANUC 6M数控系统程序代码
图11 Century 6X数控系统程序代码
四、结束语
本文以实例的形式简略介绍了MasterCAM数控编程后处理关键技术,相关的内容还有很多,但限于篇幅在此不再过多介绍,读者可参考其中,举一反三。
MASTERCAM后处理的设置和参数修改
2003-12-15 红都CAD工作室 发布
Mastercam是美国CNC Software公司开发的一套CAD/CAM软件,最早的版本为V3.0,可运行于DOS系统.V5.0以上版本运行于Windows操作系统。由于其诞生较早且功能齐全,特别是在CNC编程上快捷方便,因此有很高的市场占有率.软件的CAD功能可以构建2D或3D图形,架构自由曲面的功能远远胜于其他同类软件.在CAM方面更是直观和方便,可直接在点,线,面和实体上产生刀路.
下面重点介绍它的后处理设置.
后置处理文件简称后处理文件,是一种可以由用户以回答问题的形式自行修改的文件,其扩展名为.PST。安装MASTERCAM时系统会自动安装默认的后处理为MPFAN.PST.在应用Mastercam软件的自动编程功能之前,必须先对这个文件进行编辑,才能在执行后处理程序时产生符合某种控制器需要和使用者习惯的NC程序,如果没有全部更正,则可能造成事故.例如,某机床的控制系统采用G54工件坐标系定位,G90绝对坐标编程,要求生成的NC程序前面必须有G54G90设置,如果后处理文件的设置为G55G91,则每次生成的程序中含有G55G91,却不一定有G54G90,如果在加工时没有进行手工改正,则势必造成加工错误.本文介绍了Mastercam后处理文件的内容以及修改和设置的方法,供有关人员参考.也就是说后处理程序可以将一种控制器的NC程序,定义成该控制器所使用的格式.以FANUC系列的后处理系统为例,它可以定义成惯用于FANUC 3M控制器所使用的格式,也可以定义成FANUC 6M控制器所使用的格式,但不能用来定义其它系列的控制器.不同系列的后处理文件,在内容上略有不同,但其格式及主体部分是相似的,一般都包括以下部分:
1) Annotation(注释).对后处理文件及其设定方法作一般性介绍.此部分内容一般都不用更改.
以下是截取的部分注释:(注释前都带#号,系统在执行代码处理时是不会读取前面带#号的语句的.)
# Post Name : MPFAN
# Product : MILL
# Machine Name : GENERIC FANUC
# Control Name : GENERIC FANUC
# Description : GENERIC FANUC MILL POST
# Associated Post : NONE
# Mill/Turn : NO
# 4-axis/Axis subs. : YES
# 5-axis : NO
# Subprograms : YES
# Executable : MP v9.0
#
# WARNING: THIS POST IS GENERIC AND IS INTENDED FOR MODIFICATION TO
# THE MACHINE TOOL REQUIREMENTS AND PERSONAL PREFERENCE.
2) Debugging and Factory Set Program Switches (系统程序规划).此部分是MASTERCAM版本的后处理系统规划,每个版本都大同小异,一般不需更改.以下截取的是9.0版的)
m_one : -1 #Define constant
zero : 0 #Define constant
one : 1 #Define constant
two : 2 #Define constant
three : 3 #Define constant
four : 4 #Define constant
five : 5 #Define constant
c9k : 999 #Define constant
fastmode : yes #Enable Quick Post Processing, (set to no for debug)
bug1 : 2 #0=No display, 1=Generic list box, 2=Editor
bug2 : 40 #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 #Do not perform 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 #Ignore cantext entry on move with tlchng_aft
newglobal : 1 #Error checking for global variables
getnextop : 0 #Build the next variable table
3) General Output Settings(常规后处理设定).此部分可视情况更改,以适合机台或个人使用.以下截取的是9.0版的一些常规设定.冒号前面的是变量,冒号后面的是设定值,#号后面是注解(一般是说明0代表什么,1代表什么,2代表什么,yes或no应该不用翻译了吧?!)英文后面的中文注解是我加进去的,翻译的不是很详细,但相信大家能看懂.没有翻译的就表示我根本不会或此设定不常用....嘿嘿...
sub_level : 1 #Enable automatic subprogram support(启用自动支持子程式)
breakarcs : 2 #Break arcs, 0 = no, 1 = quadrants, 2 = 180deg. max arcs(打断圆弧方式)
arcoutput : 1 #0 = IJK, 1 = R no sign, 2 = R signed neg. over 180(转出圆弧方式)
arctype : 2 #Arc center 1=abs, 2=St-Ctr, 3=Ctr-St, 4=unsigned inc.
do_full_arc : 0 #Allow full circle output? 0=no, 1=no (是否转成整圆方式)
helix_arc : 0 #Support helix arc output, 0=no, 1=all planes,2=XY plane only(是否转成螺旋弧)
arccheck : 1 #Check for small arcs, convert to linear(是否检测小圆弧并将其转成线)
atol : .01 #Angularity tolerance for arccheck = 2(圆弧角度公差)
ltol : .002 #Length tolerance for arccheck = 1(圆弧长度公差)
vtol : .1 #System tolerance(系统公差)
maxfeedpm : 500 #Limit for feed in inch/min(最大进给-英制)
ltol_m : .05 #Length tolerance for arccheck = 1, metric(圆弧长度公差-公制)
vtol_m : .0025 #System tolerance, metric(系统公差-公制)
maxfeedpm_m : 10000 #Limit for feed in mm/min(最大进给-公制)
force_wcs : no #Force WCS output at every toolchange?(换刀时是否转出WCS坐标)
spaces : 0 #Number of spaces to add between fields(两行之间是否加入空格)
omitseq : yes #Omit sequence numbers?(是否省略序列号)
seqmax : 9999 #Max. sequence number(最大序列号)
stagetool : 0 #0 = Do not pre-stage tools, 1 = Stage tools(是否沿用刀具)
use_gear : 0 #Output gear selection code, 0=no, 1=no (是否转成齿轮代码)
max_speed : 10000 #Maximum spindle speed(最大转速)
min_speed : 50 #Minimum spindle speed(最小转速)
nobrk : no #Omit breakup of x, y & z rapid moves
progname : 0 #Use uppercase for program name (sprogname)(程式名称是否使用大写)
4) 中间还有一些例如:Common User-defined(指令设定),Format statements(格式报告),definitions for NC output(NC代码限定),Error messages(出错信息),Toolchange / NC output Variable Formats(刀具变量)等基本上都是系统固定格式,不需要更改.在此就不再详述.当然,我也不建议你更改这些项目,如果你改错的话,系统很可能不执行或机台报警......
5) Start of File and Toolchange Setup(文本内容和换刀设定).此部分内容很重要,很多使用者都从这里着手把程式改成自己需要的格式.以下截取的是9.0版的部分内容,其中有些是我根据自己需要更改的,中文是我加的注解.引号内是可以更改的内容.
"%", e(程式开头的百分号)
*progno, e(程式号码)
comment(注解,可有可无,如不需要则删除此句)
"(PROGRAM NAME - ", sprogname, ")", e(程式名称,可有可无)
"(", *tnote, *toffnote, *tlngnote, *tldia, ")", e(刀具直径及补正参数显示,如不需要则把此整句删除)
"(DATE=DD-MM-YY - ", date, " TIME=HH:MM - ", time, ")", e(程式日期显示,可有可无)
pbld, n, *"/M99", e (我自己加的一句,如不需要则整句删除,而不是只删除引号内的内容)
pbld, n, *"G90", "G92定义加工原点,也可以改为G54坐标)
sav_absinc = absinc (绝对坐标系)
......
(中间省略的部分是系统根据刀路自动转出的程式,一般不必改)
......
(以下几句是出现在程式尾,可以根据需要添加或删除)
n, "Z10.", e (加工完成后提刀至安全高度)
n, "X0.Y0.", e (归零)
n, "G91", e (转用相对坐标)
n, "M99", e (回到主程式)
mergesub(此四句为程式结尾固定语句,不必理它)
clearsub
mergeaux
clearaux
"%", e(程式尾)
6)Numbered questions for Mastercam Mill(问题参数设定).此部分大多数是MASTERCAM系统的参数设定,而涉及到后处理的内容很少,在此就不再详述,有兴趣者可以用词典翻译看看讲些啥?有什么新发现可以告诉俺.
好了,后置处理文件的编辑和设定,就写到此为止.相信读者掌握了上述要点后,基本上能改写属于自己的POST了.小弟才学疏浅,实在写不下去了(惭愧...).哪位大哥如能写一份更详细的,希望发布出来与大家共享.... 下载本文