o sub (DEBUG, from tool_in_spindle=# to selected_tool=#) ; ------------------------------------- ; --- Begin Initial data gathering ---- ; ------------------------------------- # = #3004 (set from probe screen fast probe feed rate) # = #3005 (set from probe screen slow probe feedrate) # = #3006 (set from probe screen traverse probe feedrate) # = #3007 (max z distance the tool travels before erroring out if not contact is made) # = #3008 (max xy distance the tool travels before erroring out if not contact is made) # = #3009 (distance the tool retracts after making contact during fast feed mode) # = #3010 (G53 distance from home to spindle nose triggering point on touch plate) # = #3011 (activates the tool diameter probe subroutine section) # = #3012 (activates the tool diameter offset position for probe subroutine section) # = #3013 (sets tool setter offset direction to move tool) # = #5410 (current tool's diameter used for offseting probe position in x axis) G92.1 (Cancel G92 offset) M50 P0 # = #5181 # = #5182 # = #5183 # = 1 # = -16 # = 0 # = [# / 2] # = [# - #] # = [# + #] # = [# - #] # = [# + #] # = # # = # # = #<_x> # = #<_y> # = #<_z> # = [#[5203 + #5220 * 20] + #5213 * #5210] ;# = #5422 ;Stores the offset of the current Z coordinate. o100 if [# EQ 1] o101 if [# EQ 0] # = # o101 else if [# EQ 1] # = # o101 else if [# EQ 2] # = # o101 else if [# EQ 3] # = # o101 endif o100 endif ; ------------------------------------- ; --- End Initial Data Gathering ---- ; ------------------------------------- ; ------------------------------------- ; --- Begin Initial Safety Checks ---- ; ------------------------------------- ; we must execute this only in the milltask interpreter ; or preview will break, so test for '#<_task>' which is 1 for ; the milltask interpreter and 0 in the UI's o110 if [#<_task> EQ 0] (debug, Task is Null) o110 return [999] o110 endif ; check we are in right mode o120 if [#<_metric_machine>] o125 if [#<_imperial>] (MSG, Auto Tool probe error: not in G21 mode ) o125 return [-3] ; indicate probe contact failure to epilog o125 endif o120 else o125 if [#<_imperial> EQ 0] (MSG, Auto Tool probe error: not in G20 mode ) o125 return [-3] ; indicate probe contact failure to epilog o125 endif o120 endif ; ------------------------------------- ; --- End Initial Safety Checks ---- ; ------------------------------------- ; ------------------------------------- ; --- Begin Physical Tool Change ---- ; ------------------------------------- G90 (set absolute coordinates) G53 G0 F[#] Z0 (move to z0 home position) o200 if [#<_current_tool> NE #] ; then move to change position G53 G0 F[#] X# Y# G53 G0 F[#] Z# o200 endif ;cancel tool offset mode G49 ; using the code being remapped here means 'use builtin behaviour' ; ie, this is not a recursive call to this program, but calls the ; un-remapped M6 processing ; That processing includes actually sending the window to the user ; to press OK when they have completed the tool change. M6 ; ------------------------------------- ; ------ End Physical Tool Change ---- ; ------------------------------------- ; ------------------------------------- ; ------ Begin Safety Checks for Tool Offset Measurement ---- ; ------------------------------------- ; ------------------------------------- ; ------ Begin Tool Offset Measurement ---- ; ------------------------------------- G90 (set absolute coordinates) G53 G1 F[#] Z0 (move to z0 home position) G53 G1 F[#] X# Y# G53 G1 F[#] Z# # = #5422 ;Stores the offset of the current Z coordinate. ;switch to relative distance mode for probe moves G91 F # G38.2 Z-[#] (fast tool probe) # = #5063 (save probe result of fast probe to parameters) G1 F[#] Z[#] (retract tool retract distance amount) o400 if [#5070 EQ 0] G90 o400 return [-3] ; indicate probe contact failure to epilog o400 endif (Slow Probe Rule, if Slow Probe FR is set to 0, Slow Probe is Bypassed) o410 if [# GT 0] (Initiate Slow Z- Probe) G91 F[#] (set probe slow feedrate) G38.2 Z-[# * 2] (slow tool probe) # = #5063 o410 endif o420 if [#5070 EQ 0] G90 o420 return [-3] ; indicate probe contact failure to epilog o420 endif (Tool Diameter Probe Mode Section, User must define this section as needed) o430 if [# EQ 1] (DEBUG, Tool Diameter Probing is Not Defined in Subroutine) o430 endif G90 (set absolute coordinates) G53 G1 F[#] Z0 (Send Spindle to home zero position) (define new tool length offset parameters) # = [ABS[# + #5063 - #]] G10 L1 P # Z [#] T # G43 H # (enable tool length offset) M50 P1 (reinstate feedrate override) (DEBUG, new tool lenght offset: #) (DEBUG, offset_z: #, spindle zero offset: #, fast probe: #, slow probe: #) o endsub [1] M2