Hello all,
Previously I completed a cnc conversion on BVB25L lathe and now I'm adding a 8 station tool turret to this cnc lathe:
I know I need a macro code for this, I did a search on Machsupport forum, found some code but not sure if that's the suitable one, here's the link:
http://www.machsupport.com/forum/index.php/topic,15569.0.htmlcan I use the code below for my tool turret?
'Macro Tool Changer
Sub Main()
Dim Tool As Integer
Dim OldTool As Integer
Dim NewTool As Integer
Dim MaxToolNum As Integer
NewTool = 10
MaxToolNum = 8 'Maximum positions on Automatic Tool Changer
Tool = GetSelectedTool() 'Get the toolnumber from the command e.g T0101 M6 Tool number 1
OldTool = GetCurrentTool() 'Get current tool number
If Tool > MaxtoolNum Then GoTo 6
If TOOL = OldTool Then GoTo 7
ActivateSignal(Output3) 'Turn on output signal to turn off spindle and turn on the atc
sleep(10)
ActivateSignal(Output4) 'Turn atc forward
sleep (3000) 'Needed to start atc otherwise it plays up
While NewTool <> Tool
' CheckPins
If IsActive(Input3) And Not IsActive(Input2) And Not IsActive(Input1) Then
NewTool = 1
GoTo 5 'StopTool
End If
If Not IsActive(Input3) And Not IsActive(Input2) And Not IsActive(Input1) Then
NewTool = 8
GoTo 5 'StopTool
End If
If Not IsActive(Input3) And Not IsActive(Input2) And IsActive(Input1) Then
NewTool = 4
GoTo 5 'StopTool
End If
If IsActive(Input3) And Not IsActive(Input2) And IsActive(Input1)Then
NewTool = 5
GoTo 5 'StopTool
End If
If IsActive(Input3) And IsActive(Input2) And IsActive(Input1) Then
NewTool = 7
GoTo 5 'StopTool
End If
If Not IsActive(Input3) And IsActive(Input2) And IsActive(Input1)Then
NewTool = 6
GoTo 5 'StopTool
End If
If Not IsActive(Input3) And IsActive(Input2) And Not IsActive(Input1) Then
NewTool = 2
GoTo 5 'StopTool
End If
If IsActive(Input3) And IsActive(Input2) And Not IsActive(Input1) Then
NewTool = 3
GoTo 5 'StopTool
End If
Wend
5:
' Stoptool
DeActivateSignal(Output4) 'StopATC
sleep(10)
ActivateSignal(Output5) 'Run ATC in reverse
Sleep (3000) 'Wait 3 seconds to allow the toolpost to lock in
DeActivateSignal(Output5) 'Stop running ATC in reverse
Sleep (1000)
SetCurrentTool(NewTool)
DeActivateSignal(Output3) 'Turn off output to turn spindle back on
sleep(10)
GoTo 7
6:
MsgBox ("Tool out of RANGE")
Goto 7
7:
End Sub
Thanks,