前言:
目前各位老铁们对“setupcfg”大概比较关心,姐妹们都想要了解一些“setupcfg”的相关内容。那么小编也在网络上网罗了一些关于“setupcfg””的相关内容,希望大家能喜欢,我们快快来了解一下吧!Mastercam后处理时间源代码,该方法所输出的时间只能放在程序尾部,如果需要放在程序头,需要使用者额外增加输出到程序头的代码,至于程序时间的准确与否,未经全面测试,部分测试时间可信。
由于代码较多,添加时严格按照下列方法进行。
1:换刀时间,这个需要根据实际情况进行相应的时间设定。
单位:分钟
tlchgtime : 0.066 #Tool Change Time (* in Minutes *) I'ts 4 sec now
2:定义切削进给,快速进给等保存数据标签。
ttltime : 0 #Total operation timetltime : 0 #Feed timetrtime : 0 #Rapid timetotal : 0 #Total machine timetot_ltime : 0 #Total FEED timetot_rtime : 0 #Total RAPID time
3:定义记录x,y,z相对距离保存数据标签
len : 0 #Length for calculationdx : 0 #Delta xdy : 0 #Delta ydz : 0 #Delta z
3:定义钻孔类辅助数据保存标签
drill_length_r : 0 # Drill length - RAPIDdrill_length_f : 0 # Drill length - FEEDactual_drl_depth : 0 # Actual drill depth variablepeck_safe_dist : 0.3 # Peck/Chip break safe distance for retratct into hole
4:定义他辅助开关
use_TC_pos : yes$ # Calculate with Home positions @ TC? 0=No, 1=Yessav_X_Pos : 0 # Saved X position, use X_home/Y_home/Z_home in rapids at TCsav_Y_Pos : 0 # Saved Y position, use X_home/Y_home/Z_home in rapids at TCsav_Z_Pos : 0 # Saved Z position, use X_home/Y_home/Z_home in rapids at TC
5:定义时间输出格式
time_format : 2 # Time format of output times in NC code: # 1 = 2h 14:25 # 2 = 2hrs, 14mins, 25.08sec
6:定义时间数据格式
fs2 8 0^2 0^2n #Decimal, 2 place, omit decimal if whole number, non-modal
7:定义时间数据输出类型
fmt 2 llenfmt 2 rlenfmt 2 llen_totalfmt 2 rlen_totalfmt 2 totalfmt 2 ttltimefmt 4 thrsfmt 4 tminfmt 8 tsec
8:初始化所有保存数据的标签
psetup #Output of toolchange information !gcode llen = zero #Reset counter for next tool rlen = zero #Reset counter for next tool tltime = zero #Reset counter for next tool trtime = zero #Reset counter for next tool ttltime = zero #Reset counter for next tool if use_TC_pos, [ sav_X_Pos = x, sav_Y_Pos = y, sav_Z_Pos = z x = xh, y = yh, z = zh ptime_calc x = sav_X_Pos, y = sav_Y_Pos, z = sav_Z_Pos ]
9:统计进给距离,快速进给距离,时间等
ptooldata #Total ending data for tool (Path Length and Times) llen_total = llen_total + llen #Keep running total for Program rlen_total = rlen_total + rlen #Keep running total for Program tot_ltime = tot_ltime + tltime #Total FEED time tot_rtime = tot_rtime + trtime #Total RAPID time ttltime = tltime + trtime #Calc. current Tool Time total = ttltime + total + tlchgtime #Calc. total Program Time
10:时间转换,按60进制进行转换
pthrminsec #Convert minutes to hr/min/sec format thrs = int(ttltime / 60) tmin = int(ttltime - thrs * 60) tsec = (ttltime - thrs * 60 - tmin) * 60
11:时间输出
ptimeout #Output "times" pthrminsec #Convert minutes to hr/min/sec format if time_format = one, [ #Output 'HOURS' if thrs = one, *thrs, "hr, " if thrs > one, *thrs, "hrs, " #Output 'MINUTES' if tmin = one, *tmin, "min, " if tmin > one, *tmin, "min, " #Output 'SECONDS' if tsec > zero, *tsec, "sec" ] else, [ result = newfs(five, tsec) #Output 'HOURS' if thrs > one, *thrs, "h " #Output 'MINUTES' and 'SECONDS' *tmin, ":", *tsec ]
12:快速进给时间计算
ptimer #Rapid time and length calc rlen = rlen + len #Running total RAPID length trtime = rlen / pst_rpd_fr #Running total RAPID time
13:进给加工时间计算
ptimel #Feed time and length calc llen = llen + len tltime = tltime + len / fr_pos
14:运行轨迹距离计算
ptime_calc #Distance calculations # Delta Distances dx = x - prv_x dy = y - prv_y dz = z - prv_z # Distance at linear movement if gcode = zero | gcode = one, len = sqrt(dx^2 + dy^2 + dz^2) # Distance at circular movement if gcode = two | gcode = three, len = (abs(sweep)/360) * 2 * arcrad * pi # Distance at drilling if gcode = 81 | gcode = 100, [ if gcode = 100, ptime_drill_XY if drillcyc = 0, ptime_drill_0 # Simple Drill if drillcyc = 1, ptime_drill_1 # Peck Drill if drillcyc = 2, ptime_drill_2 # Chip Break Drill if drillcyc = 3, ptime_drill_3 # Tapping if drillcyc = 4, ptime_drill_4 # Bore, feed out, Reaming if drillcyc = 5, ptime_drill_0 # Bore, stop, rapid out, SAME movements as "Simple Drill" if drillcyc = 6, ptime_drill_0 # Bore, fine, SAME movements as "Simple Drill" if drillcyc = 7, ptime_drill_0 # Bore, standard, SAME movements as "Simple Drill" ] # Time calculations by feed type if gcode = zero, ptimer #RAPID time and length calc if gcode = one | gcode = two | gcode = three, ptimel #FEED time and length calc !x, !y, !z, !fr_pos #Update previous [prv_?] variables
15:G81,G82钻孔距离,时间计算
ptime_drill_0 # Simple Drill lengths len = abs(refht - depth) ptimel if initht <> refht, [ len = abs(initht - refht) len = len + abs(initht - depth) ptimer ] else, [ len = abs(refht - depth) ptimer ] if dwell <> zero, total = total + (dwell / 60)
16:G83钻孔距离,时间计算
ptime_drill_1 # Peck Drill drill_length_f = abs(refht - depth) actual_drl_depth = peck1 while actual_drl_depth < drill_length_f, [ len = peck1 + peck_safe_dist ptimel len = (actual_drl_depth * 2) - peck_safe_dist ptimer actual_drl_depth = actual_drl_depth + peck1 ] len = (drill_length_f - actual_drl_depth) + peck_safe_dist + peck1 ptimel if initht <> refht, [ len = abs(initht - refht) len = len + abs(initht - depth) ptimer ] else, [ len = abs(refht - depth) ptimer ] if dwell <> zero, total = total + (dwell / 60)
17:G73钻孔距离,时间计算
ptime_drill_2 # Chip Break Drill drill_length_f = abs(refht - depth) actual_drl_depth = peck1 while actual_drl_depth < drill_length_f, [ len = peck1 + peck_safe_dist ptimel len = peck_safe_dist ptimer actual_drl_depth = actual_drl_depth + peck1 ] len = (drill_length_f - actual_drl_depth) + peck_safe_dist + peck1 ptimel if initht <> refht, [ len = abs(initht - refht) len = len + abs(initht - depth) ptimer ] else, [ len = abs(refht - depth) ptimer ] if dwell <> zero, total = total + (dwell / 60)
18:G84攻丝距离,时间计算
ptime_drill_3 # Tapping drill_length_f = (abs(refht - depth)) * 2 llen = llen + drill_length_f tot_ltime = tot_ltime + ((drill_length_f / (feed / speed)) / speed) if initht <> refht, [ len = (abs(initht - refht)) * 2 ptimer ] if dwell <> zero, total = total + (dwell / 60)
19:G85,G86,G87镗孔,铰孔距离,时间计算
ptime_drill_4 # Bore, feed out, Reaming len = (abs(refht - depth)) * 2 ptimel if initht <> refht, [ len = (abs(initht - refht)) * 2 ptimer ] if dwell <> zero, total = total + (dwell / 60)
20:钻孔其他类型距离,时间计算
ptime_drill_XY # Moves between additional points sav_gcode = gcode gcode = zero ptime_calc gcode = sav_gcode
21:在psof按如下格式增加
psof #Start of file for non-zero tool number psetup
22:在ptlchg后按如下格式增加
ptlchg #Tool change ptooldata #Total ending data for tool (Path Length and Times) psetup
23:在pncoutput按如下格式增加
pncoutput #Movement output ptime_calc
24:在pdrlcommonb按如下格式增加
pdrlcommonb #Canned Drill Cycle common call, before ptime_calc
25:在pcancledc按如下格式增加
pcanceldc #Cancel canned drill cycle ptime_calc
26:在peof按如下格式增加
peof #End of file for non-zero tool ptooldata #Total ending data for tool (Path Length and Times) "( *** Path Length/Time *** )", e "( Rapid Path Lengh = ", *rlen_total, punit, ")", e "( Feed Path Length = ", *llen_total, punit, ")", e ttltime = total #Transfer TOTAL program time "( Full Cycle Time = ", ptimeout, " )", e #Program Total time output ttltime = tot_rtime "( Full Rapid Time : ", ptimeout, " )", e ttltime = tot_ltime "( Full Feed Time : ", ptimeout, " )", e
27:公英制判断
punit # System unit if met_tool$, "mm" else, "In"
申明:以上代码来自国外网站,非本人原创,为了方便大家,搬运过来,其中部分地方进行了修正。
标签: #setupcfg