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

51 lines
1.4 KiB
Plaintext

o<m12> sub
; Move tool carousel CCW Parameter P number of steps
; Without parameter one step CCW.
; Parameter #3989 is used to track if the carousel is homed (M13) (volatile)
; Parameter #3990 is used to track the current tool pocket (persistently)
; #<number_of_pockets>: The number of pockets in the ATC is automaticity pulled from the INI via #<_ini[atc]pockets>
(PRINT, o<m12> P#<p>)
o100 if [#3989 NE 1]
(PRINT, atc not homed, homing)
M13
o100 endif
; default to a 12 pocket ATC (matching DynATC Widget behaviour), then update based on INI settings
#<number_of_pockets> = 12
o110 if [EXISTS[#<_ini[atc]pockets>]]
#<number_of_pockets> = #<_ini[atc]pockets>
o110 endif
o120 if [EXISTS[#<p>]]
#<steps_to_move> = #<p>
o120 else
#<steps_to_move>=1
(tells the atc widget move 1 step reverse)
o120 endif
(tells the atc widget how many steps to move and start moving reverse)
(DEBUG, EVAL[vcp.getWidget{"dynatc"}.rotate{#<steps_to_move>, "ccw"}])
M64 P3 ; Move atc motor REV
o130 do
M66 P4 L1 Q3 ; wait for rising edge on rotation index
o131 if [#5399 LT 0]
M65 P3 ; Stop atc motor
(abort, Failed to get rotation index)
o131 endif
#3990 = [[[#3990-2] MOD #<number_of_pockets>]+1] ; Pocket is no.1-#<number_of_pockets>
#<steps_to_move> = [#<steps_to_move>-1]
o130 while [#<steps_to_move> GT 0]
M65 P3 ; Stop motor
#<_my_current_pocket> = #3990
(PRINT, o<m12> endsub)
o<m12> endsub [1]
M2