Hello Guest it is April 26, 2024, 05:03:43 PM

Author Topic: Tool setter, M6, tool length offsets  (Read 3359 times)

0 Members and 1 Guest are viewing this topic.

Re: Tool setter, M6, tool length offsets
« Reply #10 on: April 10, 2021, 12:39:52 PM »
Are you trying to run a one tool wonder machine?
If so you likely don't need to use the TLO's :)
If you're running a M6 with multiple tools then shoot me your script and I'll take a look.
You need to make sure the TLO (G43) is called before the zeroing of your Z axis to the material.
This way if multiple tools are called we are then just compensating for the difference between the tools rather than the entire tool length after zeroing.
You can see this happen if you have no TLO called and then zero your Z to the material, when your first G43 is called you'll be in a world of trouble.
I don't typically have the TLO called inside the M6 as it's normally called by the post in GCODE.
There are a lot of different ways to tackle this issue it's really what works best for you.
I really like to put a button on screen called "Job Setup" or something similar then call the TLO's and everything else I like prior to cutting with the click of a button.

So to recap, many years ago i was a cnc machinist, life change of career etc i didn't touch a machine for 17 years or so. 
I got a Chinese 6040 about 4 years ago and had some success as a one tool wonder machine on mach3 then after a rebuild mach4.  Just manual tool changes if anything.

I have now built a bigger stronger machine from scratch, and got an ATC spindle and a fixed tool setter. I haven't set up the carousel yet, i don't  think i dare before i get the tool setter measuring correctly.
At the moment i use the code below, but the z0 is not setting up properly.
It may be my method, something i'm missing etc... not sure. In my mind the tool setter should update the tool length of each tool in machine coordinates, and it will have its comparison. Then set wpc z0 with any tool and the rest should compensate accordingly even tool 1.  Am i doing it all messed up? i even manually set tool 0 and touched off the spindle face but still not working right.
Here is the code..
function m6()
   
local inst = mc.mcGetInstance()

----------------------------------------------------------------------------------
--change lines here to either auto rapid, or manually jog to a tool change position
----------------------------------------------------------------------------------
--Manual Lines. Uncomment line below to allow you to manually jog to a tool change position.
--local MyChoice = wx.wxMessageBox("Click OK, \nThen Jog to A Safe Tool Change Position,\nInsert New tool,\nThen Click Cycle Start.","Click OK to continue" , 16)
---------------------------------------------------------------------------------
--Auto Lines.  Uncomment both lines below (and comment out local MyChoice line above) to automatically move to tool change position.
--Edit to include the machine coordinate values of that tool change position.

--AUTO LINES
mc.mcCntlGcodeExecuteWait(inst, "G53 G0 Z-5\nG53 G0 X200.0 Y20.0")--Move the Z to Home.Then to the X, Y Coords for our touch pad.
mc.mcCntlSetLastError(inst, 'Now in Tool Change Position. Hit Cycle Start!')
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
local posmode = mc.mcCntlGetPoundVar(inst, mc.SV_MOD_GROUP_3) --get the current mode so we can return to it when macro ends
local selectedtool = mc.mcToolGetSelected(inst)
local currenttool = mc.mcToolGetCurrent(inst)
   
 if selectedtool == currenttool then
        mc.mcCntlSetLastError(inst, "Current tool == Selected tool so there is nothing to do")
 else
        mc.mcCntlToolChangeManual(inst, true);
  mc.mcCntlSetLastError(inst, "Current tool == " .. tostring(selectedtool) .. "   Previous Tool == " .. tostring(currenttool))
  mc.mcToolSetCurrent(inst, selectedtool)

--local MyChoice = wx.wxMessageBox("Click Ok to Begin Probing the New Tool","Click OK to continue" , 16)
    mc.mcCntlGcodeExecuteWait(inst, "G53 G0 X24.0 Y436.0")--
        mc.mcCntlSetLastError(inst, "Probing in Progress!")
        mc.mcCntlGcodeExecuteWait(inst, " G91 G31 Z-95. F150.")--probe the new tool
local probedz = mc.mcCntlGetPoundVar(inst, mc.SV_PROBE_POS_Z) -- Z Probe position in Machine coords
        mc.mcCntlGcodeExecute(inst, string.format('G ' .. posmode))--return to pre macro mode G90, or G91
  mc.mcCntlGcodeExecuteWait(inst, "G00 G53 Z0 ")--Retract
 
local NewOffset = probedz
  mc.mcToolSetData(inst, mc.MTOOL_MILL_HEIGHT, selectedtool, NewOffset)
  mc.mcCntlSetLastError(inst, string.format("Auto tool setting complete, Offset = %.4f", NewOffset))
wx.wxMessageBox("Toolchange Complete.\nTLO Set")
        end

end

if (mc.mcInEditor() == 1) then
 m6()
end
Re: Tool setter, M6, tool length offsets
« Reply #11 on: April 10, 2021, 02:52:52 PM »
Update..
using this script there are some bugs with the tool table... i will try and make a video and post it on here.
I just ran through the following in mdi

m6 t1
m6 t2
m6 t3
m6 t4

The machine cycled endlessly through the tool changes, measured the same tool repeatably, but if i stop the cycle, the tool table would mess up.
say for example i press cycle stop after probing t1, then t2 updates in the tool table to t1 length.  One time it changed all 4 of the tool lengths!

So i tried mdi
m6 t1 g43 h1
m6 t2 g43 h2 etc.... got wildly different results..

I'm confused now!
Any help appreciated

Offline Graham Waterworth

*
  • *
  •  2,673 2,673
  • Yorkshire Dales, England
    • View Profile
Re: Tool setter, M6, tool length offsets
« Reply #12 on: April 10, 2021, 05:17:23 PM »
Try it like this :-

Code: [Select]
function m6()
   
local inst = mc.mcGetInstance()

----------------------------------------------------------------------------------
--change lines here to either auto rapid, or manually jog to a tool change position
----------------------------------------------------------------------------------
--Manual Lines. Uncomment line below to allow you to manually jog to a tool change position.
--local MyChoice = wx.wxMessageBox("Click OK, \nThen Jog to A Safe Tool Change Position,\nInsert New tool,\nThen Click Cycle Start.","Click OK to continue" , 16)
---------------------------------------------------------------------------------
--Auto Lines.  Uncomment both lines below (and comment out local MyChoice line above) to automatically move to tool change position.
--Edit to include the machine coordinate values of that tool change position.

--AUTO LINES
mc.mcCntlGcodeExecuteWait(inst, "G53 G0 Z-5\nG53 G0 X200.0 Y20.0")--Move the Z to Home.Then to the X, Y Coords for our touch pad.
mc.mcCntlSetLastError(inst, 'Now in Tool Change Position. Hit Cycle Start!')
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
local posmode = mc.mcCntlGetPoundVar(inst, mc.SV_MOD_GROUP_3) --get the current mode so we can return to it when macro ends
local selectedtool = mc.mcToolGetSelected(inst)
local currenttool = mc.mcToolGetCurrent(inst)
   
 if selectedtool == currenttool then
        mc.mcCntlSetLastError(inst, "Current tool == Selected tool so there is nothing to do")
        do return end
 end
  mc.mcCntlToolChangeManual(inst, true);
  mc.mcCntlSetLastError(inst, "Current tool == " .. tostring(selectedtool) .. "   Previous Tool == " .. tostring(currenttool))
  mc.mcToolSetCurrent(inst, selectedtool)

  --local MyChoice = wx.wxMessageBox("Click Ok to Begin Probing the New Tool","Click OK to continue" , 16)
    mc.mcCntlGcodeExecuteWait(inst, "G53 G0 X24.0 Y436.0")--
        mc.mcCntlSetLastError(inst, "Probing in Progress!")
        mc.mcCntlGcodeExecuteWait(inst, " G91 G31 Z-95. F150.")--probe the new tool
local probedz = mc.mcCntlGetPoundVar(inst, mc.SV_PROBE_POS_Z) -- Z Probe position in Machine coords
        mc.mcCntlGcodeExecute(inst, string.format('G ' .. posmode))--return to pre macro mode G90, or G91
  mc.mcCntlGcodeExecuteWait(inst, "G00 G53 Z0 ")--Retract
 
local NewOffset = probedz
  mc.mcToolSetCurrent(inst, SelectedTool)
  mc.mcToolSetData(inst, mc.MTOOL_MILL_HEIGHT, selectedtool, NewOffset)
  mc.mcCntlSetLastError(inst, string.format("Auto tool setting complete, Offset = %.4f", NewOffset))
wx.wxMessageBox("Toolchange Complete.\nTLO Set")
end

if (mc.mcInEditor() == 1) then
 m6()
end
Without engineers the world stops

Offline Graham Waterworth

*
  • *
  •  2,673 2,673
  • Yorkshire Dales, England
    • View Profile
Re: Tool setter, M6, tool length offsets
« Reply #13 on: April 10, 2021, 05:22:10 PM »
By the way you can NOT use G91 in G53 mode
Without engineers the world stops
Re: Tool setter, M6, tool length offsets
« Reply #14 on: April 10, 2021, 05:29:48 PM »
By the way you can NOT use G91 in G53 mode
AHH maybe that could be the issue... I will test tomorrow.
I didn't even notice that was there.... It could be why my tool heights are moving
« Last Edit: April 10, 2021, 05:32:07 PM by barneskite28 »
Re: Tool setter, M6, tool length offsets
« Reply #15 on: April 11, 2021, 05:06:44 AM »
This was a video made yesterday to show some of the issues...
https://www.youtube.com/watch?v=l6MMqYhT8xc

Offline Stuart

*
  •  311 311
    • View Profile
Re: Tool setter, M6, tool length offsets
« Reply #16 on: April 11, 2021, 11:43:02 AM »
you cannot zero the DRO for the axis while you have the machine co-ordinates selected these can only be set by the homing routine not the operator

uncheck machine co-ordinates and you can zero the DRO

stuart
Re: Tool setter, M6, tool length offsets
« Reply #17 on: April 11, 2021, 11:50:26 AM »
you cannot zero the DRO for the axis while you have the machine co-ordinates selected these can only be set by the homing routine not the operator

uncheck machine co-ordinates and you can zero the DRO

stuart
Yes, as you can see in the video i did that :)
Re: Tool setter, M6, tool length offsets
« Reply #18 on: April 11, 2021, 01:38:23 PM »
Here is the updated code running, i still cant get to re-zero. Mach4 seems really buggy for todays day and age!
https://www.youtube.com/watch?v=sswY4xx-OOU
Re: Tool setter, M6, tool length offsets
« Reply #19 on: April 12, 2021, 02:53:13 PM »
Any idea?