# 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 line
cant_tlchng : 1 #忽视 cantext 入口 on move with tlchng_aft
newglobal : 1 #全局变量错误检测
getnextop : 0 #建立下一个变量表
# --------------------------------------------------------------------------
# 通用自定义变量初始化(不能改变!)
# --------------------------------------------------------------------------
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
#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
# --------------------------------------------------------------------------
# 刀具交换 / 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
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)
]
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
]
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
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
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
]
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
89. 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
164. 打开旋转轴按钮? 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
# --------------------------------------------------------------------------
# 配置文件关联参数 (缺省为 "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