# Post Name : MPROUTER # Product : ROUTER # Machine Name : GENERIC # Control Name : FANUC # Description : GENERIC 3-AXIS ROUTER POST # 4-axis/Axis subs. : YES (SKELETON) # 5-axis : NO # Subprograms : YES # Executable : MP v9.18 # # WARNING: THIS POST IS GENERIC AND IS INTENDED FOR MODIFICATION TO # THE MACHINE TOOL REQUIREMENTS AND PERSONAL PREFERENCE. # # -------------------------------------------------------------------------- # Revision log: # -------------------------------------------------------------------------- # Programmers Note: # CNC 02/05/03 - Update for V9.1 # CNC 03/06/03 - Updated YZ Axis agg test & Q.5001 # CNC 05/21/03 - Added toolchange type logic (ra_tc_type) for SP1 # CNC 05/28/03 - Initial post update for V9.1SP1 # CNC 06/25/03 - Added use_hd_sel # CNC 06/27/03 - Updated with new drill vars # CNC 07/17/03 - Modifications made for multi head support (up/down, offsets) # added support for axis mulitpliers for IJK (x_mult, y_mult, z_mult) # CNC 07/23/03 - Additional cleanup of mulit head support # CNC 12/18/03 - Modified toolchange logic - psof & ptlchg # CNC 03/15/04 - added mtol and chord_tol which replaces the use of vtol. # Added update to cc_pos and cutpos2 after each move. # # -------------------------------------------------------------------------- # Features: # -------------------------------------------------------------------------- # This post supports 3-Axis output and C-Axis Aggregate tool positioning # It is designed to support the features of Mastercam Mill V9. # # Aggregate tooling is supported through use of the Aggrhead C-hook. # The coordinates will be mapped to the Machine Base coordinate system # as defined in the post processor. DO NOT select the Map to machine # base option in the C-hook! The post processor will map the coordinates. # # This is a 3-Axis post, with C-Axis Aggregate support. No additional # rotary axes are supported. # # The height of the dust brushes on some machines is adjustable via an M code # Example (Mn01-Mn16) where n = spindle number. A value of 1 is the highest # or tool change position, 16 is the lowest. This feature may not used on some # machines but the Misc integer is reserved for compatibility with other posts. # # Support for drill blocks can be accomplished by selecting the "block drill" # toolpath option in Mastercam. The multi_tl C-hook will not be included in # the Version 9.1 Release. # # -------------------------------------------------------------------------- # Following Misc. Integers are used: # -------------------------------------------------------------------------- # Integers: # # mi1 - (NOT USED) # # mi2 - Absolute or Incremental positioning at top level # 0 = absolute # 1 = incremental # # mi3 - Select G28 or G30 reference point return. # 0 = G28, 1 = G30 # # mi4 - Table Selection # 0 = Both M24 # 1 = Right M23 # 2 = Left M22 # # mi6 - Select Brush Height 1-16 # 1 = Highest or (T.C.) Position # ... # 16 = Lowest # # mi7 - Program to be called from main (read once at the start of file) # 0=No # 1=Yes # # # -------------------------------------------------------------------------- # Reals: # # # -------------------------------------------------------------------------- #Canned text: # Entering cantext on a contour point from within Mastercam allows the # following functions to enable/disable. # Cantext value: # 1 = Stop = output the "M00" stop code # 2 = Ostop = output the "M01" optional stop code # 3 = Bld on = turn on block delete codes in NC lines # 4 = bLd off = turn off block delete codes in NC lines # # -------------------------------------------------------------------------- #Additional Notes: # 1) Disable 4 axis by setting the numbered question 164. to 'n'. # 2) G54 calls are generated where the work offset entry of 0 = G54, # 1 = G55, etc. # 3) Metric is applied from the NCI met_tool variable. # 4) 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. # 5) The variable 'absinc' is now pre-defined, set mi2 (Misc. Integer) for # the 'top level' absolute/incremental program output. Subprograms are # updated through the Mastercam dialog settings for sub-programs. # 6) Always avoid machining to the center of rotation with rotary axis! # 7) Transform subprograms are intended for use with G54.. workshifts. # # END_HEADER$ # # -------------------------------------------------------------------------- # Debugging and Factory Set Program Switches # -------------------------------------------------------------------------- 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 six : 6 #Define constant seven : 7 #Define constant eight : 8 #Define constant nine : 9 #Define constant c9k : 9999 #Define constant fastmode : 1 #Posting speed optimizition bug1 : 2 #0=No display, 1=Generic list box, 2=Editor 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 #Do not perform whatline branches? (leave as yes) #NEW skp_lead_flgs : 1 #Skip new lead in/lead out contour flags? bdrl_use_lead : no #Output the lead drill as drill position w/block drill use_ra_offs : yes #Override Work Offset with Aggregate Offset Register use_oal : no #Scale coordinates to tool length with Aggregates use_g8 : yes #Use G8 P1 for Fast corner (adv preview) function? use_dc : no #Output codes to raise and lower dust cover? use_tl_select : no #Use tool code string select for drill block? use_hd_select : yes #Use tool code string select for multi-heads? set_g43_vert : no #G43 Height Offset Regs set as if tool is Vertical #for all tools and Aggregates dual_table : no #Set to yes to enable misc integer option arc_planes : yes #Allow arcs in G18 and G19 planes use_brush_ht : no sextnc NC #Override NC Program extension 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 tooltable : 1 # cant_tlchng : 1 #Ignore cantext entry on move with tlchng_aft newglobal : 1 #Error checking for global variables getnextop : 1 #Build the next variable table rotaxtyp : 999 #Rotary Axis Override cutpos2 : m_one #Disable cutpos2 if not 4 axis, saves time # -------------------------------------------------------------------------- # General Output Settings # -------------------------------------------------------------------------- sub_level : 1 #Enable automatic subprogram support breakarcs : 1 #Break arcs, 0 = no, 1 = quadrants, 2 = 180deg. max 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 : 0 #Allow full circle output? 0=no, 1=yes helix_arc : 2 #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 : .005 #Length tolerance for arccheck = 1 mtol : .0001 #System Motion tolerance(replaces use of vtol),inch chord_tol : .0001 #System tolerance used in arc/line break up, inch maxfeedpm : 3000 #Limit for feed in inch/min ltol_m : .05 #Length tolerance for arccheck = 1, metric mtol_m : .0025 #System Motion tolerance(replaces use of vtol_m),metric chord_tol_m : .0025 #System tolerance used in arc/line break up, metric maxfeedpm_m : 76200 #Limit for feed in mm/min force_wcs : yes #Force WCS output at every toolchange? spaces : 0 #No. of spaces to add between fields omitseq : no #Omit sequence no. seqmax : 9999 #Max. sequence no. stagetool : 0 #0 = Do not pre-stage tools, 1 = Stage tools use_gear : 0 #Output gear selection code, 0=no, 1=yes max_speed : 18000 #Maximum spindle speed min_speed : 0 #Minimum spindle speed nobrk : no #Omit breakup of x, y & z rapid moves nobrk_sav : nobrk #Saved value progname : 1 #Use uppercase for program name tool_off : 0 #Tool off / retract tool? local_int : 0 #Local variable for multi-tool calculations tool_sel : 0 #Selector variable for multiple tool number string select head_sel : 0 #Selector variable for multiple head number string select last_result : 0 #Calculated prv_ value for modality test sav_t : 0 #Saved value for multi-tool modality test sav_h : 0 #Saved value for multi-tool modality test max_tools : 8 #Can be set up to 32 tools ( < 32 = saves time ) max_heads : 8 #Can be set up to 32 tools ( < 32 = saves time ) ang_orient : 0 ag_plane : 0 g64mode : 0 spndlno : 0 # -------------------------------------------------------------------------- # Rotary Axis Settings rot_on_x : 3 #Default Rotary Axis Orientation, See ques. 164. #0 = Off, 1 = About X, 2 = About Y, 3 = About Z rot_ccw_pos : 0 #Axis signed dir, 0 = CW positive, 1 = CCW positive index : 2 #Use index positioning, 0 = Full Rotary, 1 = Index only ctable : 5 #Degrees for each index step with indexing spindle use_frinv : 1 #Use Inverse Time Feedrates in 4 Axis, (0 = no, 1 = yes) maxfrdeg : 2000 #Limit for feed in deg/min maxfrinv : 999.99#Limit for feed inverse time frc_cinit : 1 #Force C axis reset at toolchange ctol : 225 #Tolerance in deg. before rev flag changes ixtol : .01 #Tolerance in deg. for index error frdegstp : 10 #Step limit for rotary feed in deg/min # -------------------------------------------------------------------------- # Enable Canned Drill Cycle Switches # -------------------------------------------------------------------------- usecandrill : yes #Use canned cycle for drill usecanpeck : yes #Use canned cycle for Peck usecanchip : yes #Use canned cycle for Chip Break usecantap : yes #Use canned cycle for Tap usecanbore1 : yes #Use canned cycle for Bore1 usecanbore2 : yes #Use canned cycle for Bore2 usecanmisc1 : yes #Use canned cycle for Misc1 usecanmisc2 : yes #Use canned cycle for Misc2 # -------------------------------------------------------------------------- # Common User-defined Variable Initializations (not switches!) # -------------------------------------------------------------------------- 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 cia : 0 #Formated absolute value for C incremental calculations cuttype : 0 #Cut type flag #0 = Tool Plane, 1 = Axis Subs, 2 = Polar, 3 = 4/5 axis bld : 0 #Block delete active 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 sav_frc_wcs : 0 #Force work offset flag saved toolchng : 1 #On a toolchange flag spdir2 : 1 #Copy for safe spindle direction calculation op : 0 # Selector Variable for sopnote table_sel : 0 prog_is_main : 0 spndlno_sav : 0 station_sav : 0 #Drill variables usecan : 0 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 ss_underflow : 1 canceldc : 1 drl_usecan : 0 sav_plane : 0 #Save plane when drilling sav_dgcode : 0 # drillrefx : 0 #Vector to test for initht <> refht drillrefy : 0 #Vector to test for initht <> refht drillrefz : 0 #Vector to test for initht <> refht ###ref_x : 0 ###ref_y : 0 ###ref_z : 0 #Subprogram variables mr_rt_actv : 0 #Flag to indicate if G51/G68 is active #0=Off, 1=Toolchange, 2=Subprogram call/start, G68 #3=Absolute start, both rt_csav : 0 #C saved value end_sub_mny : 0 #Many tool setting captured at transform sub end #Rotary/Index variables bsav : 0 #B saved value csav : 0 #C saved value prvcabs : 0 #Saved cabs from pe_inc_calc, #Used for rotary feed and direction calculations c_tmp : 0 #Temporary Value cdelta : 0 #Calculation for angle change rev : 0 #Calculation for deg/min sav_rev : 0 #Saved revolution counter indx_out : c9k #Rotation direction calculation fmt 16 indx_mc #Rotation direction calculation #Feedrate calculation variables frdelta : 0 #Calculation for deg/min frinv : 0 #Feedrate inverse time frdeg : 0 #Feedrate deg/min actual prvfrdeg : 0 #Feedrate deg/min actual ldelta : 0 #Calculation for deg/min, linear cldelta : 0 #Calculation for deg/min, linear and rotary circum : 0 #Calculation for deg/min ipr_type : 0 #Feedrate for Rotary, 0 = UPM, 1 = DPM, 2 = Inverse translate_err : 0 stranslate_err "ERROR- Translate to machine view must be disabled for Aggregate operations" # -------------------------------------------------------------------------- #Machine base Matrix -Top View # -------------------------------------------------------------------------- matb1 : 1 matb2 : 0 matb3 : 0 matb4 : 0 matb5 : 1 matb6 : 0 matb7 : 0 matb8 : 0 matb9 : 1 # -------------------------------------------------------------------------- #Vector Constants for Rotatary Calculations # -------------------------------------------------------------------------- aaxisx : 1 #A axis rotation vector constant aaxisy : 0 #A axis rotation vector constant aaxisz : 0 #A axis rotation vector constant baxisx : 0 #B axis rotation vector constant baxisy : 1 #B axis rotation vector constant baxisz : 0 #B axis rotation vector constant caxisx : 0 #C axis rotation vector constant caxisy : 0 #C axis rotation vector constant caxisz : 1 #C axis rotation vector constant mmtx1 : 0 #Machine mapping Matrix mmtx2 : 0 mmtx3 : 0 mmtx4 : 0 mmtx5 : 0 mmtx6 : 0 mmtx7 : 0 mmtx8 : 0 mmtx9 : 0 rmtx1 : 0 #Temporary return Matrix rmtx2 : 0 rmtx3 : 0 rmtx4 : 0 rmtx5 : 0 rmtx6 : 0 rmtx7 : 0 rmtx8 : 0 rmtx9 : 0 tmtx1 : 1 #Calculated Mapping Matrix tmtx2 : 0 tmtx3 : 0 tmtx4 : 0 tmtx5 : 1 tmtx6 : 0 tmtx7 : 0 tmtx8 : 0 tmtx9 : 1 vecx : 0 #Toolplane Normal Vector vecy : 0 vecz : 1 tvecx : 0 #Tool Axis Normal Vector tvecy : 0 tvecz : 1 xshft : 0 #Axis Shifts yshft : 0 zshft : 0 x_mult : 1 #Axis Multiplier y_mult : 1 z_mult : 1 vzerox : 0 #defined constant for vequ() vzeroy : 0 # vzeroz : 0 # vshftx : 0 #Aggregate offsets vshfty : 0 # vshftz : 0 # irotv : 0 #Temporary vector jrotv : 0 # krotv : 0 # # -------------------------------------------------------------------------- # Format statements - n=nonmodal, l=leading, t=trailing, i=inc, d=delta # -------------------------------------------------------------------------- #Default english/metric position format statements fs2 1 0.7 0.6 #Decimal, absolute, 7 place, default for initialize (:) fs2 2 0.4 0.3 #Decimal, absolute, 4/3 place fs2 3 0.4 0.3d #Decimal, delta, 4/3 place #Common format statements fs2 4 1 0 1 0 #Integer, not leading fs2 5 2 0 2 0l #Integer, force two leading fs2 6 3 0 3 0l #Integer, force three leading fs2 7 4 0 4 0l #Integer, force four leading fs2 9 0.1 0.1 #Decimal, absolute, 1 place fs2 10 0.2 0.2 #Decimal, absolute, 2 place fs2 11 0.3 0.3 #Decimal, absolute, 3 place fs2 12 0.4 0.4 #Decimal, absolute, 4 place fs2 13 0.5 0.5 #Decimal, absolute, 5 place fs2 14 0.3 0.3d #Decimal, delta, 3 place fs2 15 0.2 0.1 #Decimal, absolute, 2/1 place fs2 16 1 0 1 0n #Integer, forced output fs2 17 1^3 1^3 #Decimal, absolute # -------------------------------------------------------------------------- #String and string selector definitions for NC output # -------------------------------------------------------------------------- #Numbered question 164. string to detect Rotary axis y/n sq164 #Address string definitions strm "M" strn "N" stro "O" strp "P" srad "R" srminus "R-" sblank #Cantext string definitions (spaces must be padded here) sm00 "M00" sm01 "M01" strtextno strcantext #Transform mirror and rotate codes strns_mir_on "G51.1" #Programmable mirror image code strns_mir_off "G50.1" #Programmable mirror image cancel code strns_rot_on "G68" #Coordinate System Rotation strns_rot_off "G69" #Coordinate System Rotation Cancel # -------------------------------------------------------------------------- # Error messages # -------------------------------------------------------------------------- saxiswarn "WARNING-POST ROTARY AXIS ASSIGNMENT ('rot_on_x') OVERWRITTEN BY OPERATION" saxisoff "ERROR-POST ROTARY AXIS ASSIGNMENT ('rot_on_x') IS DISABLED" saxiserror "ERROR-INVALID ROTARY AXIS ASSIGNMENT ('rot_on_x') FOR CURRENT OPERATION" sindxerror "WARNING-INDEX ANGLE DOES NOT MATCH POST SETTING ('ctable')" stlorgerr "ERROR-TOOL ORIGIN DOES NOT MATCH CENTER OF ROTATION IN POLAR MILLING" shomeserror "ERROR WORK OFFSET USAGE DOES NOT SUPPORT TRANSFORM SUBPROGRAM" sprgnerror "ERROR-SUBPROGRAM NUMBER MATCHES THE MAIN PROGRAM NUMBER" # -------------------------------------------------------------------------- # General G and M Code String select tables # -------------------------------------------------------------------------- # Motion G code selection sg00 G0 #Rapid sg01 G1 #Linear feed sg02 G2 #Circular interpolation CW sg03 G3 #Circular interpolation CCW sg04 G4 #Dwell sgcode #Target for string fstrsel sg00 gcode2 sgcode # -------------------------------------------------------------------------- # Select work plane G code sgm17 G17 #neg one ss_underflow sg17 G17 #XY plane code sg19 G19 #YZ plane code sg18 G18 #XZ plane code sgplane #Target string fstrsel sg17 plane2 sgplane # -------------------------------------------------------------------------- #Select english/metric code sg20 G20 #Inch code sg21 G21 #Metric code smetric #Target string fstrsel sg20 met_tool smetric # -------------------------------------------------------------------------- #Select reference return code sg28 G28 #First reference point return sg30 G30 #Second reference point return sg28ref #Target string fstrsel sg28 mi3 sg28ref # -------------------------------------------------------------------------- # Cutter compensation G code selection scc0 G40 #Cancel cutter compensation scc1 G41 #Cutter compensation left scc2 G42 #Cutter compensation right sccomp #Target for string fstrsel scc0 cc_pos2 sccomp # -------------------------------------------------------------------------- # Canned drill cycle string select sg81 G81 #drill - no dwell sg81d G82 #drill - with dwell sg83 G83 #peck drill - no dwell sg83d G83 #peck drill - with dwell sg73 G73 #chip break - no dwell sg73d G73 #chip break - with dwell sg84 G84 #tap - right hand sg84d G74 #tap - left hand sg85 G85 #bore #1 - no dwell sg85d G89 #bore #1 - with dwell sg86 G86 #bore #2 - no dwell sg86d G86 #bore #2 - with dwell sgm1 G76 #misc #1 - no dwell sgm1d G76 #misc #1 - with dwell sgm2 G81 #misc #2 - no dwell sgm2d G82 #misc #2 - with dwell sgdrill #Target for string fstrsel sg81 drlgsel sgdrill # -------------------------------------------------------------------------- # Select incremental or absolute G code sg90 G90 #Absolute code sg91 G91 #Incremental code sgabsinc #Target string fstrsel sg90 absinc sgabsinc # -------------------------------------------------------------------------- # Feed mode G code selection sg94 G94 #UPM sg94d G94 #DPM, See pfcalc_deg if you use another gcode sg93 G93 #Inverse sgfeed #Target for string fstrsel sg94 ipr_type sgfeed # -------------------------------------------------------------------------- #Canned drill cycle reference height sg98 G98 #Reference at initht sg99 G99 #Reference at refht sgdrlref #Target for string fstrsel sg98 drillref sgdrlref # Drill cycle G string select # -------------------------------------------------------------------------- # Generate string for spindle sm04 M4 #Spindle reverse sm05 M3 #Spindle off *Allow spindle to 'activate' use literal M05 at toolchange sm03 M3 #Spindle forward spindle #Target for string fstrsel sm04 spdir2 spindle # -------------------------------------------------------------------------- # Coolant M code selection sm09 M9 #Coolant Off sm08 M8 #Coolant Flood sm08_1 M8 #Coolant Mist sm08_2 M8 #Coolant Tool scoolant #Target for string fstrsel sm09 coolant scoolant # -------------------------------------------------------------------------- # Table rotation direction, index sindx_cw #Rotate CW code sindx_ccw #Rotate CCW code sindx_mc #Target for string fstrsel sindx_cw indx_mc sindx_mc # -------------------------------------------------------------------------- # Table select sm24 M24 #Lock Both tables together sm23 M23 #Right (v-table) only sm22 M22 #Left (y-table) only smtable fstrsel sm24 table_sel smtable # -------------------------------------------------------------------------- #Dust cover up/down sdc_up sdc_down # -------------------------------------------------------------------------- # Contouring Mode sg64a G642 # Rounding with axial precision. sg64b G64 # Exact stop - contouring mode. sg64 fstrsel sg64a g64mode sg64 # -------------------------------------------------------------------------- # Multi-tool number output string select (supports up to 32 tools at a time) # -------------------------------------------------------------------------- stl_0a_on # Leave blank stl_0a_off # Leave blank stl_1a_on T1 # T or M-Code for tool 1 on - stl_1a_off # T or M-Code for tool 1 off - stl_2a_on T2 # T or M-Code for tool 2 on - stl_2a_off # T or M-Code for tool 2 off - stl_3a_on T3 # T or M-Code for tool 3 on - stl_3a_off # T or M-Code for tool 3 off - stl_4a_on T4 # T or M-Code for tool 4 on - stl_4a_off # T or M-Code for tool 4 off - stl_5a_on T5 # T or M-Code for tool 5 on - stl_5a_off # T or M-Code for tool 5 off - stl_6a_on T6 # T or M-Code for tool 6 on - stl_6a_off # T or M-Code for tool 6 off - stl_7a_on T7 # T or M-Code for tool 7 on - stl_7a_off # T or M-Code for tool 7 off - stl_8a_on T8 # T or M-Code for tool 8 on - stl_8a_off # T or M-Code for tool 8 off - stl fstrsel stl_0a_on tool_sel stl # -------------------------------------------------------------------------- # Multi-head number output string select # -------------------------------------------------------------------------- shd_0a_on # Leave blank shd_0a_off # Leave blank shd_1a_on T101 # T or M-Code for head 1 on - shd_1a_off # T or M-Code for head 1 off - shd_2a_on T102 # T or M-Code for head 2 on - shd_2a_off # T or M-Code for head 2 off - shd_3a_on T103 # T or M-Code for head 3 on - shd_3a_off # T or M-Code for head 3 off - shd_4a_on T104 # T or M-Code for head 4 on - shd_4a_off # T or M-Code for head 4 off - shd_5a_on T105 # T or M-Code for head 5 on - shd_5a_off # T or M-Code for head 5 off - shd_6a_on T106 # T or M-Code for head 6 on - shd_6a_off # T or M-Code for head 6 off - shd_7a_on T107 # T or M-Code for head 7 on - shd_7a_off # T or M-Code for head 7 off - shd_8a_on T108 # T or M-Code for head 8 on - shd_8a_off # T or M-Code for head 8 off - shd fstrsel shd_0a_on head_sel shd # -------------------------------------------------------------------------- # Define the gear selection code flktbl 1 3 #Lookup table definition - table no. - no. entries 40 0 #Low gear range 41 400 #Med gear range 42 2250 #Hi gear range # -------------------------------------------------------------------------- # Toolchange / NC output Variable Formats # -------------------------------------------------------------------------- fmt T 4 t #Tool No fmt 4 t2 #Tool No fmt T 7 bdrl_tool_no #Binary tool code fmt T 7 ra_head_grp #Binary tool code for multi head fmt T 4 first_tool #First Tool Used fmt T 4 next_tool #Next Tool Used fmt D 4 tloffno #Diameter Offset No fmt H 4 tlngno #Length Offset No fmt T 4 toolno #4-digit toolchng command (1=Spindle,2=NULL,3,4=Pocket) fmt T 4 spndlno #3-digit spindle number 101 or 103 fmt T 4 toolno2 #4-digit toolchng command (1=Spindle,2=NULL,3,4=Pocket) fmt T 4 spndlno2 #3-digit spindle number 101 or 103 fmt G 4 g_wcs #WCS G address fmt P 4 p_wcs #WCS P address fmt S 4 speed #Spindle Speed fmt M 4 gear #Gear range fmt M 4 brush_ht #Brush Height fmt M 4 brush_ht2 #Brush Height fmt 17 ang_orient # # -------------------------------------------------------------------------- fmt N 4 n #Sequence number fmt X 2 xabs #X position output fmt Y 2 yabs #Y position output fmt Z 2 zabs #Z position output fmt X 3 xinc #X position output fmt Y 3 yinc #Y position output fmt Z 3 zinc #Z position output fmt X 2 xa #X position output fmt Y 2 ya #Y position output fmt Z 2 za #Z position output fmt X 2 ag_home_x #X position for manual toolchange of aggregate tools fmt Y 2 ag_home_y #Y position for manual toolchange of aggregate tools fmt Z 2 ag_home_z #Z position for manual toolchange of aggregate tools fmt U 2 ua #X position output fmt V 2 va #Y position output fmt W 2 wa #Z position output fmt C 11 cabs #C axis position fmt C 14 cinc #C axis position fmt C 4 indx_out #Index position fmt R 14 rt_cinc #C axis position, G68 fmt I 3 iout #Arc center description in X fmt J 3 jout #Arc center description in Y fmt K 3 kout #Arc center description in Z fmt R 2 arcrad #Arc Radius fmt F 15 feed #Feedrate fmt P 11 dwell #Dwell fmt M 5 cantext #Canned text # -------------------------------------------------------------------------- fmt ":" 7 progno #Program number fmt ":" 7 main_prg_no #Program number fmt O 7 sub_prg_no #Program number fmt X 2 sub_trnsx #Rotation point fmt Y 2 sub_trnsy #Rotation point fmt Z 2 sub_trnsz #Rotation point # -------------------------------------------------------------------------- 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 - " 5 tnote # Note format fmt " DIA. OFF. - " 4 toffnote # Note format fmt " LEN. - " 4 tlngnote # Note format fmt " DIA. - " 1 tldia # Note format # -------------------------------------------------------------------------- # Block Drill output (tool numbers are OR'd in to bdrl_tool_no) # -------------------------------------------------------------------------- pchk_tools # Modal Tool Output Raise and/or Lower tools sequentially local_int = zero while local_int < max_tools & local_int < 32, [ last_result = and(2^local_int, sav_t) result = and(2^local_int, bdrl_tool_no) if result = zero, [ tool_off = one result = 2^local_int ] else, tool_off = zero local_int = local_int + 1 tool_sel = local_int * 2 + tool_off #Set up for boolean test to control modality if last_result <> zero, last_result = local_int * two else, last_result = local_int * two + one if tool_sel <> last_result, pbld, n, *stl, e ] if sav_t <> bdrl_tool_no, pbld, n, "M03", e sav_t = bdrl_tool_no ptools_up # Retract current tools at the end of program tool_off = one if use_tl_select, ptool_set ptools_down # Lower current tools at start of program tool_off = zero if use_tl_select, ptool_set else, pbld, n, bdrl_tool_no, 'M91', e if sav_t <> bdrl_tool_no, pbld, n, "M03", e if ra_type = three, sav_t = bdrl_tool_no ptool_set # Multi-tool output for independant raise or lower local_int = zero while local_int < max_tools & local_int < 32, [ result = and(2^local_int, bdrl_tool_no) local_int = local_int + 1 if result <> zero, [ tool_sel = local_int * 2 + tool_off pbld, n, *stl, e ] ] # -------------------------------------------------------------------------- # Multi-head output (head numbers are OR'd in to ra_head_grp) # -------------------------------------------------------------------------- pchk_heads # Modal Tool Output Raise and/or Lower tools sequentially local_int = zero while local_int < max_heads & local_int < 32, [ last_result = and(2^local_int, sav_h) result = and(2^local_int, ra_head_grp) if result = zero, [ tool_off = one result = 2^local_int ] else, tool_off = zero local_int = local_int + 1 head_sel = local_int * 2 + tool_off #Set up for boolean test to control modality if last_result <> zero, last_result = local_int * two else, last_result = local_int * two + one if head_sel <> last_result, pbld, n, *shd, e ] sav_h = ra_head_grp pheads_up # Retract current tools at the end of program tool_off = one if use_hd_select, phead_set pheads_down # Lower current tools at start of program tool_off = zero if use_hd_select, phead_set else, sav_h = ra_head_grp phead_set # Multi-tool output for independant raise or lower local_int = zero while local_int < max_heads & local_int < 32, [ result = and(2^local_int, ra_head_grp) local_int = local_int + 1 if result <> zero, [ head_sel = local_int * 2 + tool_off pbld, n, *shd, e ] ] # -------------------------------------------------------------------------- # Tool Comment / Manual Entry Section # -------------------------------------------------------------------------- ptoolcomment #Comment for tool tnote = t toffnote = tloffno tlngnote = tlngno '(', pstrtool, ')', e '(', *tnote, *toffnote, *tlngnote, *tldia, ')', 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, [ if gcode = 1006, "M00", "(", scomm, ")", e else, "(", scomm, ")", e ] # -------------------------------------------------------------------------- # Start of File and Toolchange Setup # -------------------------------------------------------------------------- psof0 #Start of file for tool zero psof psof #Start of file for non-zero tool number pcuttype toolchng = one pcom_moveb prog_is_main = not(mi7) if ntools = one, [ #skip single tool outputs, stagetool must be on stagetool = m_one !next_tool ] "%", e *progno, e "(PROGRAM NAME - ", progname, ")", e "(DATE=DD-MM-YY - ", date, " TIME=HH:MM - ", time, ")", e if translate_err = 1, [ stranslate_err, e exitpost ] pbld, n, *sgplane, *smetric, *sgabsinc, "G40", "G80", "G64", "G49", "G0", "M05", e if use_g8, pbld, n, "G8", "P1", e pbld, n, *sgabsinc, "M05", "Z0", e if prog_is_main, pbld, n, "G52", "X0.", "Y0.", "Z0.", e if ra_tc_type <> 2, [ pheads_down ] if ra_type = three, [ sav_t = bdrl_tool_no ptools_down ] if ra_type <> 3 & not(ra_tc_type), [ pbld, n, *t, "M06", e ] c_mmlt #Multiple tool subprogram call ptoolcomment comment pcan absinc = zero if prog_is_main & dual_table, pbld, n, *smtable, e if ra_type & ra_tc_type = two, [ pbld, n, "G00", "G90", "G53", *ag_home_x, *ag_home_y, e pbld, n, "M00", " (Insert Aggregate and Press Cycle Start)", e ] if ra_tc_type = 2, [ pheads_down ] pindex pcan1, pbld, n, pfwcs, *sgcode, sgabsinc, pfxout, pfyout, pcout, strcantext, e if ra_type & (ra_type <> three) & ra_tc_type, [ pbld, n, *t, e ] pbld, n, *speed, *spindle, pgear, e if use_dc, *sdc_down, e prv_feed = c9k pbld, n, "G43", *tlngno, pfzout, next_tool, [if use_brush_ht, *brush_ht], e absinc = sav_absinc pcom_movea toolchng = zero c_msng #Single tool subprogram call ptlchg0 #Call from NCI null tool change (tool number repeats) pcuttype toolchng = m_one pcom_moveb pbld, n, sg64, e c_mmlt #Multiple tool subprogram call comment pcan #if ra_type = three & use_tl_select, pchk_tools #if ra_head_grp & use_hd_select, pchk_heads pbld, n, sgplane, e pspindchng if workofs <> prv_workofs, [ sav_absinc = absinc absinc = zero pbld, n, sgabsinc, pwcs, pfxout, pfyout, pfzout, pcout, e pe_inc_calc ps_inc_calc absinc = sav_absinc ] if cuttype = zero, ppos_cax_lin if prog_is_main & dual_table, pbld, n, *smtable, e if gcode = one, plinout else, prapidout pcom_movea toolchng = zero c_msng #Single tool subprogram call ptlchg #Tool change pcuttype toolchng = one pcom_moveb pbld, n, "M01", e pbld, n, *sgabsinc, "M05", "Z0", e ptoolcomment if ra_tc_type <> 2, [ pheads_down ] if ra_type = three, [ sav_t = bdrl_tool_no ptools_down ] if ra_type <> 3 & not(ra_tc_type), [ pbld, n, *t, "M06", e ] c_mmlt #Multiple tool subprogram call comment pcan sav_absinc = absinc absinc = zero if prog_is_main & dual_table, pbld, n, *smtable, e pbld, n, sg64, e if ra_type & ra_tc_type = two, [ pbld, n, "G00", "G90", "G53", *ag_home_x, *ag_home_y, e pbld, n, "M00", " (Insert Aggregate and Press Cycle Start)", e ] if ra_tc_type = 2, [ pheads_down ] pindex pcan1, pbld, n, pwcs, *sgcode, sgabsinc, pfxout, pfyout, pcout, strcantext, e if ra_type & (ra_type <> three), [ pbld, n, *t, e ] pbld, n, *speed, *spindle, pgear, e if use_dc, *sdc_down, e pbld, n, "G43", *tlngno, pfzout, next_tool, [if use_brush_ht, *brush_ht], e absinc = sav_absinc pcom_movea toolchng = zero c_msng #Single tool subprogram call pretract #End of tool path, toolchange #if toolchng <> 1003, pbld, n, "D0", e #if ra_type = three, ptools_up sav_absinc = absinc sav_coolant = coolant coolant = zero cc_pos = zero gcode = zero pbld, n, sccomp, psub_end_mny, e pbld, n, *sg90, "G49", "M05", "Z0", e absinc = one if prv_ra_type & prv_ra_tc_type = two, [ pbld, n, "G00", "G90", "G53", *ag_home_x, *ag_home_y, e pbld, n, "M00", " (Remove Aggregate and Press Cycle Start)", e ] if toolchng = 1003, pbld, n, "G53", "X0.", "Y0.", e pbld, n, "G52", "X0.", "Y0.", "Z0.", e absinc = sav_absinc coolant = sav_coolant protretinc #Reset the C axis revolution counter if frc_cinit & rot_on_x, [ rev = zero sav_rev = zero cabs = zero csav = zero indx_out = zero if index = one, e, pindxcalc, pindex else, [ if index = zero, *cabs ] prvcabs = zero !csav, !cabs ] peof0 #End of file for tool zero peof peof #End of file for non-zero tool ptoolend toolchng = 1003 pretract comment #Remove pound character to output first tool with staged tools #if stagetool = one, pbld, n, *first_tool, e if use_g8, pbld, n, "G8", "P0", e if use_dc, *sdc_up, e pbld, n, "G17", e if prog_is_main, n, "M30", e else, n, "M99", e mergesub clearsub mergeaux clearaux "%", e pwcs #G54+ coordinate setting at toolchange sav_frc_wcs = force_wcs if sub_level, force_wcs = zero if workofs <> prv_workofs | (force_wcs & toolchng), [ if workofs < 6, [ g_wcs = workofs + 54 *g_wcs ] else, [ p_wcs = workofs - five "G54", *p_wcs ] ] force_wcs = sav_frc_wcs !workofs pfwcs sav_frc_wcs = force_wcs if sub_level, force_wcs = zero if workofs <> prv_workofs | (force_wcs & toolchng), [ if workofs < 6, [ g_wcs = workofs + 54 *g_wcs ] else, [ p_wcs = workofs - five "G54", *p_wcs ] ] force_wcs = sav_frc_wcs !workofs pgear #Find spindle gear from lookup table if use_gear = one, [ gear = frange (one, speed) *gear ] #Toolchange setup pspindchng #Spindle speed change if prv_spdir2 <> spdir2 & prv_speed <> zero, pbld, n, "M05", e if prv_speed <> speed | prv_spdir2 <> spdir2, [ if speed, pbld, n, *speed, *spindle, pgear, e ] !speed, !spdir2 pspindle #Spindle speed calculations for RPM speed = abs(ss) if maxss = zero | maxss > max_speed, maxss = max_speed #zero indicates spindle off (not a mistake) Use M03 to "Activate" spindle i.e. M3 S0 if 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 #Shut off rotary axis if, Q164. Enable Rotary Axis button? n if ucase(sq164) = strn, rot_on_x = zero if arctype = one | arctype = four, [ result = newfs(two, iout) result = newfs(two, jout) result = newfs(two, kout) ] else, [ result = newfs(three, iout) result = newfs(three, jout) result = newfs(three, kout) ] pheader #Call before start of file #progname, e if met_tool = one, #Metric constants and variable adjustments [ ltol = ltol_m mtol = mtol_m chord_tol = chord_tol_m maxfeedpm = maxfeedpm_m ] ptoolend #End of tool path, before reading new tool data !speed, !spdir2, !op_id, !ra_type, !ra_tc_type ptlchg1002 #Call at actual toolchange, end last path here if fmtrnd(lng3(ra_svecx) = zero), rot_on_x = zero #No initial direction = No C else, rot_on_x = three if ra_type | ra_head_grp & use_ra_offs, workofs = ra_offset pspindle whatline = four #Required for vector toolpaths #Brush Height: 1 = highest (t.c. position), 16 = lowest if mi6 <= zero, mi6 = one if mi6 > 16, mi6 = 16 brush_ht = spndlno + mi6 brush_ht2 = spndlno2 + mi6 if gcode = 1000, [ #Null toolchange ] else, [ #Toolchange and Start of file sav_absinc = absinc absinc = zero if gcode = 1002, [ #Actual toolchange pretract ] ag_home_x = vequ(xh) if stagetool = one, prv_next_tool = m_one prv_xia = vequ(xh) prv_feed = c9k ] pmatrix_su spndlno_sav = spndlno !lstation !t # -------------------------------------------------------------------------- # Motion NC output # -------------------------------------------------------------------------- #The variables for absolute output are xabs, yabs, zabs. #The variables for incremental output are xinc, yinc, zinc. # -------------------------------------------------------------------------- prapidout #Output to NC of linear movement - rapid if opcode = three & ra_type, [ #Force high feedrate move in drilling rather than rapid as safety gcode2 = one feed = pst_rpd_fr plinout ] else, [ pcan1, pbld, n, sgplane, `sgcode, sgabsinc, pwcs, pccdia, pxout, pyout, pzout, pcout, strcantext, scoolant, e prv_feed = c9k ] plinout #Output to NC of linear movement - feed pcan1, pbld, n, sgfeed, sgplane, `sgcode, sgabsinc, pwcs, pccdia, pxout, pyout, pzout, pcout, feed, strcantext, scoolant, e pcirout #Output to NC of circular interpolation pcan1, pbld, n, `sgfeed, sgplane, sgcode, sgabsinc, pwcs, pccdia, pxout, pyout, pzout, pcout, parc, feed, strcantext, scoolant, e pcom_moveb #Common motion preparation routines, before if toolchng = zero & ra_type = three & bdrl_tool_no <> sav_t, [ ptools_down #pchk_tools ] #adjust offsets if ra_type | ra_head_grp, [ if ra_type = three, workofs = bdrl_wrk_ofs else, workofs = ra_offset ] pshft_map pxyzcout ps_inc_calc pncoutput #Movement output pcom_moveb comment pcan if cuttype = zero, ppos_cax_lin #Toolplane rotary positioning if gcode = zero, prapidout if gcode = one, plinout if gcode > one & gcode < four, pcirout if mr_rt_actv, #Restore absolute/incremental for G51/G68 [ absinc = sav_absinc mr_rt_actv = zero ] pcom_movea pcom_movea #Common motion preparation routines, after pcan2 pe_inc_calc pdwl_spd #Call from NCI gcode 4 pspindle comment pspindchng pcan if fmtrnd(dwell), pcan1, pbld, n, *sgcode, *dwell, strcantext, e else, pcan1, pbld, n, strcantext, e pcan2 prapid #Output to NC of linear movement - rapid pncoutput pzrapid #Output to NC of linear movement - rapid Z only pncoutput plin #Output to NC of linear movement - feed pncoutput pz #Output to NC of linear movement - feed Z only pncoutput pmx #Output to NC of vector NCI pncoutput pcir #Output to NC of circular interpolation pncoutput #Pre-process rotary motion control flags pmx0 #5 axis gcode setup if gcode = 11 & drillcur = zero, [ if fr = -2, gcode = zero else, gcode = one ] # -------------------------------------------------------------------------- # Motion output components # -------------------------------------------------------------------------- pbld #Canned text - block delete if bld, '/' pfbld #Force - block delete "/" pccdia #Cutter Compensation #Force Dxx# if prv_cc_pos <> cc_pos & cc_pos, prv_tloffno = c9k sccomp if cc_pos, tloffno !cc_pos 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 pfcout #Force C axis output if index = zero & rot_on_x, [ if absinc = zero, *cabs, !cinc else, *cinc, !cabs ] pcout #C axis output if index = zero & rot_on_x & cinc, [ if absinc = zero, cabs, !cinc else, cinc, !cabs ] pindex #Index output if index = one & rot_on_x & cinc, [ pbld, n, `sindx_mc, indx_out, e !cabs, !cinc ] parc #Select the arc output if arcoutput = zero, [ #Arc output for IJK if plane2 = zero, *iout, *jout if plane2 = one, *jout, *kout if plane2 = two, *iout, *kout ] else, [ #Arc output for R if abs(sweep)<=180 | arcoutput=one, result = nwadrs(srad, arcrad) else, result = nwadrs(srminus, arcrad) *arcrad ] ppos_cax_lin #Position the rotary axis before move - rapid if index = one, pindex else, [ if index = zero & cinc & rot_on_x, [ sav_gcode = gcode gcode = zero pbld, n, `sgcode, pcout, e !cia ps_cinc_calc gcode = sav_gcode prv_feed = c9k ] ] # -------------------------------------------------------------------------- # Drilling # -------------------------------------------------------------------------- pdrill0 #Pre-process before drill call drl_plane = plane2 sav_dgcode = gcode #Capture gcode for 5 axis drill sav_plane = plane if drl_cycle < 8 & opcode <> 16, [ #Don't compare drl_plane if the cycle was off if drl_cycle_actv < one, !drl_plane #Cancel the drill cycle if drl_plane = m_one | prv_drl_plane <> drl_plane, canceldc #Use the canned drillcycle? if drl_plane = m_one, zero = vlin(drl_cycle, usecandrill) else, [ drl_usecan = vlout(drl_cycle, prv_usecandrill) drl_usecan = vlin(drl_cycle, usecandrill) ] ] !drl_plane pdrlcommonb #Canned Drill Cycle common call, before if sav_dgcode = 81, [ result = newfs (two, zinc) if drillcyc = three, drlgsel = fsg1(-ss) + drillcyc * two else, drlgsel = fsg2(dwell) + drillcyc * two drillrefx = vsub(drl_init_x, drl_ref_x) if lng3(drillrefx) > vtol, drillref = zero else, drillref = one prv_refht_a = c9k prv_refht_i = c9k prv_dwell = zero ] prv_zia = drl_init_z x = vequ(drl_depth_x) pcom_moveb feed = fr_pos comment pcan plane = drl_plane prdrlout #Drill position based on plane if drl_plane = two, pxout, pzout, pfyout else, [ if drl_plane = one, pyout, pzout, pfxout else, pxout, pyout, pfzout ] prdrlrout #R drill position if drl_plane = two, [ refht_i = drl_ref_y - drl_init_y refht_a = drl_ref_y ] else, [ if drl_plane = one, [ refht_i = drl_ref_x - drl_init_x refht_a = drl_ref_x ] else, [ refht_i = drl_ref_z - drl_init_z refht_a = drl_ref_z ] ] if absinc = zero, refht_a, !refht_i else, refht_i, !refht_a pdrill #Canned Drill Cycle pdrlcommonb pcan1, pbld, n, *sgplane, *sgdrlref, *sgdrill, prdrlout, prdrlrout, dwell, *feed, strcantext, e pcom_movea ppeck #Canned Peck Drill Cycle pdrlcommonb pcan1, pbld, n, *sgplane, *sgdrlref, *sgdrill, prdrlout, prdrlrout, *peck1, *feed, strcantext, e pcom_movea pchpbrk #Canned Chip Break Cycle pdrlcommonb pcan1, pbld, n, *sgplane, *sgdrlref, *sgdrill, prdrlout, prdrlrout, *peck1, *feed, strcantext, e pcom_movea ptap #Canned Tap Cycle pdrlcommonb result = newfs(17, feed) # Set for tapping Feedrate format pcan1, pbld, n, *sgplane, *sgdrlref, *sgdrill, prdrlout, prdrlrout, *feed, strcantext, e pcom_movea pbore1 #Canned Bore #1 Cycle pdrlcommonb pcan1, pbld, n, *sgplane, *sgdrlref, *sgdrill, prdrlout, prdrlrout, dwell, *feed, strcantext, e pcom_movea pbore2 #Canned Bore #2 Cycle pdrlcommonb pcan1, pbld, n, *sgplane, *sgdrlref, *sgdrill, prdrlout, prdrlrout, *feed, strcantext, e pcom_movea pmisc1 #Canned Misc #1 Cycle pdrlcommonb pcan1, pbld, n, *sgplane, *sgdrlref, *sgdrill, prdrlout, prdrlrout, 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, prdrlrout, 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 #Custom drill cycles 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 #Custom drill cycles 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 pcan pcan1, pbld, n, "G80", strcantext, e pcan2 plane = sav_plane # -------------------------------------------------------------------------- #Subprogram postblocks #sub_trnstyp - 0=mirror, 1=rotate, 2=scale, 3=translate #sub_trnmthd (mirror) - 0=X axis, 1=Y axis, 2=line #sub_trnmthd (rotate) - 0=tplane, 1=tplane origin only, 2=coordinates # -------------------------------------------------------------------------- psub_call_m #Call to main level, single tool psub_call_trans psub_call_mm #Call to main level, multiple tools psub_call_trans psub_call_trans #Translate level calls from toolchange, user if mi1 <= one, result = mprint(shomeserror) sav_absinc = absinc pindex #Mirror or Rotate Coord's if sub_trnstyp = zero | (sub_trnstyp = one & mr_rt_actv), [ #The original pattern is not mirrored or rotated if sub_sec_no, [ absinc = zero if sub_trnstyp, psub_rotate else, psub_mirror ] mr_rt_actv = three ] else, #Translate [ if sub_mny_t, [ if mi1 > one, absinc = zero pbld, n, *sgcode, *sgabsinc, pwcs, pfxout, pfyout, pfzout, pfcout, e pe_inc_calc ps_inc_calc ] ] absinc = sav_absinc result = nwadrs(strp, main_prg_no) if progno = main_prg_no, result = mprint(sprgnerror) pbld, n, "M98", *main_prg_no, e prv_feed = c9k #Force feed in sub psub_mirror #Mirror start code, user #Mirror Y axis if sub_trnmthd, pbld, n, *sgabsinc, strns_mir_on, *sub_trnsx, e #Mirror X axis else, pbld, n, *sgabsinc, strns_mir_on, *sub_trnsy, e psub_rotate #Rotate start code, user pbld, n, *sgcode, *sgabsinc, strns_rot_on, *sub_trnsx, *sub_trnsy, [absinc = one], *sgabsinc, *rt_cinc, e psub_st_m #Header in main level result = nwadrs(stro, main_prg_no) " ", e *main_prg_no, e #G51/G68 requires absolute position on first move if mr_rt_actv & absinc = one, [ sav_absinc = absinc absinc = zero prv_absinc = m_one prv_xabs = m_one prv_yabs = m_one ] else, pbld, n, sgabsinc, e psub_end_m #End in main level n, "M99", e prv_absinc = -1 #Reset update variables for subs at main level #Mirror or Rotate cancel, output is forced if (sub_trnstyp = zero & esub_sec_no > zero) | (sub_trnstyp = one & esub_sec_no = esub_totl_no-one & sub_trnmthd = two), [ subout = zero no_nc_out = m_one sav_absinc = absinc #Mirror cancel if sub_trnstyp = zero, [ absinc = zero pbld, n, *sgabsinc, strns_mir_off, *sub_trnsx, *sub_trnsy, e ] else, #Rotate cancel [ pbld, n, strns_rot_off, e ] absinc = sav_absinc no_nc_out = zero ] end_sub_mny = sub_mny_t psub_end_mny #End in main level for many tools sub, user #Check for coming out of xform with stage tool. if end_sub_mny & stagetool = one, [ *t end_sub_mny = zero ] psub_call_s #Call to sub level result = nwadrs(strp, sub_prg_no) sub_prg_no = sub_prg_no + 1000 #Add sub number offset if progno = sub_prg_no, result = mprint(sprgnerror) pbld, n, "M98", *sub_prg_no, e psub_st_s #Header in sub leveln result = nwadrs(stro, sub_prg_no) " ", e *sub_prg_no, e pbld, n, sgabsinc, e psub_end_s #End in sub level n, "M99", e prv_absinc = -1 # -------------------------------------------------------------------------- # 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 ] # -------------------------------------------------------------------------- # Position calculations, generally these do not need to be modified # -------------------------------------------------------------------------- pmiscint #Capture the top level absinc for subprograms if sub_level <= zero, absinc = mi2 table_sel = mi4 g64mode = mr1 #Disable cutpos2 if not 4 axis, saves time if rot_on_x = zero, cutpos2 = m_one pmatrix_su #Establish mapping matrix 'mmtx1' #Machine Base is 'matb1' tmtx1 = matt(aaxisx) tmtx1 = mmul(tmtx1,m1) rmtx1 = matt(m1) mmtx1 = mmul(rmtx1,matb1) arc_norm_x : 0 arc_norm_y : 0 arc_norm_z : 0 plane2 : 0 gcode2 : 0 cc_pos2 : 0 rev_arc : 0 pshft_map #Map coordinates #xa = vadd(x, tox) xa = vmap(x, mmtx1) if not(mill5), ua = vadd(xa, tmtx7) #UVW add toolplane normal else, ua = vmap(u,rmtx1) #Map UVW position into machine base vecx = vsub(ua, xa) vecx = vnrm(vecx) if gcode = two | gcode = three, [ #xc = vadd(xc, tox) xc = vmap(xc, mmtx1) iout = vadd(i, tox) iout = vmap(i, mmtx1) arc_norm_x = vequ(vzerox) if plane = zero, arc_norm_z = one if plane = one, arc_norm_x = one if plane = two, arc_norm_y = one arc_norm_x = vmap(arc_norm_x, mmtx1) if abs(arc_norm_z) = 1, plane2 = zero if abs(arc_norm_x) = 1, plane2 = one if abs(arc_norm_y) = 1, plane2 = two if arc_norm_x = m_one | arc_norm_y = m_one | arc_norm_z = m_one, rev_arc = one else, rev_arc = zero if plane2 <> zero & not(arc_planes) | (abs(fmtrnd(arc_norm_x)) <> 1 & abs(fmtrnd(arc_norm_y)) <> 1 & abs(fmtrnd(arc_norm_z)) <> 1), [ rev_arc = zero linarc = one redo_proc ] #prev_arc ] else, [ arc_norm_x = vequ(tmtx7) if abs(tmtx9) = 1, plane2 = zero if abs(tmtx7) = 1, plane2 = one if abs(tmtx8) = 1, plane2 = two if opcode <> 3, [ if tmtx7 = m_one | tmtx8 = m_one | tmtx9 = m_one, rev_arc = one else, rev_arc = zero ] else, [ drl_ref_x = zero drl_ref_y = zero drl_ref_z = refht drl_ref_x = vmap(drl_ref_x, mmtx1) if abs(fmtrnd(tmtx9)) <> 1 & abs(fmtrnd(tmtx7)) <> 1 & abs(fmtrnd(tmtx8)) <> 1, plane2 = m_one ] gcode2 = gcode cc_pos2 = cc_pos ] prev_arc prev_arc #rev_arc gcodes and cutter compensation if rev_arc, [ if gcode = 2 | gcode = 3, gcode2 = 5 - gcode else, gcode2 = gcode if cc_pos = 1 | cc_pos = 2, cc_pos2 = 3 - cc_pos else, cc_pos2 = cc_pos ] else, [ gcode2 = gcode cc_pos2 = cc_pos ] pmotion_su #Motion Setup (Set brklinestype & linarc) brklinestype = zero linarc = zero if rot_on_x, [ if cuttype = one, linarc = one #Axis subs if cuttype = two, #Polar [ brklinestype = rotary_axis + three linarc = one ] ] pcuttype #Determine the cut type #cuttype (0 = Tool Plane, 1 = Axis Subs, 2 = Polar, 3 = 4/5 axis) cuttype = rotary_type if cuttype = three, cuttype = zero if mill5, [ if rot_on_x = zero, result = mprint(saxisoff) cuttype = three ] if rotary_axis, [ if rotary_axis <> rot_on_x, result = mprint(saxiswarn) rot_on_x = rotary_axis ] #Check for Tool Origin in Polar Milling if cuttype = two & (tox | toy | toz), result = mprint(stlorgerr) #Transform Rotate, set mr_rt_actv if user selected 'coordinates' if sub_trnstyp = one & sub_trnmthd = two, [ #Calculate the rotation incremental angle for G68 rt_csav = atan2(sub_m2, sub_m1) rt_cinc = prv_rt_csav - rt_csav while rt_cinc > 180, rt_cinc = rt_cinc - 360 while rt_cinc < -180, rt_cinc = rt_cinc + 360 if rot_ccw_pos = one, rt_cinc = -rt_cinc !rt_csav if sub_sec_no, mr_rt_actv = two else, mr_rt_actv = one ] else, mr_rt_actv = zero pfcalc_u_min pmotion_su pxyzcout #Map coordinates if rot_on_x, [ if cuttype = zero, pxyzcout0 #Toolplane Positioning if cuttype = one, pxyzcout1 #Axis Substitution if cuttype = two, pxyzcout2 #Polar Conversion if cuttype = three, pxyzcout3 #Simulatneous 4 axis (Multi-axis) if rot_ccw_pos = one, csav = -csav if mr_rt_actv <> two, [ pcoutrev if index = one, pindxcalc pfcalc ] else, feed = fr_pos ] else, feed = fr_pos xabs = xa * x_mult yabs = ya * y_mult zabs = za * z_mult iout = iout * x_mult jout = jout * y_mult kout = kout * z_mult pxyzcout0 #Toolplane Positioning pxyzcout3 pxyzcout1 #Axis substitution #Axis subs not supported pxyzcout2 #polar interpolation #Polar not supported pxyzcout3 #Multisurf rotary axis motion & toolplane if ra_type = 0 | fmtrnd(lng3(ra_svecx) = zero), [ #If you're not using the C-hook... #your not getting C-Axis! csav = zero !cabs, !cinc ] else, [ if fmtrnd(vecz) = one, [ c_tmp = atan2(m2, m1) xshft = vequ(vzerox) ] else, [ csav = atan2(-ra_svecy, -ra_svecx) ptfixx = vequ(vzerox) axisx = vequ(caxisx) tvecx = rotv(-csav, vecx) csav = atan2(tvecy, tvecx) axisx = vequ(caxisx) c_tmp = csav csav = atan2(vecy, vecx) irotv = rotv(-csav, vecx) bsav = atan2(irotv, krotv) #Apply tool length #(G43 is set with tool in Vertical for CA Head) xshft = vequ(vzerox) if use_oal, zshft = tl_oal axisx = vequ(caxisx) axisx = rotv(csav, baxisx) ptfixx = vsub(xa, xshft) xa = rotp(bsav, xa) if set_g43_vert = zero, za = za + zshft ] csav = c_tmp ] pcoutrev #Rotary axis revolution calculation (Modify for wind-up) cdelta = csav - prv_csav while abs(cdelta) > ctol, #If motion exceeds ctol, add wind-up [ if cdelta > zero, [ rev = rev - one cdelta = cdelta - 360 ] else, [ rev = rev + one cdelta = cdelta + 360 ] ] if cuttype <> one, cabs = rev * 360 + csav else, cabs = sav_rev * 360 + csav !csav pindxcalc #Index move calculations, direction is shortest #Check if in tolerance cdelta = frac(abs(csav)/ctable) if cdelta > ixtol & cdelta < 1-ixtol, result = mprint(sindxerror) cdelta = prvcabs - cabs #Phase shift delta 10 revolutions, check odd/even if frac(int((cdelta + 3600)/180)/two), indx_mc = one else, indx_mc = zero #Set range 0-360 indx_out = csav while indx_out < 0, indx_out = indx_out + 360 while indx_out > 360, indx_out = indx_out - 360 #Feedrate calculations pfcalc #Feedrate calculations, gcode 0 does not evaluate if gcode <> zero, [ if fmtrnd(cabs) = prvcabs | index <> zero, pfcalc_u_min else, [ if cuttype = one & (cutpos2 <= one | cutpos2 = four), pfcalc_u_min else, pfclc_deg_inv ] if ipr_type <> prv_ipr_type, prv_feed = c9k ] pfcalc_u_min #Feedrate unit/min ipr_type = zero feed = fr_pos if feed > maxfeedpm, feed = maxfeedpm prvfrdeg = feed pfclc_deg_inv #Feedrate deg/min circum = zabs * two * pi if circum = zero, circum = c9k #Don't allow Zero ldelta = sqrt((xabs-prv_xabs)^2+(yabs-prv_yabs)^2+(zabs-prv_zabs)^2) cdelta = ((abs(cabs - prvcabs))/360)*circum if ldelta = zero, cldelta = cdelta else, cldelta = sqrt(cdelta^two + ldelta^two) if cldelta = zero, cldelta = c9k if use_frinv, [ #Feedrate inverse calculation ipr_type = two prv_feed = c9k #Always force feed frinv = abs(fr_pos/cldelta) if frinv > maxfrinv, frinv = maxfrinv feed = frinv ] else, [ #Feedrate deg/min control and calculation ipr_type = zero #Change to ipr_type = one to force new DPM frdeg = abs(cdelta/cldelta) * abs(fr_pos * (360/circum)) if abs(frdeg - prvfrdeg) > frdegstp | ipr_type <> prv_ipr_type, [ #Control output of frdeg prvfrdeg = frdeg feed = frdeg ] if frdeg > maxfrdeg, feed = maxfrdeg ] #Incremental calculations ps_inc_calc #Incremental calculations, start xia = fmtrnd(xabs) yia = fmtrnd(yabs) zia = fmtrnd(zabs) xinc = vsub (xia, prv_xia) ps_cinc_calc ps_cinc_calc #Incremental calculations, start rotary cia = fmtrnd(cabs) cinc = cia - prv_cia pe_inc_calc #Incremental calculations, end prvcabs = fmtrnd(cabs) #Avoid updating until called explicitly !xia, !yia, !zia, !cia !x, !y, !z, !cc_pos, !cutpos2 pwrtt #if t >= 1, ptoolcomment if ra_type <> 0 & ra_type <> 3, [ if ra_translated = 1, translate_err = 1 ] pparameter if prmcode = 20007, [ #Reinitialize Vars before parameter read tl_min = 0 #Place Holder 1 (Min dia for plunge) tl_flen = 0 #Place Holder 2 (Flute Length) tl_oal = 0 #Overall Length (Finally, this is the one I want) tl_min = rpar(sparameter, 3) #Get OAL until it becomes a variable ] #20007 tl_min : 0 #Place Holder 1 (Min dia for plunge) tl_flen : 0 #Place Holder 2 (Flute Length) tl_oal : 0 #Overall Length (Finally, this is the one I want) # -------------------------------------------------------------------------- # Numbered questions for Mastercam -- Used by Router 9.1 # -------------------------------------------------------------------------- 38. Rapid feedrate? 1200.0 76. Name of associated CFG file? T 400. Name of associated CFG file? T 1538. Rapid feedrate (metric)? 10000.0 80. Communications port number for receive and transmit (1 or 2) ? 2 81. Data rate (110,150,300,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 88. Echo keyboard to screen in terminal emulation? n 89. Strip carriage returns? N 90. Drive and subdirectory for NC files? 91. Name of executable post processor? MP 92. Name of reverse post processor? RP 93. Reverse post PST file name? RPFAN 100. Number of places BEFORE the decimal point for sequence numbers? 3 101. Number of places AFTER the decimal point for sequence numbers? 0 103. Maximum spindle speed? 18000 107. Average time for tool change (seconds)? 2.0 159. Show first and last position as fully compensated in simulation? n #110. Default tool library? TOOLS.TL8 161. Enable Home Position button? y 162. Enable Reference Point button? y 163. Enable Misc. Values button? y 164. Enable Rotary Axis button? y 165. Enable Tool Plane button? y 166. Enable Construction Plane button? y 167. Enable Tool Display button? y 168. Check tplane during automatic work origin creation? y # -------------------------------------------------------------------------- # Default Miscellaneous Real Values # -------------------------------------------------------------------------- 201. Default Contour Mode (0=G642,1=G64) (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 # -------------------------------------------------------------------------- # Default Miscellaneous Real Values (METRIC) # -------------------------------------------------------------------------- 1601. Default miscellaneous real variable 1 (mr1) (metric)? 0.0 1602. Default miscellaneous real variable 2 (mr2) (metric)? 0.0 1603. Default miscellaneous real variable 3 (mr3) (metric)? 0.0 1604. Default miscellaneous real variable 4 (mr4) (metric)? 0.0 1605. Default miscellaneous real variable 5 (mr5) (metric)? 0.0 1606. Default miscellaneous real variable 6 (mr6) (metric)? 0.0 1607. Default miscellaneous real variable 7 (mr7) (metric)? 0.0 1608. Default miscellaneous real variable 8 (mr8) (metric)? 0.0 1609. Default miscellaneous real variable 9 (mr9) (metric)? 0.0 1610. Default miscellaneous real variable 10 (mr10) (metric)? 0.0 # -------------------------------------------------------------------------- # Enable/Disable Miscellaneous Real Variable switches # -------------------------------------------------------------------------- 1611. Enable miscellaneous real variable 1? y 1612. Enable miscellaneous real variable 2? y 1613. Enable miscellaneous real variable 3? y 1614. Enable miscellaneous real variable 4? y 1615. Enable miscellaneous real variable 5? y 1616. Enable miscellaneous real variable 6? y 1617. Enable miscellaneous real variable 7? y 1618. Enable miscellaneous real variable 8? y 1619. Enable miscellaneous real variable 9? y 1620. Enable miscellaneous real variable 10? y # -------------------------------------------------------------------------- # Default Miscellaneous Integer Values # -------------------------------------------------------------------------- 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 304. Table Selection [0=Both,1=Right,2=Left] (mi4)? 0 305. Miscellaneous integer variable 5 (mi5)? 0 306. Brush Height [1-16] (mi6)? 1 307. Program to be called from Main [0=No,1=Yes] (mi7)? 0 308. Miscellaneous integer variable 8 (mi8)? 0 309. Miscellaneous integer variable 9 (mi9)? 0 310. Miscellaneous integer variable 10 (mi10)? 0 # -------------------------------------------------------------------------- # Enable/Disable Miscellaneous Integer Variable switches # -------------------------------------------------------------------------- 1621. Enable miscellaneous integer variable 1? y 1622. Enable miscellaneous integer variable 2? y 1623. Enable miscellaneous integer variable 3? y 1624. Enable miscellaneous integer variable 4? y 1625. Enable miscellaneous integer variable 5? y 1626. Enable miscellaneous integer variable 6? y 1627. Enable miscellaneous integer variable 7? y 1628. Enable miscellaneous integer variable 8? y 1629. Enable miscellaneous integer variable 9? y 1630. Enable miscellaneous integer variable 10? y # -------------------------------------------------------------------------- # Configuration File association parameters (default is "y") # -------------------------------------------------------------------------- 401. Read SYSTEM COLORS section? y 402. Read ALLOCATIONS section? y 403. Read TOLERANCES section? y 404. Read DATA PATHS section? y 405. Read COMMUNICATIONS section? y 406. Read DRAFT SETTINGS section? y 407. Read MISCELLANEOUS section? y 408. Read NC SETTINGS section? y 409. Read DIALOG SCRIPTS section? y 410. Read DESIGN SETTINGS section? y 411. Read PLOTTER SETTINGS section? y 412. Read ALT-KEY ASSIGNMENTS section? y 413. Read CAD section? y 414. Read START/EXIT section? y 415. Read SCREEN section? y 416. Read FILE NAMES section? y 1500. Chook to execute from 'Misc. values' button? 1501. Insert parameter information in the ascii NCI? n 1502. Write operation information to binary file (.ops)? n 1503. Write transform operation transform info to binary (.ops) file (0,1,2)? 0 1520. Display a warning when cutter compensation in control simulation finds an error? n 1521. Number of controller look-ahead blocks for CDC in control? 2 1530. Ignore work offset numbers when processing subprograms? y 1531. Ignore contour flags when processing subprograms? y # Do NOT manually change the answer for Q.1999 ! 1999. Product major version number that post supports? 9 3001. Machine acceleration? 2 3002. timing size? .1 5001. Name of head definition file?