o sub (we change feed, metric/in and potentially G90) (so record current modal state) (M73 is not useful here because it reverts G43 on return too) # = #<_metric> # = #<_absolute> # = #<_feed> M73 (auto-restore modal settings on return) ;(print, rack_change: loaded tool=#<_current_tool> current pocket: #<_current_pocket>) ;(print, rack_change: selected tool=#<_selected_tool> selected pocket: #<_selected_pocket>) ; unload previous tool o300 if [#<_current_pocket> GT 0] G53 Z0 o call [#<_current_pocket>] G53 X6.25 G53 Z-60.3 G4 P0.5 G53 X3.4 M62 P #<_ini[pins]lock> ; set lock pin G53 Z-60.35 G4 P #<_ini[dwell]lock_time> G53 Z0 o call G4 P #<_ini[dwell]mystery> ; unsure what this is for o300 endif ; go to new tool o call [#<_selected_pocket>] M64 P #<_ini[pins]lock> ; set lock pin M64 P #<_ini[pins]flush> ; set flush pin G4 P #<_ini[dwell]new_tool> M65 P #<_ini[pins]flush> ; drop flush pin ; the purpose of this move is unclear to me ; micges - please explain! o400 if [#<_absolute>] G91 G0 Z-60 G90 o400 else G0 Z-60 o400 endif M65 P #<_ini[pins]lock> ; drop lock pin G4 P #<_ini[dwell]post_unlock> g53 g0 z-61 ; NB: this is reordered wrt micges patch: ; tool_holder_clear_move came after load_tool_msg o call ; tool changed - move to toolsensor g53 g0 X #<_ini[toolsensor]x> Y #<_ini[toolsensor]y> g53 g0 Z #<_ini[toolsensor]z> ; probe tool length M64 P #<_ini[pins]probing> ; turn on probing led F #<_ini[toolsensor]probefeed> G91 (relative mode) G38.2 Z #<_ini[toolsensor]maxprobe> G10 L20 P1 Z32.050 ; 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 O500 if [[#<_task> GT 0] and [#5070 EQ 0]] O call [#] [#] [#] O500 return [-2] ; indicate probe contact failure to epilog O500 endif ; see wether this was the reference tool: M66 P #<_ini[pins]reftool> L0 O600 if [#5399 EQ 1] #1000=#5063 (save reference tool length) M68 E #<_ini[pins]reflen> Q #1000 (print,reference length is #1000) O600 else g43.1 z[#5063-#1000] (set new tool offset) M68 E #<_ini[pins]currlen> Q [#5063-#1000] (print,new length is #5063) O600 endif M65 P #<_ini[pins]probing> ; drop probing led M65 P #<_ini[pins]enable> ; disable table G90 (absolute) ; move back to toolchange position: z, then xy g53 g0 Z #<_ini[change_position]z> g53 g0 X #<_ini[change_position]x> Y #<_ini[change_position]y> ; restore g20/21, g90/g91, feed O call [#] [#] [#] ; succeed by returning a positive value o endsub [1] m2