summaryrefslogtreecommitdiff
path: root/configs/sim/axis/remap/rack-toolchange/nc_subroutines/rack_change.ngc
blob: 22f4199deeaef373ebd891df402bdfe4441c20b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46



o<rack_change> sub

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]
     o<tool_getput_move> call [#<_current_pocket>]  
     M62 P #<_ini[pins]lock> ; set lock pin
     G4  P #<_ini[dwell]lock_time> 
     o<tool_holder_clear_move> call
     G4 P #<_ini[dwell]mystery> ; unsure what this is for
o300 endif

; go to new tool
o<tool_getput_move> 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-6 
     G90
o400 else
     G0 Z-6
o400 endif
M65 P #<_ini[pins]lock> ; drop lock pin
G4  P #<_ini[dwell]post_unlock> 

; NB: this is reordered wrt micges patch:
; tool_holder_clear_move came after load_tool_msg
o<tool_holder_clear_move> call

; succeed by returning a positive value
o<rack_change> endsub [1]
m2