Machsupport Forum

Mach Discussion => General Mach Discussion => Topic started by: davy182 on April 10, 2012, 10:51:00 AM

Title: Auto tool measuring and offsets
Post by: davy182 on April 10, 2012, 10:51:00 AM
I would like to set up a tool measuring system and offsets. This is a macro Brian posted that I liked.

Here is what I would like to do. Tool 1 or No tool in spindle will be the reference (Zeroed at table top), then I would like to measure the other tools and set the offsets automatically. I would like there to be a regular probe speed for first touch then a slow speed for second touch and use the second touch position. Then save tool offsets for each tool number.

If I could set up a macro for all six tools. And a macro to do current tool only.

Please chime in if there is a better way, but I do have hall effect sensor limit switches for homing and even the tool measure so accuracy and repeatability are not an issue, and don't really need to measure during tool changes.

So having a macro to measure tool in use, is basically used for if a tool is changed you can just measure and reset offset for the one tool. The macro for all six, I would like to have for say beginning of the week to recheck all tools.

Any input is appreciated.

 :) Thanks,

David


Xpos = GetDRO(0) 'Get the X and Y position
Ypos = GetDRO(1)
Code "G53 G00 Z-.1" 'Move the tool all the way up
Code "G53 G00 X3.5 Y6.00" 'Move to the probe position
While IsMoving()
Wend
Zpos = GetDRO(2)'Get the Zpos
Code "G31 Z" & Zpos - 5 & " F30" 'Probe down 5 Units
While IsMoving()
Wend
Zpos = GetVar(2002) 'Get the Position that the Porbe hit at
Code "G00 Z" & Zpos' Move to the point where the probe hit
While Ismoving()
Wend
Call SetDRO(2,0.000) 'Set the Z to 0.00
Code"G53 G00 Z-.1" 'Pick the tool up to the home switch
Code"G00 X" & Xpos & "Y" & Ypos 'Move to the point where the tool change started
Title: Re: Auto tool measuring and offsets
Post by: davy182 on April 10, 2012, 02:16:27 PM
OK,
here is my finished script for tool length offset setting with a permantly installed probe:

If IsSuchSignal (22) Then
Code "G49"
Code "G0 G53 Z00." 'Home Z
code "G53 X0 Y3.125" 'Move into Probe Pos ***EDIT HERE***
DoOEMButton(179) ' machine coordinates
Tool_Number = GetDRO(24)
code "G91 g31 z-9. f20."
While (IsMoving())
  Sleep 30
Wend

code " g0 z.2"

code "G91 g31 z-9. f3."
While (IsMoving())
  Sleep 10
Wend

If Tool_Number = 0 Then 'Master tool Cal
z = GetOEMDRO(85) 'get Machine ZPos
Call SetOEMDRO(49,z) 'Set fixture offset
Else

Call SetDRO(24,0) 'Turn off the tool offset by loading tool #0
Height = GetDRO(2) 'Get the pos of the Z axis without the Tool comp on
Call SetDRO(24,Tool_Number) 'Turn the tool Back on so the offset will go to the
Call SetoemDRO(42,Height) 'Set the Tool Height offset
End If

DoOEMButton(181) back to program coordinates
code "G0 G90 G53 Z0.0"
code "G43"
While (IsMoving())
  Sleep 10
Wend
End If

Mark


If Tool_Number = 0 Then 'Master tool Cal
z = GetOEMDRO(85) 'get Machine ZPos
Call SetOEMDRO(49,z) 'Set fixture offset
Else

Call SetDRO(24,0) 'Turn off the tool offset by loading tool #0
Height = GetDRO(2) 'Get the pos of the Z axis without the Tool comp on
Call SetDRO(24,Tool_Number) 'Turn the tool Back on so the offset will go to the
Call SetoemDRO(42,Height) 'Set the Tool Height offset

(I am thinking this is something that I am looking for What do you think.)

Title: Re: Auto tool measuring and offsets
Post by: ger21 on April 10, 2012, 07:04:10 PM
I'd turn off the offset with:
Code "G49"
And turn it on with :
Code "G43 H" & Tool_Number


You can right the tool length to the tooltable after probing with:
Code "G10 L1 P" & Too_Number & " Z" & ToolLength
Title: Re: Auto tool measuring and offsets
Post by: davy182 on April 10, 2012, 09:52:11 PM
If IsSuchSignal (22) Then
Code "G49"
Code "G0 G53 Z00." 'Home Z
code "G53 X0 Y3.125" 'Move into Probe Pos ***EDIT HERE***
DoOEMButton(179) ' machine coordinates
Tool_Number = GetDRO(24)
code "G91 g31 z-9. f20."
While (IsMoving())
  Sleep 30
Wend

code " g0 z.2" What Do I need to put here to retract .2 from where probe triggered from first time above

code "G91 g31 z-9. f3."
While (IsMoving())
  Sleep 10
Wend

If Tool_Number = 0 Then 'Master tool Cal
z = GetOEMDRO(85) 'get Machine ZPos
Call SetOEMDRO(49,z) 'Set fixture offset
Else

code "G49"
Height = GetDRO(2) 'Get the pos of the Z axis without the Tool comp on
code "G43 H" & Tool_Number
code "G10 L1 P" & Tool_Number & "Z" & ToolLength
End If

DoOEMButton(181) back to program coordinates
code "G0 G90 G53 Z0.0"
code "G43"
While (IsMoving())
  Sleep 10
Wend

How does that look.
Title: Re: Auto tool measuring and offsets
Post by: BR549 on April 10, 2012, 10:55:05 PM
If IsSuchSignal (22) Then
Code "G49"
Code "G0 G53 Z00." 'Home Z
code "G53 X0 Y3.125" 'Move into Probe Pos ***EDIT HERE***
DoOEMButton(179) ' machine coordinates
Tool_Number = GetDRO(24)
code "G91 g31 z-9. f20."
While (IsMoving())
  Sleep 30
Wend

PRP = (GetParam(2002) +.2)  'Get the touch point value and add the .2 to it (Probe Retract Point)

code " g0 z"  & PRP       'What Do I need to put here to retract .2 from where probe triggered from first time above

code "G91 g31 z-9. f3."
While (IsMoving())
  Sleep 10
Wend
Title: Re: Auto tool measuring and offsets
Post by: davy182 on April 10, 2012, 11:17:35 PM
Looks great can't wait to try it. One last thing what would I need to add to this macro to go through all seven tools automatically(0 ref(no tool in spindle), 1 ,2 ,3,4,5,6) so as to have a single tool offset and set all tool offsets.
Title: Re: Auto tool measuring and offsets
Post by: BR549 on April 10, 2012, 11:30:29 PM
I would get it working as you want it with a single tool then work from there. It is just a matter of repeating what you did the first time.

You start with the master tool and reference all the rest of the tools to it. Then you set you master tool to the Part Z0.00 then when you cycle the tools the offsets follow the tools.

Just remember whne Mach3 cycles the tool offsets it must have room to safely make the offset move without crashing into something or limiting out.

As a rule I always make the master tool the longest tool. That way the spindle is always moving away from the upper stop and can not hit the upper limit switch when Mach3 cycles the tool offsets.

Justa thought, (;-) TP
Title: Re: Auto tool measuring and offsets
Post by: davy182 on April 11, 2012, 10:17:18 AM
Ok we have good movement UNTIL ??? we reach in red




code "G49"
code "G0 G53 Z00."
code "G53 X1.1014 Y4.825"
DoOEMButton(179)
Tool_Number = GetDRO(24)
code "G31 z-6 f20."
While (IsMoving())
Sleep 30
Wend

PRP= (GetParam(2002)+.2)

code "G0 z" & PRP

code "G31 z-6. f3."
While (IsMoving())
Sleep 10
Wend

If Tool_Number =0 Then
z= GetOEMDRO(85)
Call SetOEMDRO(49,z)
Else

code "G49"
Height = GetDRO(2)
code "G43H" & Tool_Number
code "G10L1P" & Tool_Number & "Z" & ToolLength
End If

DoOEMButton(181)
Code "G0 G90 G53 Z0.0"
Code "G43"
While (IsMoving())
Sleep 10

What it is doing is going to work coordinates .2 not trigger point plus .2 machine coordinates.

Title: Re: Auto tool measuring and offsets
Post by: davy182 on April 11, 2012, 11:53:22 AM
ok I got rid of the problem by changing it to

PRP=(GetVar(2002)+.2)
Title: Re: Auto tool measuring and offsets
Post by: davy182 on April 11, 2012, 12:58:18 PM
Here is what I changed in order to get the offset to be stored.


code "G49"
Height = GetDRO(2)
Call SetDRO(24,Tool_Number) 'Turn the tool Back on so the offset will go to the
Call SetoemDRO(42,Height) 'Set the Tool Height offset
code "G43H" & Tool_Number
code "G10L1P" & Tool_Number & "Z" & ToolLength
End If

DoOEMButton(181)
Code "G0 G90 G53 Z0.0"
Code "G43"
While (IsMoving())
Sleep 10
Wend    

And It works great. It stores the values in the tool table for the correct tool number.
The only thing I get is "No Characters Found In Reading Real Value" in the status bar."
Title: Re: Auto tool measuring and offsets
Post by: HimyKabibble on April 11, 2012, 01:54:07 PM
FWIW - I used to to tool length that way, but switched some time ago to just doing it off-line using a digital height gauge.  I find it MUCH faster and more convenient, as I don't have to swap out all the tools.  I can measure a dozen tools in maybe 2-3 minutes, where it would take 10 minutes to do using the machine.  Might be a different matter with a PDB....

Regards,
Ray L.
Title: Re: Auto tool measuring and offsets
Post by: davy182 on April 11, 2012, 03:14:24 PM
currently by using the single macro it measures in less than 30sec and I am testing out the repeatability. But for what I am doing it is great so far and leaves operator error out of the loop. I would only run the whole program on every Monday and really don't have to unless a tool is removed or broken ( in which case if a tool is removed or broken they can run just the single tool offset macro and be back in business).

And also I have looked into a digital height gauge for a iso 30, $1500 is not in my budget and measuring equipment breaks. I would much rather use the cnc as the measuring gauge.
Title: Re: Auto tool measuring and offsets
Post by: BR549 on April 11, 2012, 04:31:33 PM
You are correct the Get Var() is the correct call. I have been flipping back and forth in the Fanuc world a lot lately and they call them parameters(;-)

I am not sure WHY you keep invoking the G43 H# it should have nothing to do with what you are trying to do.

Probe the master tool, set the Z to zero and the TOOL offset to Zero

Probe the next tool Apply the Z value as that tool offset (it will show the difference between the master and the set tool Remember the master is Zero)
PRobe the next tool and apply the Zvalue as that tool offset

etc
etc
Untill  you run out of tools to set.

That is basically all there is to it.

Just a thought, (;-)TP
Title: Re: Auto tool measuring and offsets
Post by: davy182 on April 11, 2012, 05:15:06 PM
I don't know that much about vbscripting. I went with an all ready written tool offset macro and tweaked it with help from Gerry. It is automatically inputting the offsets in the tool table so I am happy. Here is the actual finished macro that is running on the machine with no hiccups, but feel free to optimize. I all ready plowed the tool setter off trying to make my own auto tool zero macro. I got it working but Darn could have done without the mishap.
Title: Re: Auto tool measuring and offsets
Post by: BR549 on April 11, 2012, 06:22:54 PM
IF it makes you happy that is all that matters(;-)

You may want to look at something like this as a comparison. It starts by measuing the master then you can set as many tool#s as you like or cancel to end.

Sub Main()   
 'Macro for tool setting
code " G28 Z0.000"
code " G28 X0.000 Y0.000"
While Ismoving()
Sleep(10)
Wend

'Set Master Tool Routine
MsgBox(" Place the Master tool into the spindle")
Tnum = Question ("Tool Number?")
Ret = MachMsg ("Are you ready to run the MasterTool setting function?", "MasterTool", 1)
If Ret=2 Then End
code "G31 z-10 f20."
While IsMoving()
Sleep(10)
Wend
PRP= (GetVar(2002)+.2)
code "G0 z" & PRP
code "G31 z-10. f3."
While IsMoving()
Sleep(10)
Wend
Code"G92 Z0.000"
Tlo=GetDro(2)
Code" G28 Z0.000"
SetToolParam(Tnum,2,Tlo)

N1:
' SetNext Tool Routine
Ret = MachMsg ("Are you ready to run the Next Tool Setting function?", "MasterTool", 1)
If Ret=2 Then End
Tnum = Question ("Tool Number?")
MsgBox(" Place the NEXT tool into the spindle THEN press OK Routine Will Start.")


code "G31 z-10 f20."
While IsMoving()
Sleep(10)
Wend
PRP= (GetVar(2002)+.2)
code "G0 z" & PRP
code "G31 z-10 f3."
While IsMoving()
Sleep(10)
Wend
Tlo=GetDro(2)
Code" G28 Z0.000"
SetToolParam(Tnum,2,Tlo)
While Ismoving()
Sleep(10)
Wend
GoTo N1

End Sub

         


Title: Re: Auto tool measuring and offsets
Post by: davy182 on April 11, 2012, 11:05:19 PM
Thanks I will have to give that a try.
Title: Re: Auto tool measuring and offsets
Post by: Mountainman on December 08, 2012, 07:40:17 PM
I am totally new to all this and am looking at you guys writing your own macros in awe.  If I wanted to use BR549's code, where would I insert that into MACH3.  anybody got any suggestions how I would go about having the knee's servo motor take care of compensating for tool lengths?    I am running a knee mill
Title: Re: Auto tool measuring and offsets
Post by: BR549 on December 08, 2012, 09:19:52 PM
Unless your Knee is the Z axis there is no direct way to use both the knee and the quill. It will be one or the other.

Now if you want to run hybrid Gcode where you have macros do the tool height comp it can be done BUT you can no longer run standard Gcode.

You would also have to MOdify the CAm post to add in the required code and remove the Tool Height comp code(Gcode).

(;-) TP

Title: Re: Auto tool measuring and offsets
Post by: Mountainman on December 09, 2012, 08:17:22 AM
lets say during tool change G43 is called up and the tool being inserted is H3 ( 3" longer than shortest tool)  so after the tool change when cycle start is pressed the first thing to happen is the knee going down 3" and the knee dro zeroing at that position.   Basically the H value is inserted into a macro that automatically moves teh knee by that amount and makes that Z zero for the part.  That's it so now we have ofsetted for that tool and when the next tool change occurs that will happen again.    
Title: Re: Auto tool measuring and offsets
Post by: BR549 on December 09, 2012, 11:58:33 AM
Your problem will be when the G43 runs it moves the Z axis. IF you move the Z and the macro moves the KNEE then what.

Like I said you can do one or the other with standard Gcode. IF you want to run hybrid Gcode you can do it with knee and quill.

(;-) TP
Title: Re: Auto tool measuring and offsets
Post by: Mountainman on December 09, 2012, 01:10:39 PM
can't we rewrite that part of MACH so that G43 controls the knee instead of Z?  Thanks for clearing things up? 
Title: Re: Auto tool measuring and offsets
Post by: BR549 on December 09, 2012, 01:30:28 PM
(;-) No

(;-) TP
Title: Re: Auto tool measuring and offsets
Post by: vertcnc on March 10, 2013, 11:03:43 PM
BR549,
I was using your code for tool setup and all was fine. Setup table. Ran some code with tool changes and everything was fine.
I then went to setup some additional tools and after 1st touch off of tool it drove tool through table. Any ideas?
Title: Re: Auto tool measuring and offsets
Post by: BR549 on March 11, 2013, 12:24:45 AM
Are you sure it was MY code? I have not played with tool offset/setting code for years that I can remember.

Just a thought, (;-) TP
Title: Re: Auto tool measuring and offsets
Post by: BR549 on March 11, 2013, 12:49:41 AM
I guess IF I read UP the list I would have seen it(;-)

Sounds like Mach3 failed to stop on the probe trip as a best guess.

(;-) TP
Title: Re: Auto tool measuring and offsets
Post by: vertcnc on March 11, 2013, 08:06:34 AM
Yup that's what I was thinking, but it appears to be something to do with the 2002 variable where it lift the tool .2 above the first touch. Instead of lifting it goes down further. It stops at the first touch.