(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 ; #: The number of pockets the ATC platter has, This is user set in the INI file via #<_ini[atc]pockets> o sub (PRINT, o) # = #1 ; this is the value form the TOOL tab # = #3014 ; default to a 12 pocket ATC (matching DynATC Widget behaviour), then update based on INI settings # = 12 o101 if [EXISTS[#<_ini[atc]pockets>]] # = #<_ini[atc]pockets> o101 endif #10 = 0 #11 = 0 ; 1 if tool is already stored in carousel o110 while [#10 LT #] #10 = [#10+1] o120 if [# 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# G43 H# #3991 = # o130 endif o140 if [# EQ #] S0 M5 o140 endif o call o endsub M2 (end program)