If IsLoading() Then 'Do Nothing, program loading Else ' Dim Variables Dim Num_Tools As Integer Dim CW_Steps_Per_Tool As Integer Dim CCW_Steps As Integer Dim HoldingDRO As Integer Dim Requested_Tool As Integer Dim Current_Tool As Integer Dim CW_Feed As Integer Dim CCW_Feed As Integer 'Dim moves As Integer 'Dim total_move As Integer ' set up some vars Num_Tools = 6 CW_Move_Per_Tool = 360/Num_Tools CCW_Move = 10 HoldingDRO = 1050 Requested_Tool = GetSelectedTool() Current_Tool = GetCurrentTool() CW_Feed = 8000 CCW_Feed = 2000 Current_Feed = GetOEMDRO(818) ' start tool change Message ("Requested Tool No=" & Requested_Tool) If Requested_Tool > Num_Tools Then Message "Requested Tool No. too high, program stopped." Code "M30" End End If If Requested_Tool < 1 Then 'Message "Requested Tool No. too low, program stopped." Code "M30" End End If If Requested_Tool = Current_Tool Then ' do nothing Else ' lets do some changing If Requested_Tool > Current_Tool Then moves = Requested_Tool - Current_Tool If Requested_Tool < Current_Tool Then moves = Num_Tools - Current_Tool + Requested_Tool total_move = (moves * CW_Move_Per_Tool)+(CCW_Move/2) 'Move to safe position Code "G0 G53 Z-1 X-.25" 'Pause for 1/2 second Code "G04 P0.5" Code "G91 G94" 'incremental & Feed per minute Code "G01 A" & total_move & " F" & CW_Feed Code "G01 A-" & CCW_Move & " F" & CCW_Feed While IsMoving() sleep(10) Wend SetCurrentTool Requested_Tool SetUserDRO HoldingDRO, Requested_Tool Code "G90" ' back to absolute movement Code "F" & Current_Feed End If End If ' end of tool change