71 lines
3.4 KiB
Plaintext
Executable file
71 lines
3.4 KiB
Plaintext
Executable file
O<tool-change> SUB
|
|
|
|
#<_TravelZ> = 0 ( machine Z coordinate for travelling, typically near max Z to avoid ever hitting the work )
|
|
#<_TravelFeed> = 3000 ( feedrate used for general Z moves when avoiding G0 )
|
|
#<_ToolChangeX> = 150 ( machine X coordinate to pause at for manual tool changing )
|
|
#<_ToolChangeY> = 100 ( machine Y coordinate to pause at for manual tool changing )
|
|
|
|
O100 IF [ EXISTS[#<_ToolDidReferance>] EQ 0 ]
|
|
#<_ToolDidReferance> = 0
|
|
O100 ENDIF
|
|
|
|
O101 IF [ EXISTS[#<_IgnoreFirstTool>] EQ 0 ]
|
|
#<_IgnoreFirstTool> = 0
|
|
O101 endif
|
|
|
|
O102 IF [ #<_IgnoreFirstTool> EQ 0 ]
|
|
#<_IgnoreFirstTool> = 1
|
|
O102 ELSE
|
|
M49 (disable spindle speed and feed rate override controls)
|
|
O105 IF [ #<_ToolDidReferance> EQ 0 ]
|
|
G49 ( clear tool length compensation prior to saving state if this is first time )
|
|
O105 ENDIF
|
|
(AXIS,hide)
|
|
M6 ( do the normal M6 stuff )
|
|
M70 ( save current modal state )
|
|
|
|
M9 ( turn off coolant, will be restored on return if it was on )
|
|
M5 ( turn off spindle, cannot be on during the probe )
|
|
G21 ( use millimeters )
|
|
G30.1 ( save current position in #5181-#5183... )
|
|
#<StartPointX> = #5181
|
|
#<StartPointY> = #5182
|
|
#<StartPointZ> = #5183
|
|
G49 ( clear tool length compensation )
|
|
G90 ( use absolute positioning here )
|
|
G94 ( use feedrate in units/min )
|
|
G40 ( turn cutter radius compensation off here )
|
|
|
|
O200 IF [ #<_ToolDidReferance> EQ 0 ]
|
|
o<probe_tlo> call
|
|
(AXIS,hide)
|
|
G90 ( use absolute positioning )
|
|
#<_ToolZRef> = #5063 ( save trip point )
|
|
#<_ToolZLast> = #<_ToolZRef> ( save last tool Z position )
|
|
G53 G1 F[#<_TravelFeed>] Z[#<_TravelZ>] ( retract )
|
|
#<_ToolDidReferance> = 1 ( we have been in this section to set reference value already )
|
|
G53 G0 X[#<_ToolChangeX>] Y[#<_ToolChangeY>] ( nice place for changing tool )
|
|
(AXIS,show)
|
|
(MSG, SwitchTool )
|
|
M0 ( pause execution )
|
|
O200 ENDIF
|
|
(AXIS,show)
|
|
o<probe_tlo> call
|
|
(AXIS,hide)
|
|
G90 ( use absolute positioning )
|
|
#<_ToolZ> = #5063 ( save new tool length )
|
|
G43.1 Z[#<_ToolZ> - #<_ToolZRef>] ( set new tool length Z offset, we do this now to show operator even though it has to be set again after M72 )
|
|
#<_ToolZLast> = #<_ToolZ> ( save last tool length )
|
|
G53 G1 F[#<_TravelFeed>] Z[#<_TravelZ>] ( retract )
|
|
G53 G0 X[#<StartPointX>] Y[#<StartPointY>]
|
|
G53 G0 Z[#<StartPointZ>]
|
|
M72 ( restore modal state )
|
|
M3
|
|
G43.1 Z[#<_ToolZ> - #<_ToolZRef>] ( set new tool length Z offset )
|
|
M48 (enable spindle speed and feed rate override controls)
|
|
(AXIS,show)
|
|
O102 ENDIF
|
|
|
|
O<tool-change> ENDSUB
|
|
M2
|