Machsupport Forum

Mach Discussion => Mach4 General Discussion => Topic started by: Wallerawang on October 22, 2017, 05:12:11 AM

Title: Jogging while doing a tool change?
Post by: Wallerawang on October 22, 2017, 05:12:11 AM
Hello

I'm a very happy Mach 4 user, just tidying up the last part of my system.

I have one of these tool length setters as in the attached file - it works great and seems to be very repeatable. I use the DaztheGas M6 auto tool change script as to measure the tool length when I change tools - this works great on my smaller tools that hit the tool length setter OK - ones that are small enough to align with the probe as programmed in the script.

When I want to use a facing cutter or a fly cutter they are too big to hit the tool length setter and need alignment so a tooth will hit the setter this is where I need some help please. Ideally I would like to pause the the auto tool change, jog to adjust the position of the tool to be above the setter and then continue with the tool length probing. I have tried to do this but I can not take control of the machine to jog it around during the M6 command.

Is there any way to do this that you guys know of? Or any other suggestions - I could go back to the manual tool change if needed but I would like to probe the tool length during a manual change is that possible? 

Thanks for your help.

Steve
Title: Re: Jogging while doing a tool change?
Post by: joeaverage on October 22, 2017, 11:37:17 PM
Hi,
its not quite as straight forward as you might think.

When a Gcode job is running the motion controller is being directed by Machs Gcode interpreter and trajectory planner. Even when you execute an m6
toolchange macro the Gcode interpreter is still in charge. What you want to do is have the jogging functions built in to Machs GUI take over temporarily
so you can jog to an appropriate location for probing and then revert back to the Gcode interpreter.

The problem is that given that you've jogged away from the exact toolpath that the Gcode specified.  When the interpreter takes over again it is not starting
from a known point along that path but some other location and could have unpredictable results.

If you are to achieve the behaviour you wish there are two hurdles I can see that you will have to overcome.
1) You need to be able to stop the Gcode interpreter without loss of place or status and offer up motion control to the jog functions.
2) Once you've jogged to the right location and set the tool length then the machine needs to go back to the last known good point on the toolpath,
    reinstate the status of the interpreter, have control revert to the interpreter.

I can't think of any ready solutions at the moment however feel sure that this behaviour could be achieved, after all customisation is Mach4s strength.

Craig
Title: Re: Jogging while doing a tool change?
Post by: joeaverage on October 23, 2017, 12:46:39 AM
Hi,
can you post your m6 macro as it is.

I'm using one of the example m6s that come with Mach4. It may be quite different with your m6.

The only way I can see that you can jog is to stop the current cycle, do the business and <cycle start>
Code: [Select]
    mc.mcCntlFeedHold(inst)
    mc.mcCntlCycleStop(inst)

Now you can jog around and MDI a toollength measuring macro for instance.

Craig
Title: Re: Jogging while doing a tool change?
Post by: Wallerawang on October 23, 2017, 01:16:29 AM
Hi Craig - It's directly from DazTheGas as below.

function M6()
    local inst = mc.mcGetInstance();
    local selectedtool = mc.mcToolGetSelected(inst)
    local currenttool = mc.mcToolGetCurrent(inst)
    local xstart = mc.mcAxisGetPos(inst,0)
    local ystart = mc.mcAxisGetPos(inst,1)

    if selectedtool == currenttool then
    return
    mc.mcCntlSetLastError(inst, "ToolChange Activated But Not Required")
    else
    mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z0.0 \n X14 Y30")
    wx.wxMessageBox("Please turn off spindle and click ok to continue") --can be removed if required
    RunProbe(currenttool)
    local toolz = mc.mcAxisGetPos(inst,2)
    mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z0.0")
    local changetoo = mc.mcToolGetDesc(inst,selectedtool)
    wx.wxMessageBox("Please change to tool number "..selectedtool.." "..changetoo.." and press ok to continue")
    mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 X14 Y30")
    RunProbe(selectedtool)
    mc.mcAxisSetPos(inst, 2 , toolz)
    mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z0.0")
    wx.wxMessageBox("Please turn on spindle and click ok to continue") --can be removed if required
    mc.mcCntlGcodeExecuteWait(inst,"G90 G0 X"..xstart.." Y"..ystart)
    mc.mcToolSetCurrent(inst, selectedtool)
    mc.mcCntlSetLastError(inst, "ToolChange Finished")
    end
end

function RunProbe(tool)
    local inst = mc.mcGetInstance()
    toollen = mc.mcToolGetData(inst, mc.MTOOL_MILL_HEIGHT, tool)
    if toollen == 0 then toollen = 40 end -- User Preference
    mc.mcCntlSetLastError(inst, "Changing to Fallback Length")
    local probestart = -60 + toollen
    mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z"..probestart.."\nG91 G31 Z-15 F25")
end

if (mc.mcInEditor() == 1) then
    M6()
end
Title: Re: Jogging while doing a tool change?
Post by: joeaverage on October 23, 2017, 01:52:28 AM
Hi,
and this code works ok, ie automatically with ordinary tools?

Do you have a specific tool number or numbers for which you require the ability to jog?

My thinking goes that this macro should run as is except say for tools 6,7 and 8 all being facing tools. In which case they will necessarily do a cycle stop so
you can jog and then restart with your runprobe function.

Craig
Title: Re: Jogging while doing a tool change?
Post by: DazTheGas on October 23, 2017, 05:37:49 AM
Hi,
its not quite as straight forward as you might think.

Actually its very easy to do by adding an if statement to change coordinates as per tool IE

Code: [Select]
wx.wxMessageBox("Please change to tool number "..selectedtool.." "..changetoo.." and press ok to continue")
if (selectedtool == 6) then
   mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 X14 Y30")
elseif (selectedtool == 7) then
mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 X20 Y40")
elseif (selectedtool == 8) then
mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 X10 Y40")
end

DazTheGas
Title: Re: Jogging while doing a tool change?
Post by: joeaverage on October 23, 2017, 06:02:20 AM
Hi Daz,
yes that's a good solution if you know the co-ords you need to go to for each facing tool. OP asked about jogging the tool into a suitable position
and that is a bit trickier. It requires, to my knowledge, that the cycle be stopped so jogging is active, then probing, then restarting the Gcode job.

Wallerwang, what do you wish to do?. As Daz points out if you know your facing tools there is a simple extension to your existing macro. If you want to
jog the tool...well that's harder.

Maybe you could try both...the easy one first and 'build up a head of steam' before the tricky one.

Craig

Title: Re: Jogging while doing a tool change?
Post by: Wallerawang on October 23, 2017, 07:21:26 PM
Thanks very much guys, I will try Daz's method on the week end - I've had luck with his methods before.
Steve
Title: Re: Jogging while doing a tool change?
Post by: Cbyrdtopper on October 24, 2017, 08:31:38 AM
Steve,
Just curious, how repeatable is that probe?  I've seen it online before.
Title: Re: Jogging while doing a tool change?
Post by: Wallerawang on October 24, 2017, 10:49:27 AM
Steve,
Just curious, how repeatable is that probe?  I've seen it online before.


My DRO reads in 0.005mm and it's less then that.  In the imperial system that less than a few tenth's of a thou.
Steve
Title: Re: Jogging while doing a tool change?
Post by: Cbyrdtopper on October 24, 2017, 10:58:55 AM
Awesome, Steve.  Thanks!
Title: Re: Jogging while doing a tool change?
Post by: Wallerawang on October 24, 2017, 03:40:25 PM
Hi Daz
I'm just wondering if it is possible to use the tool diameter info in the tool table to set an offset to move the x axis so a large tool would line up with the setter? Like you used the tool length info to set the probe start position?
Thanks
Steve
Title: Re: Jogging while doing a tool change?
Post by: DazTheGas on October 24, 2017, 03:48:32 PM
Anything is possible, I will take a look as the tooltable is now very customisable.

DazTheGas
Title: Re: Jogging while doing a tool change?
Post by: DazTheGas on October 24, 2017, 04:10:42 PM
A simpler way would be to go into the tooltable and add 2 user fields ie XProbe and YProbe and make these integers, you can then call these like

Code: [Select]
local xpos = mc.mcToolGetDataExInt(inst, selectedtool, XProbe)
local ypos = mc.mcToolGetDataExInt(inst, selectedtool, YProbe)
mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z0.0 \n X"..xpos.." Y"..ypos)

obviously you would have to populate the table for all tools which should be straight forward.

DazTheGas
Title: Re: Jogging while doing a tool change?
Post by: Wallerawang on October 24, 2017, 05:42:56 PM
Thanks Daz - Guess what I'll be doing this weekend. :)
Title: Re: Jogging while doing a tool change?
Post by: Wallerawang on October 29, 2017, 04:09:52 AM
Thanks to everyone that helped. I only have 2 tools that don't hit the tool probe so I just went with the If, Then, Else, option and it work great. Video link attatched.


Steve

https://youtu.be/y-rBoPp9C1M (https://youtu.be/y-rBoPp9C1M)
Title: Re: Jogging while doing a tool change?
Post by: DazTheGas on October 29, 2017, 04:46:11 AM
Glad you got it sorted :-)

DazTheGas