'Sub Main()Dim x,y,z,a,b,cDim OldTool,NewTool,tool,MaxToolNum,ToolDown,ToolUpŁ¬ToolSafeDim Xpos,YPos, ZPosDim ToolYaxisAdd, ToolxaxisAddDim BrushWaitTime,ToolReleaseWaitTime,ToolClampWaitTime, aironwaittimeCode "g20 g50 g53"OldTool = GetOEMDRO (1200) 'Tool In spindle DRO You must add this to your settings screenx = GetToolChangeStart( 0 )y = GetToolChangeStart( 1 )z = GetToolChangeStart( 2 )a = GetToolChangeStart( 3 )b = GetToolChangeStart( 4 )c = GetToolChangeStart( 5 )tool = GetSelectedTool()NewTool = toolMaxToolNum = 8                         'Max number off tools for the changerToolSafe   = -1          'Tool Safe PositionToolUp     = -12          '-1.0'Z Hieght to Rapid from tool to toolSpd   = 2000          '10000'speedspd2 = 400ToolxaxisAdd = 3        '100'Y Avoid Position Add'newtool = 1'*********wait for air on signal**************AirOnWaitTime = 0While Not IsActive(Input1) 'OEM INPUT1Code "G4 P0.1"While IsMoving()WendIf aironWaitTime > 5 Then    DoOEMBUTTON(1021)    Message "Air Pressure On Timeout"    Exit Sub End IfAironWaitTime = aironWaitTime +1   Wend'End of wait for air on signalMessage "TOOL CHANGE"If GetOEMLED(11) Then     Message  "Spindle is ON"    Exit Sub End If  If NewTool = OldTool Then    Message "No Tool Change, tool loaded already"    Exit SubEnd If'------------------------------------------'    Brush Control'------------------------------------------DeActivateSignal(Output2)Message "Wait for Brush Position Limit Signal "BrushWaitTime = 0While IsActive(Input4)Code "G4 P0.1"While IsMoving()WendIf BrushWaitTime > 25 Then    DoOEMBUTTON(1021)    Message"Brush Wait OverTime"    Exit Sub End IfBrushWaitTime = BrushWaitTime +1   Wend'---------------------tool change code----------------------'-------------------------------------------Message"Tool Change"While NewTool > MaxToolNumNewTool = Question ("Enter New Tool Number up to " & MaxToolNum)WendCode "G00 G53 Z" & ToolSafe & "F" & spd2While IsMoving()Wend'---brush wait--While IsActive(Input4)Code "G4 P0.1"While IsMoving()WendIf BrushWaitTime > 25 Then    DoOEMBUTTON(1021)    Message"Brush Wait OverTime"    Exit Sub End IfBrushWaitTime = BrushWaitTime +1   Wend'---brush waitCall MovePos(OldTool)While IsMoving()WendCode "G01 G53 F" & Spd &"X" & XPos - ToolxaxisAdd & "Y" & YPos While IsMoving()WendCode "G4 P0.1"While IsMoving()WendCode "G4 P0.5"While IsMoving()Wend'---brush wait--While IsActive(Input4)Code "G4 P0.1"While IsMoving()WendIf BrushWaitTime > 25 Then    DoOEMBUTTON(1021)    Message"Brush Wait OverTime"    Exit Sub End IfBrushWaitTime = BrushWaitTime +1   Wend'---brush waitCode "G0 G53 Z" & ZPos & "F" & spd2Code "G4 P.75"While IsMoving()Wend'---brush wait--While IsActive(Input4)Code "G4 P0.1"While IsMoving()WendIf BrushWaitTime > 25 Then    DoOEMBUTTON(1021)    Message"Brush Wait OverTime"    Exit Sub End IfBrushWaitTime = BrushWaitTime +1   Wend'---brush waitCode "G01 G53 x" & xPos & "F" & Spd Code "G4 P.75"While IsMoving()Wend'---brush wait--While IsActive(Input4)Code "G4 P0.1"While IsMoving()WendIf BrushWaitTime > 25 Then    DoOEMBUTTON(1021)    Message"Brush Wait OverTime"    Exit Sub End IfBrushWaitTime = BrushWaitTime +1   Wend'---brush wait'------------------------------------------'    Tool Release Control'------------------------------------------ActivateSignal(Output1) 'Turn On Draw bar to release the toolMessage "Wait for Tool Release Signal"ToolReleaseWaitTime = 0While Not IsActive(Input2) 'OEM INPUT1Code "G4 P0.1"While IsMoving()WendIf ToolReleaseWaitTime > 25 Then    DoOEMBUTTON(1021)    Message "Tool Release feedback Signal Timeout"    Exit Sub End IfToolReleaseWaitTime = ToolReleaseWaitTime +1   Wend'-------------------------------------------'-------------------------------------------Code "G4 P1.0"    'Wait for the tool to releaseCode "G0 G53 Z" & ToolUpCall MovePos(NewTool)While IsMoving()WendCode "G01 G53 X" & XPos & "Y" & YPos & "F" & Spd Code "G0 G53 Z" & ZPos &"F" & spd2Code "G4 P.75"While IsMoving()Wend'------------------------------------------'    Tool Clamp Control'------------------------------------------DeActivateSignal(Output1) 'Turn Off Draw bar to Clamp the toolMessage "Wait Tool Release Signal "ToolClampWaitTime = 0While IsActive(input2) 'OEM INPUT2Code "G4 P0.1"While IsMoving()Wendif ToolClampWaitTime > 25 Then    DoOEMBUTTON(1021)    Message "Tool Clamp feedback Signal Wait OverTime"    SetCurrentTool( NewTool )    Exit Sub End IfToolClampWaitTime = ToolClampWaitTime +1   Wend'-------------------------------------------'-------------------------------------------Code "G4 P1.0"    'Wait for the tool to ClampWhile IsMoving()Wend'---brush wait--While IsActive(Input4)Code "G4 P0.1"While IsMoving()WendIf BrushWaitTime > 25 Then    DoOEMBUTTON(1021)    Message"Brush Wait OverTime"    Exit Sub End IfBrushWaitTime = BrushWaitTime +1   Wend'---brush wait'Code "G01 G53 Y" & YPos - ToolYaxisAdd & "F" & Spd Code "G01 G53 x" & xPos - ToolxaxisAdd & "F" & Spd Code "G4 P1"While IsMoving()WendCode "G0 G53 Z" & ToolSafe & "F" & spd2While IsMoving()WendCall SetUserDRO (1200,NewTool)SetCurrentTool( NewTool )code "g20"Code "G1 G90" & "F" & Spd & "X" & x & "Y" & y 'Move back to where the tool change was promptedcode "g43" ActivateSignal(Output2) 'brush downCall SetUserDRO (1200,NewTool)Message "Tool Change Complete"'End Sub'------------------------------------------'    Tool Postion'------------------------------------------Sub MovePos(ByVal ToolNumber As Integer)Select Case ToolNumber       Case Is = 0         Xpos = 48         YPos = 12         ZPos = -14       Case Is = 1         Xpos = 126.8066         YPos = 5.2127         ZPos = -18.324       Case Is = 2         Xpos = 126.8066         YPos = 12.2928         ZPos = -18.324       Case Is = 3         Xpos = 126.8066         YPos = 19.4139         ZPos = -18.324       Case Is = 4         Xpos = 126.8066         YPos = 26.4543         ZPos = -18.324       Case Is = 5         Xpos = 126.8066         YPos = 33.5391         ZPos = -18.324       Case Is = 6         Xpos = 126.8066         YPos = 40.6261         ZPos = -18.324       Case Is = 7         Xpos = 126.8066         YPos = 47.7116         ZPos = -18.324       Case Is = 8         Xpos = 126.8066         YPos = 54.8007         ZPos = -18.324End Selecttool = GetSelectedTool()While IsMoving() WendEnd Sub'End Sub'-------------------------------------------'-------------------------------------------'tool = GetSelectedTool()'SetCurrentTool( tool )                                                                             