Hello Guest it is March 28, 2024, 06:40:04 PM

Author Topic: gripper style ATC macro - help needed  (Read 4041 times)

0 Members and 1 Guest are viewing this topic.

gripper style ATC macro - help needed
« on: November 29, 2012, 08:00:43 AM »

Hi Guys,

I have been trying to get a macro working for an auto tool changer that docks its tools into claw grips sitting on a rack at the end of the cnc bed.

I started with the example file and had little luck after a few days trying as I am very new to VB but keen to jump in the deep end and get my feet wet!

The code is not perfect, I am sure I can get the other things sorted myself but the one issue I can’t work out is how to call the "Xpos" value that is used in the” Call MovePos(OldTool)” sub. The movement is not working as i want and I think it may be because of the way I am trying to go about things...

Can someone confirm if I am able to get the Xpos values to be read after the sub? Or is this not possible and I need to find another way to go about getting this thing to work as I want?

Also is this style of atc called a wine rack?

Many thanks in advance and I have dropped my code below.

Jestah

  'ToolChange Macro For wine rack type tool changer 11/05 Brian
' modded by jestah for gripper style rack 
Sub Main()
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 'Tool Changer Macro (Bed Type)
MaxToolNum = 6      'Max number off tools for the changer
ToolDown   = -25.0 'Z Pos to Get or drop a tool
ToolUp     = -0.00    'Z Hieght to Rapid to and from tool change
ToolIn = 15 'X distance to push tool into gripping claw
ToolOver = 10.0 ' tool over other tools plane
AboveTool = 5 'distance above tool holder to rapid down too
DockFeed     = "2000"   'Set the first plunge speed for the probe
GrabFeed     = "2000"   'Set the first plunge speed for the probe

If NewTool = OldTool Then
   Exit Sub
End If

While NewTool > MaxToolNum
NewTool = Question ("Enter New Tool Number up to " & MaxToolNum)
Wend

'Retract to top of z before moving to old tool pos
Code "G00 G53 Z" & ToolUp
While IsMoving()
Wend
DoSpinStop()'spindle off

ActivateSignal(OUTPUT5) ' Dust hood up

'Move infront of old tool slot
Call MovePos(OldTool)

Code "G53 X" & XPos - ToolIn & "Y" & YPos ' this is where the issue is
While IsMoving()
Wend

'Lower to tool insert height
Code "G53 Z" & ToolDown
Code "G4 P1.0"
While IsMoving()
Wend

'move tool into rack
Code "G53 G1 F" & DockFeed &" X " & XPos & " Y" & YPos
While IsMoving()
Wend

'Release tool
ActivateSignal(Output4) 'Turn On Draw bar to release the tool
Code "G4 P1.0"    'Wait for the tool to release

'Retract up to over plane
Code "G53 G00 Z" & ToolOver

'Move to new tool station
Call MovePos(NewTool)
Code "G53 X" & XPos & " Y" & YPos
While IsMoving()
Wend

Code "G53 G00 Z" & ToolDown + AboveTool
Code "G53 G1 F" & GrabFeed &"Z" & ToolDown
Code "G4 P1.0"
While IsMoving()
Wend

'Clamp the tool
DeActivateSignal(Output4) 'Clamp the tool
Code "G4 P1.0"    'Wait for the tool to Clamp
While IsMoving()
Wend

'Move out of tool grip
Code "G53 G00 X" & XPos - ToolIn & " Y" & YPos
While IsMoving()
Wend

'retract To top of Z
Code "G53 Z" & ToolUp

Call SetUserDRO (1200,NewTool)
SetCurrentTool( NewTool )
Code "G00 X" & x & " Y" & y 'Move back to where the tool change was prompted
DeActivateSignal(OUTPUT5) ' Drop hood
End Sub

Sub MovePos(ByVal ToolNumber As Integer)

Select Case ToolNumber
       Case Is = 1
         Xpos = 40.00
         YPos = 10.00
       Case Is = 2
         Xpos = 40.00
         YPos = 20.00
       Case Is = 3
         Xpos = 40.00
         YPos = 30.00
       Case Is = 4
         Xpos = 40.00
         YPos = 40.00
       Case Is = 5
         Xpos = 40.00
         YPos = 50.00
       Case Is = 6
         Xpos = 40.00
         YPos = 60.00
        Case Is = 7
         Xpos = 40.00
         YPos = 70.00
   Case Is = 8
         Xpos = 40.00
         YPos = 80.00

       End Select

'Code "G53 X" & XPos & " Y" & YPos
End Sub


Main                         
   

Re: gripper style ATC macro - help needed
« Reply #1 on: November 29, 2012, 09:36:10 AM »
after a little reading and a little testing I would like to ask...

Is it really as simple as adding the below to the top of my code?

Dim Xpos
Dim Ypos

This seems to get things working as i want.... is this the way to go about things?