I have been trying to implement a rotary tool changer,it is rotated with a stepper motor
and I have it set as the "a"axis.I can enter a goa# on the mdi line and the turret works.
I found that a value of 1.64375 X tool # and it will rotate to that tool.Now I want to do it
with a brain or with a vb macro as below I must have something wrong
with this as I cannot get it to work!.I would rather use a brain as I would like to add
funcionality to my machines as I go.My turret is simple
-a pneumatic cylinder holds a lock closed, release with a signal
-read input from limit switch, to indicate lock is released,
- rotate turret and reclamp
-read lose of input from limit switch to indicate all is good.If IsLoading() Then
' do now't, program loading
Else
' dim some vars
Dim next_tool As Integer
Dim current_tool As Integer
Dim steps_per_tool As Integer
Dim max_tools As Integer
Dim holdingDRO As Integer
Dim rotateCW As Integer
Dim moves As Integer
Dim axis As String
Dim zero As Integer
' set up some vars
zero = 0
axis = a ' change to what ever axis you use for tool changer
rotateCW = 0 ' set to 1 for CCW and 0 for CW rotation
max_tools = 8 ' number of tools on turret
steps_per_tool= 1.64375 ' set to what ever it needs to be
holdingDRO=1050 ' or what ever you have set screen dro to
next_tool = GetSelectedTool()
current_tool = GetUserDRO(holdingDRO)
' do some tool changing
If next_tool > max_tools Then
Message "Tool number too high, program stopped."
Code "M30"
End
End If
If next_tool<1 Then
Message "Tool number too low, program stopped."
Code "M30"
End
End If
If next_tool=current_tool Then
' do nowt, we got it already
Else
' lets do some changing
If next_tool>current_tool Then moves=next_tool-current_tool
If next_tool<current_tool Then moves=max_tools-current_tool+next_tool
If rotateCW =1 Then
rapid_move = zero - rapid_move
End If
Code "G92 " & axis & "0"
Code "G91 G94 G61"
Code "G01 " & axis & rapid_move & "F" & fast_feed
While IsMoving()
Wend
Code "G01 " & axis "F" While IsMoving()
Wend
SetCurrentTool next_tool
SetUserDRO holdingDRO, next_tool
Code "G90" ' back to absolute movement
End If
End If
' end of tool change