找回密码
 注册
Simdroid-非首页
楼主: longxianhua

[CNC程序編輯] Mastercam軟體的後置處理文件及其設定方法

[复制链接]
 楼主| 发表于 2006-8-5 11:28:25 | 显示全部楼层 来自 广东广州
# 文件起始和刀具交换设置
# --------------------------------------------------------------------------
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
 楼主| 发表于 2006-8-5 11:28:54 | 显示全部楼层 来自 广东广州
Simdroid开发平台
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
        ]
 楼主| 发表于 2006-8-5 11:29:22 | 显示全部楼层 来自 广东广州
#换刀设置
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   
        ]
 楼主| 发表于 2006-8-5 11:29:55 | 显示全部楼层 来自 广东广州
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
 楼主| 发表于 2006-8-5 11:30:55 | 显示全部楼层 来自 广东广州
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
        ]
 楼主| 发表于 2006-8-5 11:31:24 | 显示全部楼层 来自 广东广州
# --------------------------------------------------------------------------
# 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
 楼主| 发表于 2006-8-5 11:31:53 | 显示全部楼层 来自 广东广州
# --------------------------------------------------------------------------
# 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
        ]
 楼主| 发表于 2006-8-5 11:32:13 | 显示全部楼层 来自 广东广州
# --------------------------------------------------------------------------
#   坐标计算,通常不需要修改
# --------------------------------------------------------------------------
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/B)? 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
       #在自动工作原点建立时检查刀具平面
 楼主| 发表于 2006-8-5 11:32:45 | 显示全部楼层 来自 广东广州
# --------------------------------------------------------------------------
# 定义杂项实数值
# --------------------------------------------------------------------------
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
 楼主| 发表于 2006-8-5 11:45:02 | 显示全部楼层 来自 广东广州
因为后处理文件因机台及数控系统不同就会不同,希望大家能消化并理解!修改一个真正符合你们的工厂机台及数控系统的后置处理文件!
      有什么问题可直接联系!
       http://www.simwe.com
      QQ群:12786873
     希望大家多交流,有更好的建议及技巧上传到本网站交流!谢谢!
 楼主| 发表于 2006-8-5 11:54:40 | 显示全部楼层 来自 广东广州
我把刚那个上传一个附件吧!

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

×
发表于 2006-10-26 23:47:17 | 显示全部楼层 来自 北京

感谢斑竹

斑竹:你实在太强了,谢谢你给我们的珍贵资料,祝愿你学术常青!
发表于 2006-10-27 22:59:44 | 显示全部楼层 来自 广东广州
谢谢!楼主了,真是千里寻她千百度啊.
发表于 2010-9-11 17:24:35 | 显示全部楼层 来自 台湾
太好太棒的数据分享, 还要多下点功夫学习, 谢谢分享!:handshake
回复 不支持

使用道具 举报

发表于 2014-10-22 19:36:30 | 显示全部楼层 来自 浙江杭州
好帖子顶一个
回复 不支持

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|小黑屋|联系我们|仿真互动网 ( 京ICP备15048925号-7 )

GMT+8, 2024-4-19 09:04 , Processed in 0.031804 second(s), 7 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表