Machsupport Forum

Mach Discussion => Mach4 General Discussion => Topic started by: barneskite28 on May 01, 2021, 08:52:16 AM

Title: Again with the tool setter
Post by: barneskite28 on May 01, 2021, 08:52:16 AM
Ok guys, so after digging around i found some script in the Mach4 scripting manual.  The supporting paragraph describes exactly what i need, but refers to 'customization manual' that doesn't exist.
Below is the script copied direct from the manual
Code: [Select]
-----------------------------------------------------------------------------
-- Auto Tool Setting Macro
-----------------------------------------------------------------------------
--[[
 Requires the following instance registers to be defined
 TS_XPos-----------X position of probe (machine position)
 TS_YPos-----------Y position of probe (machine position)
 TS_Type-----------Offset type (1 or 2)
 TS_TouchPos-------Z position of touch off surface (machine position)
 TS_ProbeH---------Height of probe above touch off surface
 TS_DefaultL-------Default tool length guess
 TS_Retract--------Retract distance after probe touch
 Offset Type 1-----Length of tool from gauge line to tip
 Offset Type 2-----Distance from tip of tool to the touch position
]]
--The function GetRegister() must be defined for use by macros
function m1005()
 local inst = mc.mcGetInstance()

 ------------- Define Vars -------------
 local ProbeSignal = mc.ISIG_DIGITIZE
 ------------- Get current state -------------
 local CurTool = mc.mcToolGetCurrent(inst)
 local CurHNum = mc.mcCntlGetPoundVar(inst, 2032)
 local CurFeed = mc.mcCntlGetPoundVar(inst, 2134)
 local CurZOffset = mc.mcCntlGetPoundVar(inst, 4102)
26
 local CurFeedMode = mc.mcCntlGetPoundVar(inst, 4001)
 local CurAbsMode = mc.mcCntlGetPoundVar(inst, 4003)
 ------------- Get touch off parameters -------------
 local Xpos = GetRegister("TS_XPos", 1)
 local Ypos = GetRegister("TS_YPos", 1)
 local OffsetType = GetRegister("TS_Type", 1)
 local TouchPos = GetRegister("TS_TouchPos", 1)
 local ProbeHeight = GetRegister("TS_ProbeH", 1)
 local RetractDistance = GetRegister("TS_Retract", 1)
 local ToolLengthGuess = GetRegister("TS_DefaultL", 1)
 ------------- Check Probe -------------
 local hsig = mc.mcSignalGetHandle(inst, ProbeSignal)
 local ProbeState = mc.mcSignalGetState(hsig)
 if (ProbeState == true) then
 mc.mcCntlSetLastError(inst, "ERROR: Probe signal is activated")
 do return end
 end

 ------------- Calculations for Gcode -------------
 local StartHeight = TouchPos + ProbeHeight + ToolLengthGuess + .5

 ------------- Generate GCode -------------
 AutoToolSetGCode = ""
 AutoToolSetGCode = AutoToolSetGCode .. "G00 G80 G40 G49 G90\n"
 AutoToolSetGCode = AutoToolSetGCode .. "G00 G53 Z0.0\n"
 AutoToolSetGCode = AutoToolSetGCode .. string.format("G00 G53 X%.4f Y%.4f\n", Xpos, Ypos)
 AutoToolSetGCode = AutoToolSetGCode .. string.format("G00 G53 Z%.4f\n", StartHeight)
 AutoToolSetGCode = AutoToolSetGCode .. "G91 G31 Z-2.0 F25.\n"

 mc.mcCntlGcodeExecuteWait(inst, AutoToolSetGCode)
 --Check probe contact
 ProbeState = mc.mcSignalGetState(hsig)
 if (ProbeState ~= 1) then
 mc.mcCntlSetLastError(inst, "ERROR: No contact with probe")
 mc.mcCntlGcodeExecuteWait(inst, "G0 G90 G53 Z0.0\n")
 do return end
 end

 AutoToolSetGCode = ""
 AutoToolSetGCode = AutoToolSetGCode .. string.format("G91 G00 Z%.4f\n", RetractDistance)
 AutoToolSetGCode = AutoToolSetGCode .. "G91 G31 Z-1.0 F10.\n"

 mc.mcCntlGcodeExecuteWait(inst, AutoToolSetGCode)
 --Check probe contact
 ProbeState = mc.mcSignalGetState(hsig)
 if (ProbeState ~= 1) then
 mc.mcCntlSetLastError(inst, "ERROR: No contact with probe")
 mc.mcCntlGcodeExecuteWait(inst, "G0 G90 G53 Z0.0\n")
 do return end
 end

 AutoToolSetGCode = ""
 AutoToolSetGCode = AutoToolSetGCode .. "G90 G00 G53 Z0.0\n"
 mc.mcCntlGcodeExecuteWait(inst, AutoToolSetGCode)
 ------------- Get touch position and set offset -------------
 local ZProbed = mc.mcCntlGetPoundVar(inst, 5063)
 local ZOffset = ZProbed - ProbeHeight + CurZOffset
 if (OffsetType == 1) then
 ZOffset = math.abs(TouchPos - ZOffset)
 end

 mc.mcToolSetData(inst, mc.MTOOL_MILL_HEIGHT, CurTool, ZOffset)
 mc.mcCntlSetLastError(inst, string.format("Auto tool setting complete, Offset = %.4f",
ZOffset))

I have managed to touch off the spindle face in machine coords, and have the spindle face (gauge line- without holder) at -161.2219.  My tool setter position is at x24.0 y436.0

Can someone help me understand where to put these values and how to get this damn thing to work please?

Tim
Title: Re: Again with the tool setter
Post by: barneskite28 on May 01, 2021, 08:55:31 AM
I put a ticket into mach support for assistance, got a reply back that said 'read the manual'..... not much support from the support!!
Title: Re: Again with the tool setter
Post by: Tweakie.CNC on May 02, 2021, 12:55:20 AM
I put a ticket into mach support for assistance, got a reply back that said 'read the manual'..... not much support from the support!!

Bet they didn't put their name to the reply  ;D

Tweakie.
Title: Re: Again with the tool setter
Post by: barneskite28 on May 02, 2021, 04:09:04 AM
I put a ticket into mach support for assistance, got a reply back that said 'read the manual'..... not much support from the support!!

Bet they didn't put their name to the reply  ;D

Tweakie.
They did, but its not personal so i don't see the relevance of their name, as far as i am concerned i'm dealing with a company.

Does anyone have a similar setup to me ? could you share your method/script and help me get this working please?
Title: Re: Again with the tool setter
Post by: barneskite28 on May 02, 2021, 08:18:38 AM
Found the following code, just not sure exactly where to insert my manual tool change position and my tool height setter position? i see the variable at the top and i see that called in the probing move, but where do i set it?
Code: [Select]
function M6()
    local inst = mc.mcGetInstance();
    local changeToTool = mc.mcToolGetSelected(inst)
    local changeFromTool = mc.mcToolGetCurrent(inst)
    local XPositionBeforeToolChange = mc.mcAxisGetPos(inst,0)
    local YPositionBeforeToolChange = mc.mcAxisGetPos(inst,1)
    local XToolProbePosition = "1"
    local YToolProbePosition = "1"
    local XManualToolChangePosition = "2"
    local YManualToolChangePosition = "2"
    local ColletAtProbeZCoordinate = -105 -- Machine Z-coordinate when collet tip touches TouchPlate (Must be more than ProbeOperationDistance - DefaultToolLength
    local ExtraProbeDistance = 5 -- SafetyMargin
    local ProbeOperationDistance = -50 -- Length of Probemove before giving up
    local ProbePrepSpeed = 100
    local ProbeSpeed = 25
    local DefaultToolLength = 70 -- Used if tool info is not found. (Should be a value slightly longer than the longest tool in the shop :D)
        -- QUICK REFERENCE
        -- G90 - Absolute (Go to coordinate)
        -- G91 - Incremental (Godistance along axis from current position)
        -- G53 - Machine Coordinate Move

    if changeToTool == changeFromTool then
    return
    mc.mcCntlSetLastError(inst, "ToolChange Activated But Not Required")
    else
    mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z0.0\nM5" )
    RunProbe(inst,changeFromTool,XToolProbePosition,YToolProbePosition,DefaultToolLength,ColletAtProbeZCoordinate,ExtraProbeDistance,ProbePrepSpeed,ProbeSpeed,ProbeOperationDistance)
    local ToolZCoordinate = mc.mcAxisGetPos(inst,2)
    mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z0.0 \n G90 G53 G0 X"..XManualToolChangePosition.." Y"..YManualToolChangePosition)
    local changeToToolDescription = mc.mcToolGetDesc(inst,changeToTool)
    wx.wxMessageBox("Please change to tool number "..changeToTool.." "..changeToToolDescription.." and press ok to continue")
    RunProbe(inst,changeToTool,XToolProbePosition,YToolProbePosition,DefaultToolLength,ColletAtProbeZCoordinate,ExtraProbeDistance,ProbePrepSpeed,ProbeSpeed,ProbeOperationDistance)
    mc.mcAxisSetPos(inst, 2 , ToolZCoordinate)
    mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z0.0")
    mc.mcCntlGcodeExecuteWait(inst,"G90 G0 X"..XPositionBeforeToolChange.." Y"..YPositionBeforeToolChange)
    mc.mcToolSetCurrent(inst, changeToTool)
    wx.wxMessageBox("If Toolchange was Sucessful - click ok to continue")
    mc.mcCntlSetLastError(inst, "ToolChange Finished")
    end
end

function RunProbe(finst,ftool,fXToolProbePosition,fYToolProbePosition,fDefaultToolLength,fColletAtProbeZCoordinate,fExtraProbeDistance,fProbePrepSpeed,fProbeSpeed,fProbeOperationDistance)
    mc.mcCntlGcodeExecuteWait(finst, "G90 G53 G0 X"..fXToolProbePosition.." Y"..fYToolProbePosition)
    local toollen = mc.mcToolGetData(finst, mc.MTOOL_MILL_HEIGHT, ftool)
    if toollen == 0 then
        toollen = fDefaultToolLength
        mc.mcCntlSetLastError(finst, "Tool length not found - using Default Length")
    end
    local probestart = fColletAtProbeZCoordinate + fExtraProbeDistance + toollen
    local GCODE = "G91 G31 G0 Z"..probestart.." F"..fProbePrepSpeed
    GCODE = ""..GCODE.." \n G91 G0 Z1 F"..fProbePrepSpeed.." \n G91 G31 Z"..fProbeOperationDistance.." F"..fProbeSpeed
    mc.mcCntlGcodeExecuteWait(finst,GCODE)
end

if (mc.mcInEditor() == 1) then
    M6()
end
Title: Re: Again with the tool setter
Post by: barneskite28 on May 02, 2021, 04:40:57 PM
Can anybody help with the script?
Title: Re: Again with the tool setter
Post by: KatzYaakov on May 02, 2021, 07:48:51 PM
barn
i just want give you advice,if you put such long script and long question ,do you real think some one will now take hours to
test yours script and debug it?
try divide yours question into section ,try focus exactly yours question ,not so big global like" nothing work"
then i belive you will get many answers
hope i help little
Title: Re: Again with the tool setter
Post by: barneskite28 on May 03, 2021, 02:38:52 AM
barn
i just want give you advice,if you put such long script and long question ,do you real think some one will now take hours to
test yours script and debug it?
try divide yours question into section ,try focus exactly yours question ,not so big global like" nothing work"
then i belive you will get many answers
hope i help little
Thanks Katz, noted.
really i have tried a couple of scripts that essentially 'work' - i.e. the machine does what its supposed to, but the tool offsets are the problem.  It may be me not understanding something in the procedure, thats what i'm trying to find out.  So to divide the questions..

1. Should tool offsets be on or off when probing the tool setter?

2. I expect a length of tool to be in the table, but the measurement is not the length from the gauge line.  I'm trying to find out why!

Mach4 considering it is a paid program, has little support and no updated info (videos/tutorials) for nearly 5 years, i think this is quite poor for a software that is not free!
Title: Re: Again with the tool setter
Post by: Graham Waterworth on May 03, 2021, 04:19:30 PM
Some pictures of the machine may help.

Also are you working from the XYZ home position or are you moving the datum using G54 etc.

Do you know the distance from a fixed point on the spindle to the table top?

Do you know the distance from the same fixed point on the spindle to the tool setter trigger point?

Do you have a DRO on your screen to set the thickness of the material?

If you have this information its a simple calculation based on the trigger point of the G31


Title: Re: Again with the tool setter
Post by: barneskite28 on May 03, 2021, 04:51:29 PM
Hi Graham,
I will get some photos later of the machine. I know the distance in machine coordinate from z home to the trigger point, and the xy of the tool setter. I got the script to do a calculation for the tool length, which seemed to be ok (all tools set with offsets off), but when I tried to set the wpc z0 with a shim on the offsets page, it was not correct. It was a 0.1mm shim on the top of the stock, entered in the offsets page and the dro changed to 90 mm or so.  Only if I enter 0.1 in the program run page does it read right.
Next thing I ran a program with 2 tools, and Mach completely ignored the toolchange twice. Re started the program, it went for the tool change, measured the tool and the height was all wrong.
I have in my script to turn the tool offsets off after the change, then measure, then in the gcode the tool offset is called straight after.
On the tool panel the offset number did not match the tool offset called by the program or the tool in the spindle..
Seems very buggy and not reliable, but I hope it's just me doing something wrong!
Much appreciated Graham!
Title: Re: Again with the tool setter
Post by: Graham Waterworth on May 03, 2021, 05:35:04 PM
Where did you get the code below from?
Title: Re: Again with the tool setter
Post by: barneskite28 on May 03, 2021, 06:12:39 PM
Don't remember exactly, but I was searching for it. I'm not a programmer and I don't really have a grasp on the scripting for Mach so I started from searching. I actually used the code from the Mach support video, which seemed to be ok ISH... IE. it was simple, seemed to work but the tool lengths were coming out wrong- repeatable but still not bringing all the tools to the same wpc z0.
Title: Re: Again with the tool setter
Post by: Graham Waterworth on May 03, 2021, 08:30:01 PM
Try this version of the code, read the comments first.
Code: [Select]
function M6()
    local inst = mc.mcGetInstance();
    local changeToTool = mc.mcToolGetSelected(inst)
    local changeFromTool = mc.mcToolGetCurrent(inst)
    local XPositionBeforeToolChange = mc.mcAxisGetPos(inst,0)
    local YPositionBeforeToolChange = mc.mcAxisGetPos(inst,1)
    local XToolProbePosition = "1" -- Change to position of probe in X
    local YToolProbePosition = "1" -- Change to position of probe in Y
    local XManualToolChangePosition = "2"
    local YManualToolChangePosition = "2"
    local ColletAtProbeZCoordinate = -105 -- Machine Z-coordinate when collet tip touches TouchPlate (Must be more than ProbeOperationDistance - DefaultToolLength
    local ExtraProbeDistance = 5 -- SafetyMargin
    local ProbeOperationDistance = -50 -- Length of Probemove before giving up
    local ProbePrepSpeed = 100
    local ProbeSpeed = 25
    local DefaultToolLength = 70 -- Used if tool info is not found. (Should be a value slightly longer than the longest tool in the shop :D)
        -- QUICK REFERENCE
        -- G90 - Absolute (Go to coordinate)
        -- G91 - Incremental (Godistance along axis from current position)
        -- G53 - Machine Coordinate Move

    if changeToTool == changeFromTool then
    return
    mc.mcCntlSetLastError(inst, "ToolChange Activated But Not Required")
    else
    mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z0.0\nM5" )
    RunProbe(inst,changeFromTool,XToolProbePosition,YToolProbePosition,DefaultToolLength,ColletAtProbeZCoordinate,ExtraProbeDistance,ProbePrepSpeed,ProbeSpeed,ProbeOperationDistance)
    local ToolZCoordinate = mc.mcAxisGetPos(inst,2)
    mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z0.0 \n G90 G53 G0 X"..XManualToolChangePosition.." Y"..YManualToolChangePosition)
    local changeToToolDescription = mc.mcToolGetDesc(inst,changeToTool)
    wx.wxMessageBox("Please change to tool number "..changeToTool.." "..changeToToolDescription.." and press ok to continue")
    RunProbe(inst,changeToTool,XToolProbePosition,YToolProbePosition,DefaultToolLength,ColletAtProbeZCoordinate,ExtraProbeDistance,ProbePrepSpeed,ProbeSpeed,ProbeOperationDistance)
    mc.mcAxisSetPos(inst, 2 , ToolZCoordinate)
    mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z0.0")
    mc.mcCntlGcodeExecuteWait(inst,"G90 G0 X"..XPositionBeforeToolChange.." Y"..YPositionBeforeToolChange)
    mc.mcToolSetCurrent(inst, changeToTool)
    wx.wxMessageBox("If Toolchange was Sucessful - click ok to continue")
    mc.mcCntlSetLastError(inst, "ToolChange Finished")
    end
end

function RunProbe(finst,ftool,fXToolProbePosition,fYToolProbePosition,fDefaultToolLength,fColletAtProbeZCoordinate,fExtraProbeDistance,fProbePrepSpeed,fProbeSpeed,fProbeOperationDistance)
    mc.mcCntlGcodeExecuteWait(finst, "G90 G53 G0 X"..fXToolProbePosition.." Y"..fYToolProbePosition)
    local toollen = mc.mcToolGetData(finst, mc.MTOOL_MILL_HEIGHT, ftool)
    if toollen == 0 then
        toollen = fDefaultToolLength
        mc.mcCntlSetLastError(finst, "Tool length not found - using Default Length")
    end
    local probestart = fColletAtProbeZCoordinate + fExtraProbeDistance + toollen
    local GCODE = "G91 G31 Z"..probestart.." F"..fProbePrepSpeed
    GCODE = ""..GCODE.." \n G91 G0 Z1 F"..fProbePrepSpeed.." \n G91 G31 Z"..fProbeOperationDistance.." F"..fProbeSpeed
    mc.mcCntlGcodeExecuteWait(finst,GCODE)
end

if (mc.mcInEditor() == 1) then
    M6()
end
Title: Re: Again with the tool setter
Post by: SwiftyJ on May 04, 2021, 03:35:30 AM
You may have seen this already but this video provides a good walkthrough of setting up the tool offsets in Mach4 https://www.youtube.com/watch?v=tywAByswH2Q (https://www.youtube.com/watch?v=tywAByswH2Q)
Title: Re: Again with the tool setter
Post by: barneskite28 on May 10, 2021, 03:45:02 PM
You may have seen this already but this video provides a good walkthrough of setting up the tool offsets in Mach4 https://www.youtube.com/watch?v=tywAByswH2Q (https://www.youtube.com/watch?v=tywAByswH2Q)
Yes i saw that, but it does not really explain how to use mach with a fixed tool setter, and what procedure top use in context with a program setup, this is not clear.  It shows one method, no relation to tool table and job setup g54
Title: Re: Again with the tool setter
Post by: barneskite28 on May 13, 2021, 11:22:02 AM
Try this version of the code, read the comments first.
Code: [Select]
function M6()
    local inst = mc.mcGetInstance();
    local changeToTool = mc.mcToolGetSelected(inst)
    local changeFromTool = mc.mcToolGetCurrent(inst)
    local XPositionBeforeToolChange = mc.mcAxisGetPos(inst,0)
    local YPositionBeforeToolChange = mc.mcAxisGetPos(inst,1)
    local XToolProbePosition = "1" -- Change to position of probe in X
    local YToolProbePosition = "1" -- Change to position of probe in Y
    local XManualToolChangePosition = "2"
    local YManualToolChangePosition = "2"
    local ColletAtProbeZCoordinate = -105 -- Machine Z-coordinate when collet tip touches TouchPlate (Must be more than ProbeOperationDistance - DefaultToolLength
    local ExtraProbeDistance = 5 -- SafetyMargin
    local ProbeOperationDistance = -50 -- Length of Probemove before giving up
    local ProbePrepSpeed = 100
    local ProbeSpeed = 25
    local DefaultToolLength = 70 -- Used if tool info is not found. (Should be a value slightly longer than the longest tool in the shop :D)
        -- QUICK REFERENCE
        -- G90 - Absolute (Go to coordinate)
        -- G91 - Incremental (Godistance along axis from current position)
        -- G53 - Machine Coordinate Move

    if changeToTool == changeFromTool then
    return
    mc.mcCntlSetLastError(inst, "ToolChange Activated But Not Required")
    else
    mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z0.0\nM5" )
    RunProbe(inst,changeFromTool,XToolProbePosition,YToolProbePosition,DefaultToolLength,ColletAtProbeZCoordinate,ExtraProbeDistance,ProbePrepSpeed,ProbeSpeed,ProbeOperationDistance)
    local ToolZCoordinate = mc.mcAxisGetPos(inst,2)
    mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z0.0 \n G90 G53 G0 X"..XManualToolChangePosition.." Y"..YManualToolChangePosition)
    local changeToToolDescription = mc.mcToolGetDesc(inst,changeToTool)
    wx.wxMessageBox("Please change to tool number "..changeToTool.." "..changeToToolDescription.." and press ok to continue")
    RunProbe(inst,changeToTool,XToolProbePosition,YToolProbePosition,DefaultToolLength,ColletAtProbeZCoordinate,ExtraProbeDistance,ProbePrepSpeed,ProbeSpeed,ProbeOperationDistance)
    mc.mcAxisSetPos(inst, 2 , ToolZCoordinate)
    mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z0.0")
    mc.mcCntlGcodeExecuteWait(inst,"G90 G0 X"..XPositionBeforeToolChange.." Y"..YPositionBeforeToolChange)
    mc.mcToolSetCurrent(inst, changeToTool)
    wx.wxMessageBox("If Toolchange was Sucessful - click ok to continue")
    mc.mcCntlSetLastError(inst, "ToolChange Finished")
    end
end

function RunProbe(finst,ftool,fXToolProbePosition,fYToolProbePosition,fDefaultToolLength,fColletAtProbeZCoordinate,fExtraProbeDistance,fProbePrepSpeed,fProbeSpeed,fProbeOperationDistance)
    mc.mcCntlGcodeExecuteWait(finst, "G90 G53 G0 X"..fXToolProbePosition.." Y"..fYToolProbePosition)
    local toollen = mc.mcToolGetData(finst, mc.MTOOL_MILL_HEIGHT, ftool)
    if toollen == 0 then
        toollen = fDefaultToolLength
        mc.mcCntlSetLastError(finst, "Tool length not found - using Default Length")
    end
    local probestart = fColletAtProbeZCoordinate + fExtraProbeDistance + toollen
    local GCODE = "G91 G31 Z"..probestart.." F"..fProbePrepSpeed
    GCODE = ""..GCODE.." \n G91 G0 Z1 F"..fProbePrepSpeed.." \n G91 G31 Z"..fProbeOperationDistance.." F"..fProbeSpeed
    mc.mcCntlGcodeExecuteWait(finst,GCODE)
end

if (mc.mcInEditor() == 1) then
    M6()
end

Tried the code and got the following message in the output window


stack traceback:
   [C]: in ?
   [C]: in function 'require'
   C:\Users\cnc\AppData\Local\Temp\.2D69.tmp:1: in main chunk
   [C]: in ?
Program completed in 0.07 seconds (pid: 2224).

Not sure about this
Title: Re: Again with the tool setter
Post by: LoopZilla on June 01, 2022, 09:10:06 AM
Hey Barneskite28,

Did you ever find a resolution to this?  I have been researching the gauge line method for tool offsets, and this is a quagmire of 'scripts' written by all sorts of folks with differing opinions.  And, the posts from the folks who actually might know what is going on act like scripting is something everyone is adept at.  I agree with one of your first comments - we pay for this, especially the Industrial version.  On top of that, we can't get support direct, as we are OEM and our vendor knows less than we do.

So - did you find a solution?  Were you attempting to use the 'master tool' or 'gauge line' foundation for your tool offset?  I really want my tool offsets to be independent from any table or bed reference, only referenced from the gauge line or spindle nose - like every other machine we have. 

Thanks - and I appreciate your frustrations!
Title: Re: Again with the tool setter
Post by: barneskite28 on June 01, 2022, 09:46:07 AM
Hey Barneskite28,

Did you ever find a resolution to this?  I have been researching the gauge line method for tool offsets, and this is a quagmire of 'scripts' written by all sorts of folks with differing opinions.  And, the posts from the folks who actually might know what is going on act like scripting is something everyone is adept at.  I agree with one of your first comments - we pay for this, especially the Industrial version.  On top of that, we can't get support direct, as we are OEM and our vendor knows less than we do.

So - did you find a solution?  Were you attempting to use the 'master tool' or 'gauge line' foundation for your tool offset?  I really want my tool offsets to be independent from any table or bed reference, only referenced from the gauge line or spindle nose - like every other machine we have. 

Thanks - and I appreciate your frustrations!

Yes i did manage to get my code working, and i used the dimension from the spindle face to the tool setter to make the tool length calculations.  Up to now this has been working ok apart from a coupe of issues that are unrelated in my mind to the code.  First issue is sometimes the fist tool change after power up (and yes, after activating offsets first and then zero the workpeice) can be ~10mm off, forcing me to re-zero the work piece z0 after which all tool changes are spot on.  Second issue, is recently out of the blue Mach4 started to hang when the tool setter was reached - every time.  powered down and back up and the same story.  No idea why but it caused me a massive pita, had to detlete mach, reinstall and restore the mach config and then reinstate the same code which then worked fine again.  This is more frustrating than getting it to work in the first place, and proves to me that for some reason known only to the programmers Mach4 is not robust and stable enough to provide reliable operation.  For me it has worked fine for 100's of power cycles, then out of the blue screwed itself up with no input from me.  It just started happening one time after power up and would not go away without me reinstalling everything.

The other strange issue i have seen is sometimes during the homing sequence mach has a pause after reaching the endstops.... not all the time though.  I have checked the PC and it is running fine with no lack of resources, and nothing else running.

I will re-post my working tool change script for you so that you can see how it works for mine, and you can modify for your machine.
Title: Re: Again with the tool setter
Post by: LoopZilla on June 01, 2022, 10:38:23 AM
Hey,

Awesome news, and congrats on slaying that beast. 

Ok - have you considered referencing everything to machine coordinate home versus a G54 or other work offset (or fixture)?  I think this is what I want to do.  Why?  Because I could build in some code that does a 'QC' check of the tool setter and the Z home every time I do the auto home sequence. 

For me, I always worry if my limit switches for machine home are being bumped, get dirty, or whatever.  If I get a power out during a program, how can you recover if the machine home is moving around?  If you buy into that, how do I know my tool setter is reliable? 

If we take the Z-home to the spindle nose measurement (it shouldn't change - ever), then run a Tool 0 touch off, I should know my limit switch and tool setter are in the green.  And, all my tools can be set up with the auto tool setter or outside the machine manually (like if a tool breaks during a long program). 

It seems everyone with routers only wants to use touch off plates and reference everything from the bed.  Trouble for me is ALL the macros and scripts were written this way, and I want to invert that idea and make the machine home the center of the universe!

Please post your code, and I will do the same when I get ours going.  That may give some other folks options!
Title: Re: Again with the tool setter
Post by: barneskite28 on June 16, 2022, 04:11:20 AM
Hi,
Essentially my machine is referenced to the home switches - which are all proximity switches.  The tool lengths reference the distance from the spindle nose, and the work offset is just a zero point at a specific machine coordinate.  In this case i have had good luck with power down and power on - but with Mach4 being so buggy it sometimes does not store the last WCS.  If i am doing a critical job i have also cut a reference circle into my bed/fixture plate - so if all else fails i can model from that point and always ensure to reset within a couple of thou.  The issue that i do have as i mentioned before - is on the z0 moving on the foirst couple of cycles - it did it twice today - the first run being 130mm too high, and the second being 0.8mm too low.  after another setting of z0 it was fine