Machsupport Forum

Mach Discussion => General Mach Discussion => Topic started by: davy182 on March 15, 2012, 12:12:44 PM

Title: Would like to add in a certain path for toolchange to run. Need Help
Post by: davy182 on March 15, 2012, 12:12:44 PM
I would like for the machine, once the tool-change is initiated, to take a certain path ( z to 0.0 then x to 0.0 and y to 0.0) then move along y 0.0 to the tools x position, then proceed with the normal tool change. Once tool is released, the it would go back to z 0.0 and then move to y 0.0 and move along y 0 to the new tools position and proceed with tool change.

From what it looks like the tool change macro from the tutorial moves over other tools. I don't have the clearance necessary to do that so hence I need the machine to back off to y 0.0 and select the x for the new tool then move in directly so as not to hit another tool.

Any help would be appreciated.

Title: Re: Would like to add in a certain path for toolchange to run. Need Help
Post by: davy182 on March 16, 2012, 02:34:42 PM
Well So far I have figured out myself how to get x to go to zero and then y zero before making tool change. I now would like to place in a code for pulling up old x pos and going to it first then to y pos separately. Then same thing for going to the new tool. I want it to go this way because of tool clearances are non existent at the tool changer area. Any Ideas?
Title: Re: Would like to add in a certain path for toolchange to run. Need Help
Post by: davy182 on March 16, 2012, 02:47:45 PM
Would I need to make A sub for oldtool x and oldtool y in-order to separate them so the machine moves in the pattern I want. I guess same for the Newtool.
Title: Re: Would like to add in a certain path for toolchange to run. Need Help
Post by: ger21 on March 16, 2012, 05:06:21 PM
Well So far I have figured out myself how to get x to go to zero and then y zero before making tool change. I now would like to place in a code for pulling up old x pos and going to it first then to y pos separately. Then same thing for going to the new tool. I want it to go this way because of tool clearances are non existent at the tool changer area. Any Ideas?

Define the positions like the sample macro does, and assign them to variables. Then just use G0 moves to move the machine where you want.
Code "G53 G0 Xold"
Code "G53 G0 Y"
Title: Re: Would like to add in a certain path for toolchange to run. Need Help
Post by: davy182 on March 17, 2012, 09:57:07 AM
Here is what I got so far Gerry the changes are in red. What you posted is exactly what I had in mind. I am new to scripting so where and how do I put the definition in. The attached picture is for a little better clarification.

'ToolChange Macro For Bed type tool changer 11/05 Brian
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 = 8      'Max number off tools for the changer
ToolDown   = -3.125 'Z Pos to Get or drop a tool
ToolUp     = 0.0    'Z Hieght to Rapid from tool to tool
If NewTool = OldTool Then
   Exit Sub
End If
While NewTool > MaxToolNum
NewTool = Question ("Enter New Tool Number up to " & MaxToolNum)
Wend
Code "G00 G53 Z" & ToolUp
While IsMoving()
Wend
Code "G00 G53 X0"
While IsMoving()
Wend
Code "G00 G53 Y4"
While IsMoving()
Wend
Call MovePos(OldTool)
While IsMoving()
Wend
Code "G53 Z" & ToolDown
Code "G4 P.75"
While IsMoving()
Wend
ActivateSignal(Output1) 'Turn On Draw bar to release the tool
Code "G4 P1.0"    'Wait for the tool to release
'SystemWaitFor (7) 'Wait for the tool Release Limit switch
Code "G53 Z" & ToolUp
Call MovePos(NewTool)
While IsMoving()
Wend
Code "G53 Z" & ToolDown
Code "G4 P.75"
While IsMoving()
Wend
DeActivateSignal(Output1) 'Turn Off Draw bar to Clamp the tool
Code "G4 P1.0"    'Wait for the tool to Clamp
While IsMoving()
Wend
Code "G53 Z" & ToolUp
While IsMoving()
Wend
Code "G53 Y4"
While IsMoving()
Wend
Call SetUserDRO (1200,NewTool)
SetCurrentTool( NewTool )
Code "G00 X" & x & " Y" & y 'Move back to where the tool change was prompted
End Sub

Sub MovePos(ByVal ToolNumber As Integer)

Select Case ToolNumber
       Case Is = 1
         Xpos = 12.00
         YPos = 2.00
       Case Is = 2
         Xpos = 14.00
         YPos = 2.00
       Case Is = 3
         Xpos = 16.00
         YPos = 2.00
       Case Is = 4
         Xpos = 18.00
         YPos = 2.00
       Case Is = 5
         Xpos = 12.00
         YPos = 2.00
       Case Is = 6
         Xpos = 14.00
         YPos = 2.00
       Case Is = 7
         Xpos = 16.00
         YPos = 2.00
       Case Is = 8
         Xpos = 18.00
         YPos = 2.00
End Select

Code "G53 X" & XPos & " Y" & YPos
End Sub
Main   
Title: Re: Would like to add in a certain path for toolchange to run. Need Help
Post by: davy182 on March 17, 2012, 10:01:10 AM
The reason I want it to go a specific way is because if the operator knows the tool change routine is about to happen and it does not move in a specific way, he then knows there is something funky going on and needs to reboot. I am working on it but it is just added to a long list of things to do :).

We have really bad power fluctuations and it affects the computers every know and again.
Title: Re: Would like to add in a certain path for toolchange to run. Need Help
Post by: ger21 on March 17, 2012, 10:31:46 AM
When you do:

Call MovePos(OldTool)
While IsMoving()
Wend

It will move to the positions specified in this section:

Select Case ToolNumber
       Case Is = 1
         Xpos = 12.00
         YPos = 2.00
       Case Is = 2
         Xpos = 14.00
         YPos = 2.00
       Case Is = 3
         Xpos = 16.00
         YPos = 2.00
       Case Is = 4
         Xpos = 18.00
         YPos = 2.00
       Case Is = 5
         Xpos = 12.00
         YPos = 2.00
       Case Is = 6
         Xpos = 14.00
         YPos = 2.00
       Case Is = 7
         Xpos = 16.00
         YPos = 2.00
       Case Is = 8
         Xpos = 18.00
         YPos = 2.00
End Select




With this line:
Code "G53 X" & XPos & " Y" & YPos

You'll probably need to add some additional moves in there to get it to go exactly where you want it to.
Title: Re: Would like to add in a certain path for toolchange to run. Need Help
Post by: davy182 on March 17, 2012, 10:43:54 AM
So is this what you are saying,

Select Case ToolNumber

    Case Is = 1
      Xpos = 12.00
      Ypos = 2.00
      Code "G53 X" & XPos & " Y" & YPos

or would I take out the coordinates and place in xpos and ypos in the code you posted and just have a code for the Case Is = 1
Title: Re: Would like to add in a certain path for toolchange to run. Need Help
Post by: davy182 on March 17, 2012, 10:48:09 AM
I know how to get it to move separately, so I will just adjust the code accordingly. Knowing where to put it to get it to do what I want is the hard part.

If I need to remove the xpos and ypos then I think I need it to look like this

Case Is = 1
   Code "G53 X" & 12.00
   While IsMoving()
   Wend
   Code "G53 Y" & 2.00
   While IsMoving()
   Wend
Title: Re: Would like to add in a certain path for toolchange to run. Need Help
Post by: ger21 on March 17, 2012, 10:54:40 AM
Just change this:
Code "G53 X" & XPos & " Y" & YPos

To this:

Code "G53 X" & XPos
Code "G53 Y" & YPos
Title: Re: Would like to add in a certain path for toolchange to run. Need Help
Post by: davy182 on March 17, 2012, 11:12:27 AM
Got it to work thank you so much Gerry.

Here it is for anyone else to use.
'ToolChange Macro For Bed type tool changer 11/05 Brian
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 = 8      'Max number off tools for the changer
ToolDown   = -3.125 'Z Pos to Get or drop a tool
ToolUp     = 0.0    'Z Hieght to Rapid from tool to tool
If NewTool = OldTool Then
   Exit Sub
End If
While NewTool > MaxToolNum
NewTool = Question ("Enter New Tool Number up to " & MaxToolNum)
Wend
Code "G00 G53 Z" & ToolUp
While IsMoving()
Wend
Code "G00 G53 X0"
While IsMoving()
Wend
Code "G00 G53 Y4"
While IsMoving()
Wend
Call MovePos(OldTool)
While IsMoving()
Wend
Code "G53 Z" & ToolDown
Code "G4 P.75"
While IsMoving()
Wend
ActivateSignal(Output1) 'Turn On Draw bar to release the tool
Code "G4 P1.0"    'Wait for the tool to release
'SystemWaitFor (7) 'Wait for the tool Release Limit switch
Code "G53 Z" & ToolUp
While IsMoving()
Wend
Code "G53 Y4"
While IsMoving
Wend
Call MovePos(NewTool)
While IsMoving()
Wend
Code "G53 Z" & ToolDown
Code "G4 P.75"
While IsMoving()
Wend
DeActivateSignal(Output1) 'Turn Off Draw bar to Clamp the tool
Code "G4 P1.0"    'Wait for the tool to Clamp
While IsMoving()
Wend
Code "G53 Z" & ToolUp
While IsMoving()
Wend
Code "G53 Y4"
While IsMoving()
Wend
Call SetUserDRO (1200,NewTool)
SetCurrentTool( NewTool )
Code "G00 X" & x & " Y" & y 'Move back to where the tool change was prompted
End Sub

Sub MovePos(ByVal ToolNumber As Integer)

Select Case ToolNumber
       Case Is = 1
         Xpos = 12.00
         YPos = 2.00
         Code" G53 X" & XPos
         While IsMoving()
         Wend
         Code" G53 Y" & Ypos
         While IsMoving()
         Wend
       Case Is = 2
         Xpos = 14.00
         YPos = 2.00
         Code" G53 X" & XPos
         While IsMoving()
         Wend
         Code" G53 Y" & Ypos
         While IsMoving()
         Wend
       Case Is = 3
         Xpos = 16.00
         YPos = 2.00
         Code" G53 X" & XPos
         While IsMoving()
         Wend
         Code" G53 Y" & Ypos
         While IsMoving()
         Wend
       Case Is = 4
         Xpos = 18.00
         YPos = 2.00
         Code" G53 X" & XPos
         While IsMoving()
         Wend
         Code" G53 Y" & Ypos
         While IsMoving()
         Wend
       Case Is = 5
         Xpos = 12.00
         YPos = 2.00
         Code" G53 X" & XPos
         While IsMoving()
         Wend
         Code" G53 Y" & Ypos
         While IsMoving()
         Wend
       Case Is = 6
         Xpos = 14.00
         YPos = 2.00
         Code" G53 X" & XPos
         While IsMoving()
         Wend
         Code" G53 Y" & Ypos
         While IsMoving()
         Wend
       Case Is = 7
         Xpos = 16.00
         YPos = 2.00
         Code" G53 X" & XPos
         While IsMoving()
         Wend
         Code" G53 Y" & Ypos
         While IsMoving()
         Wend
       Case Is = 8
         Xpos = 18.00
         YPos = 2.00
         Code" G53 X" & XPos
         While IsMoving()
         Wend
         Code" G53 Y" & Ypos
         While IsMoving()
         Wend

End Select

Code "G53 X" & XPos & " Y" & YPos
End Sub
Main 
Title: Re: Would like to add in a certain path for toolchange to run. Need Help
Post by: ger21 on March 17, 2012, 11:19:23 AM
You can delete all the red lines if you change the blue as shown"

Select Case ToolNumber
       Case Is = 1
         Xpos = 12.00
         YPos = 2.00
         Code" G53 X" & XPos
         While IsMoving()
         Wend
         Code" G53 Y" & Ypos
         While IsMoving()
         Wend
       Case Is = 2
         Xpos = 14.00
         YPos = 2.00
         Code" G53 X" & XPos
         While IsMoving()
         Wend
         Code" G53 Y" & Ypos
         While IsMoving()
         Wend
       Case Is = 3
         Xpos = 16.00
         YPos = 2.00
         Code" G53 X" & XPos
         While IsMoving()
         Wend
         Code" G53 Y" & Ypos
         While IsMoving()
         Wend
       Case Is = 4
         Xpos = 18.00
         YPos = 2.00
         Code" G53 X" & XPos
         While IsMoving()
         Wend
         Code" G53 Y" & Ypos
         While IsMoving()
         Wend
       Case Is = 5
         Xpos = 12.00
         YPos = 2.00
         Code" G53 X" & XPos
         While IsMoving()
         Wend
         Code" G53 Y" & Ypos
         While IsMoving()
         Wend
       Case Is = 6
         Xpos = 14.00
         YPos = 2.00
         Code" G53 X" & XPos
         While IsMoving()
         Wend
         Code" G53 Y" & Ypos
         While IsMoving()
         Wend
       Case Is = 7
         Xpos = 16.00
         YPos = 2.00
         Code" G53 X" & XPos
         While IsMoving()
         Wend
         Code" G53 Y" & Ypos
         While IsMoving()
         Wend
       Case Is = 8
         Xpos = 18.00
         YPos = 2.00
         Code" G53 X" & XPos
         While IsMoving()
         Wend
         Code" G53 Y" & Ypos
         While IsMoving()
         Wend

End Select

Code "G53 X" & XPos
While IsMoving()
Wend

Code "G53 Y" & YPos
While IsMoving()
Wend

End Sub
Title: Re: Would like to add in a certain path for toolchange to run. Need Help
Post by: davy182 on March 17, 2012, 11:58:36 AM
excellent
Title: Re: Would like to add in a certain path for toolchange to run. Need Help
Post by: davy182 on March 19, 2012, 08:39:05 AM
On the first codes

Code "G53 X0"

and

Code "G53 Y9"

What do I need to put in front of them in order for it to be in machine coordinates and not work coordinates.

Thanks
Title: Re: Would like to add in a certain path for toolchange to run. Need Help
Post by: Hood on March 19, 2012, 09:31:10 AM
G53 is machine coords.
Hood
Title: Re: Would like to add in a certain path for toolchange to run. Need Help
Post by: davy182 on March 19, 2012, 10:07:48 AM
Thanks Hood.

I left it out and had it on the other ones. :D