I have moved my ATC Hotswap code into a plugin, so I am releasing the VB m6 form for personal hobbie use.
this code is a hot swap for a 36 tool ATC. (arm, read-a-head, and screen set are not included), it is just a base example of the Meat of the Hot swap.
Sub Main() 'M6Start.m1s for HotSwap Tool changer
'Main Body of tool changer Code Rev1.0
'Copy Right by Scott Shafer of S S Systems LLC, Jan 2006
'You may use this for hobbie use for free, for commercial applications please contact me for terms.
'Email: poppabear@hughes.net
'This only show how to do the Hot-Swap code for the Tool Changer, and it moves a rotary caracell
'to the new position, the Arm and Draw bar code as well as the Status LED code has been removed.
'The logic for Tool desision tree for, Newtool vs. Oldtool and other error conditons have been removed.
'This example is for a 36 tool ATC.
'//////////////RESOURCES USED/////////////////////////////////
'DRO 1537 Z tool Change ht.
'range 1501-1536 Tool Slot DROs
'range 1200-1202 tool change location DROs
'range 1501-1536 Tool Slot LEDs (use this Slot LED)
'//////////////////////////////////////////////////////////////
XPos=GetUserDRO(1200) 'X Axis tool change location in Machine coordinates
YPos=GetUserDRO(1201) 'Y Axis tool change location in Machine coordinates
ZPos=GetUserDRO(1202) 'Z Axis tool change location in Machine coordinates
OldTool = GetCurrentTool() 'Get tool # That is in the spindle
NewTool = GetSelectedTool() 'Get Tool# of the New tool
CaptureToolZ = GetUserDRO(1537) 'The ZPos to come down to fit tool holder all the way in.
SlotNum = 0 'will determine the degree position
OldSlot = 1500 'Base count for Old tool replacement
UserDROnum = 1500 'Loop base count for UserDRO's
UserLEDnum = 1500 'Loop base count for UserLED's
IndexDRO = 0 'set loop base for compares
IndexLED = 0 'set loop base for compares
Call SetTicker (1,"")
Dim ToolPocket(1 To 36) As Integer 'DRO's for Tool pocket array
Dim I As Integer
For I = 1 To 36
UserDROnum = UserDROnum + 1
ToolNum = GetUserDRO(UserDROnum)
ToolPocket(I) = ToolNum
Next I
Dim LedToolPocket(1 To 36) As Integer 'LED's for Tool Pocket Array
Dim J As Integer
For J = 1 To 36
UserLEDnum = UserLEDnum + 1
LedState = GetuserLED(UserLEDnum)
LedToolPocket(J) = LedState
Next J
For K = 1 To 36
IndexDRO = IndexDRO + 1
IndexLED = IndexLED + 1
If NewTool = ToolPocket(IndexDRO) And LedToolPocket(IndexLED) = 1 Then
SlotNum = K
OldSlot = OldSlot + K
End If
Next K
If SlotNum = 0 And NewTool<>0 Then
Call SetTicker (1," Requested Tool is NOT in the ATC!!!!")
DoOEMButton(1001) ' Pause Machine
Exit Sub
End If
'===============================================================================================
DoSpinStop() 'Stop Spindle
DeActivateSignal(OUTPUT1) 'Flood Coolent
DeActivateSignal(OUTPUT2) 'Mist Coolent
Code "G90 G53 G0 Z" & ZPos 'Move Z tool change Pos
Code "G90 G53 G0 X" & XPos & " Y" & YPos 'Move X, Y tool change Pos
While IsMoving ()
Wend
'==================================================================================================
NumPositions = 36 'Number of tool slots in the changer
OldPos = GetDRO (5) 'Get C axis pos
NewPos = (SlotNum-1)*360/NumPositions 'calc ABS pos of tool slot
MoveDist = NewPos - OldPos 'Calc the move distance
If Abs(MoveDist) >180 Then 'Find the shortest path
If MoveDist < 0 Then
MoveDist = 360 + MoveDist
Else
MoveDist = MoveDist - 360
End If
End If
Code "G00 G91 C" & MoveDist 'Move the C axis in Incermental the move distance
While IsMoving ()
Wend
Code "G90"
SetUserDRO(OldSlot, OldTool)
SetOEMDRO(824, NewTool)
End Sub
Main
'Have fun,
'Scott