``` o sub ; Move tool carousel CW Parameter P number of steps ; Without parameter one step CW. ; Parameter #5170 is used to track the current tool pocket (persistently) (print, o P#

) M112 P#

O100 if [EXISTS[#

]] # = #

O100 else #=1 O100 endif O110 if [#5171 NE 1] (print, atc not homed, homing) M13 O110 endif M64 P3 ; Move atc motor FWD O120 do M66 P4 L1 Q3 ; wait for falling edge on rotation index O130 if [#5399 LT 0] (abort, failed to get rotation index) M65 P3 ; Stop atc motor O130 endif #5170 = [[[#5170-2] MOD 12]+1] ;Pocket is no.1-12 # = [#-1] O120 while [# GT 0] M65 P3 ; Stop motor #<_my_current_pocket> = #5170 o endsub [1] M2