Files
probe-basic-sim/configs/atc_sim/macros_sim/load_spindle_safety_2.ngc
2025-12-14 18:29:18 +01:00

49 lines
1.5 KiB
Plaintext

(author: Chris P)
(version: 0.2)
(date: 06/27/24)
(load tool in spindle safety macro)
; This is called form the Tool page
; Parameter #3991 is used to track the current tool loaded it in the spindle (persistently)
; Parameters #4001 to #4024 are used to track which tool is in which pocket (persistently)
; Parameter #4000 is not populated just used in the maths to calculate the above numbers
; #<number_of_pockets>: The number of pockets the ATC platter has, This is user set in the INI file via #<_ini[atc]pockets>
o<load_spindle_safety_2> sub
(PRINT, o<load_spindle_safety_2>)
#<load_spindle_tool_number_2> = #1 ; this is the value form the TOOL tab
#<probe_tool_number> = #3014
; default to a 12 pocket ATC (matching DynATC Widget behaviour), then update based on INI settings
#<number_of_pockets> = 12
o101 if [EXISTS[#<_ini[atc]pockets>]]
#<number_of_pockets> = #<_ini[atc]pockets>
o101 endif
#10 = 0
#11 = 0 ; 1 if tool is already stored in carousel
o110 while [#10 LT #<number_of_pockets>]
#10 = [#10+1]
o120 if [#<load_spindle_tool_number_2> EQ #[4000 + #10]]
(DEBUG, the tool you are trying to load is already stored in carousel pocket %d#10)
#11 = 1
o120 endif
o110 endwhile
o130 if [#11 EQ 0]
M61 Q#<load_spindle_tool_number_2> G43 H#<load_spindle_tool_number_2>
#3991 = #<load_spindle_tool_number_2>
o130 endif
o140 if [#<load_spindle_tool_number_2> EQ #<probe_tool_number>]
S0 M5
o140 endif
o<program_coolant> call
o<load_spindle_safety_2> endsub
M2 (end program)