3040T/tool-change.ngc
2025-07-08 09:47:25 +02:00

98 lines
5.8 KiB
Plaintext

O<tool-change> SUB
#<_UseInches> = 0 ( set to 1 to use inches here, or 0 to use millimeters; should match units on tool.tbl dimensions )
#<_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 )
#<_ProbeX> = 9.5 ( machine X coordinate of switch/touch-off plate )
#<_ProbeY> = 24.5 ( machine Y coordinate of switch/touch-off plate )
#<_ProbeFastZ> = -20 ( machine Z coord to move to before starting probe, longest tool should not touch switch at this Z )
#<_ProbeMinZ> = -70 ( machine Z coord to stop probe, shortest tool must touch switch at this Z, must be > min Z )
#<_ProbeRetract> = 0.5 ( small distance to retract before approaching switch/touch-off plate second time )
#<_ProbeFastFeed> = 3000 ( feed rate for moving to _ProbeFastZ )
#<_ProbeFeed1> = 750 ( feed rate for touching switch/touch-off plate first time )
#<_ProbeFeed2> = 3 ( feed rate for touching switch/touch-off plate second time )
#<_ToolChangeX> = 100 ( machine X coordinate to pause at for manual tool changing )
#<_ToolChangeY> = 100 ( machine Y coordinate to pause at for manual tool changing )
#<_MistOnDuringProbe> = 0 ( set to 1 for mist, or 2 for coolant, or 0 for nothing during probing, to clear switch of swarf )
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 )
G[21 - #<_UseInches>] ( use inches or millimeters as required here, units will be restored on return )
G30.1 ( save current position in #5181-#5183... )
G49 ( clear tool length compensation )
G90 ( use absolute positioning here )
G94 ( use feedrate in units/min )
G40 ( turn cutter radius compensation off here )
G53 G1 F[#<_TravelFeed>] Z[#<_TravelZ>] ( go to high travel level on Z )
O200 IF [ #<_ToolDidReferance> EQ 0 ]
G53 G0 X[#<_ProbeX>] Y[#<_ProbeY>] ( to probe switch )
G53 G1 F[#<_ProbeFastFeed>] Z[#<_ProbeFastZ>]( move tool closer to switch -- we shouldn't hit it )
G54 G1 F[#<_ProbeFeed1>] G91 ( use relative positioning )
O103 IF [ #<_MistOnDuringProbe> EQ 1 OR #<_MistOnDuringProbe> EQ 2 ]
M[7 + #<_MistOnDuringProbe> - 1] ( turn on mist/coolant )
O103 ENDIF
G38.2 Z[#<_ProbeMinZ> - #<_ProbeFastZ>] F[#<_ProbeFeed1>] ( trip switch slowly )
G0 Z[#<_ProbeRetract>] ( go up slightly )
G38.2 Z[#<_ProbeRetract>*-1.25] F[#<_ProbeFeed2>] ( trip switch very slowly )
M9 ( turn off mist )
G90 ( use absolute positioning )
#<_ToolZRef> = #5063 ( save trip point )
#<_ToolZLast> = #<_ToolZRef> ( save last tool Z position )
G53 G1 F[#<_TravelFeed>] Z[#<_TravelZ>] ( return to safe level )
#<_ToolDidReferance> = 1 ( we have been in this section to set reference value already )
G53 G0 X[#<_ToolChangeX>] Y[#<_ToolChangeY>] ( nice place for changing tool )
(MSG, SwitchTool )
M0 ( pause execution )
O200 ENDIF
G53 G0 X[#<_ProbeX>] Y[#<_ProbeY>] ( to high place directly over switch )
G53 G1 F[#<_ProbeFastFeed>] Z[#<_ProbeFastZ>]( move tool closer to switch -- we shouldn't hit it )
G54 G1 F[#<_ProbeFeed1>] G91 ( use relative positioning )
O104 IF [ #<_MistOnDuringProbe> EQ 1 OR #<_MistOnDuringProbe> EQ 2 ]
M[7 + #<_MistOnDuringProbe> - 1] ( turn on mist/coolant )
O104 ENDIF
G38.2 Z[#<_ProbeMinZ> - #<_ProbeFastZ>] F[#<_ProbeFeed1>] ( trip switch slowly )
G4 P0.1
G0 Z[#<_ProbeRetract>] ( go up slightly )
G38.2 Z[#<_ProbeRetract>*-1.25] F[#<_ProbeFeed2>] ( trip switch very slowly )
M9 ( turn off mist )
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 G0 Z[#<_TravelZ>] ( return to safe level )
G53 G0 X[#5181] Y[#5182] ( return to saved position )
G53 G0 Z[#5183]
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