Hello Guest it is March 28, 2024, 12:37:22 PM

Author Topic: Fast Probing, Back-off and Slow Probing in Manual Tool Change M6  (Read 1682 times)

0 Members and 1 Guest are viewing this topic.

Hello,

i thank you guys who give tons of help. ;)

With help from Daz, I've been able to run M6 so far.

But I'd like to shorten the time needed for tool change.

What code should I insert to probing twice?
(First with relatively fast feed(I think F300 would be enough), the second with slow/precise probing feed(F50 will do))

I think I need to back off about 2mm when the first probing is done. then the second probing starts.


Here is my M6 code I have used so far.

What should I add to the red below?


============================================================


function m6()
    local inst = mc.mcGetInstance();
    local xstart = mc.mcAxisGetPos(inst,0)
    local ystart = mc.mcAxisGetPos(inst,1)
    local guesslen = -100
    local selectedtool = mc.mcToolGetSelected(inst)
    local currenttool = mc.mcToolGetCurrent(inst)
    local toollen = mc.mcToolGetData(inst, mc.MTOOL_MILL_HEIGHT, currenttool)
    if toollen == 0 then toollen = 50 end
    local probestart = guesslen + toollen

   if selectedtool == currenttool then   
   return
   mc.mcCntlSetLastError(inst, "Selected Tool = Current Tool")

   else
   
    mc.mcCntlGcodeExecuteWait(inst,"M05")
    mc.mcCntlGcodeExecuteWait(inst,"M09")

    mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G00 Z0.000")
    mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G00 X1.700 Y1.100")

    mc.mcCntlGcodeExecuteWait(inst,"G04 P4000")
    mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G00 Z"..probestart)

    mc.mcCntlGcodeExecuteWait(inst,"G91 G31 Z-60 F100")
    mc.mcCntlGcodeExecuteWait(inst,"M07")
      local toolz = mc.mcAxisGetPos(inst,2)
      mc.mcCntlGcodeExecuteWait(inst,"M09")

   

    mc.mcCntlGcodeExecuteWait(inst, "G90 G53 G00 Z0.000")
   local changetoo = mc.mcToolGetDesc(inst, selectedtool)
   wx.wxMessageBox("Please change to tool number "..selectedtool.." "..changetoo.." and press OK to continue")
    currenttool = selectedtool
    toollen = mc.mcToolGetData(inst, mc.MTOOL_MILL_HEIGHT, currenttool)
    if toollen == 0 then toollen = 50 end
    probestart = guesslen + toollen
    mc.mcCntlGcodeExecuteWait(inst, "G90 G53 G00 X1.700 Y1.100")
    mc.mcCntlGcodeExecuteWait(inst, "G90 G53 G00 Z"..probestart)
    mc.mcCntlGcodeExecuteWait(inst, "G91 G31 Z-60 F100")
    mc.mcAxisSetPos(inst, 2 , toolz)
    mc.mcCntlGcodeExecuteWait(inst, "G90 G53 G00 Z0.000")
--    mc.mcCntlGcodeExecuteWait(inst,"M03")
--    mc.mcCntlGcodeExecuteWait(inst, "G90 G00 X"..xstart)
--      mc.mcCntlGcodeExecuteWait(inst, "G90 G00 Y"..ystart)
    mc.mcCntlGcodeExecuteWait(inst, "G90 G00 X"..xstart.." Y"..ystart)
--    mc.mcCntlGcodeExecuteWait(inst,"G04 P3000")

    mc.mcToolSetCurrent(inst, selectedtool)
   mc.mcCntlSetLastError(inst, "Toolchange Finished")
    --wx.wxMessageBox('Toolchange Finished')
   end
   
end


if (mc.mcInEditor() == 1) then
    m6()

end
Re: Fast Probing, Back-off and Slow Probing in Manual Tool Change M6
« Reply #1 on: March 03, 2021, 03:56:17 PM »
Hello,
function m6()
    local inst = mc.mcGetInstance();
    local xstart = mc.mcAxisGetPos(inst,0)
    local ystart = mc.mcAxisGetPos(inst,1)
    local guesslen = -100
    local selectedtool = mc.mcToolGetSelected(inst)
    local currenttool = mc.mcToolGetCurrent(inst)
    local toollen = mc.mcToolGetData(inst, mc.MTOOL_MILL_HEIGHT, currenttool)
    if toollen == 0 then toollen = 50 end
    local probestart = guesslen + toollen

   if (selectedtool == currenttool) then   
   return
   mc.mcCntlSetLastError(inst, "Selected Tool = Current Tool, proceeding")

   else
   
    rc = mc.mcCntlGcodeExecuteWait(inst,"M05")
    rc = mc.mcCntlGcodeExecuteWait(inst,"M09")

    rc = mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G00 Z0.000")
    rc = mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G00 X1.700 Y1.100")

    rc = mc.mcCntlGcodeExecuteWait(inst,"G04 P4000")
    rc = mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G00 Z"..probestart)

    rc = mc.mcCntlGcodeExecuteWait(inst,"G91 G31 Z-60 F300")
   rc = mc.mcCntlGcodeExecuteWait(inst,"G91 Z.1")
   rc = mc.mcCntlGcodeExecuteWait(inst,"G91 G31 Z-60 F50")
    rc = mc.mcCntlGcodeExecuteWait(inst,"M07")
   local toolz = mc.mcAxisGetPos(inst,2)
   rc = mc.mcCntlGcodeExecuteWait(inst,"M09")
   

    rc = mc.mcCntlGcodeExecuteWait(inst, "G90 G53 G00 Z0.000")
   local changetoo = mc.mcToolGetDesc(inst, selectedtool)
   wx.wxMessageBox("Please change to tool number "..selectedtool.." "..changetoo.." and press OK to continue")
    currenttool = selectedtool
    rc, toollen = mc.mcToolGetData(inst, mc.MTOOL_MILL_HEIGHT, currenttool)
    if toollen == 0 then toollen = 50 end
    probestart = guesslen + toollen
    rc = mc.mcCntlGcodeExecuteWait(inst, "G90 G53 G00 X1.700 Y1.100")
    rc = mc.mcCntlGcodeExecuteWait(inst, "G90 G53 G00 Z"..probestart)
    rc = mc.mcCntlGcodeExecuteWait(inst, "G91 G31 Z-60 F100")
    rc = mc.mcAxisSetPos(inst, 2 , toolz)
    rc = mc.mcCntlGcodeExecuteWait(inst, "G90 G53 G00 Z0.000")
   --  mc.mcCntlGcodeExecuteWait(inst,"M03")
   --  mc.mcCntlGcodeExecuteWait(inst, "G90 G00 X"..xstart)
   --  mc.mcCntlGcodeExecuteWait(inst, "G90 G00 Y"..ystart)
    rc = mc.mcCntlGcodeExecuteWait(inst, "G90 G00 X"..xstart.." Y"..ystart)
   --  mc.mcCntlGcodeExecuteWait(inst,"G04 P3000")
    rc = mc.mcToolSetCurrent(inst, selectedtool)
   rc = mc.mcCntlSetLastError(inst, "Toolchange Finished")
    --wx.wxMessageBox('Toolchange Finished')
   end
   
end

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


This should help, I haven't tested it myself obviously.
If it doesn't work let me know and I'll swap some stuff around, I tried to do some housekeeping with the return codes but I'm slack with them too :)
Also remember probing speed has a great deal to do with accuracy, sometimes slowing down will speed you up!
Let me know how it goes.
Re: Fast Probing, Back-off and Slow Probing in Manual Tool Change M6
« Reply #2 on: March 03, 2021, 09:38:46 PM »
Thank you GOOMBA,

With your help I could tune my script. ;)
I made some modifications from yours. Without your help I couldn't make it at all. ;)

Now my machine works perfectly as I want it to do.
Re: Fast Probing, Back-off and Slow Probing in Manual Tool Change M6
« Reply #3 on: March 05, 2021, 02:39:23 AM »
can you kindly make a video of how the sequence happens?
topic may interest many people.
thank you!
Re: Fast Probing, Back-off and Slow Probing in Manual Tool Change M6
« Reply #4 on: March 05, 2021, 03:48:37 AM »
can you kindly make a video of how the sequence happens?
topic may interest many people.
thank you!

I took a video but could not upload here.

It's simple. This is to reduce time for tool change.

As for now,

my spindle goes down "G0" to the "Safe" height, and then start probing with F300, when it touches the probe, it takes back in 2mm and starts probing again for getting the height.

To apply this, one should understand how manual tool change works. Youtube videos from DazTheGas will be a great help.

If you fully understand it, you can just imagine how the code above will work. ;)
Re: Fast Probing, Back-off and Slow Probing in Manual Tool Change M6
« Reply #5 on: March 05, 2021, 04:12:01 AM »
which video are you talking about?
posting new videos on YouTube would be of great use to expand Mach4 knowledge!
people have to convince themselves that Mach4 is much superior to Mach3!
to do this you need information!
Re: Fast Probing, Back-off and Slow Probing in Manual Tool Change M6
« Reply #6 on: March 05, 2021, 09:18:54 AM »
Hello Daniba,
If you're not sure what this looks like then you don't fundamentally understand what the code is doing.
If you don't understand it then you shouldn't manipulate it until you do.
The "mc.mcCntlGcodeExecuteWait" moves are simple GCODE moves as if you wrote a MDI line (kind of) and then executed.
If you can see the lines, run each one in the MDI window (without the API call) and you'll see what it does :)
As for the YouTube videos, I plan to start working on some basics however it's very hard to provide a quality video that addresses all of the components of scripting or even basic GCODE while making it consumable. Problems of a support tech  ;D
Re: Fast Probing, Back-off and Slow Probing in Manual Tool Change M6
« Reply #7 on: March 06, 2021, 06:36:25 PM »
I was able to run M06 macros!
to be honest, I don't really like his behavior.
why do you want to measure the current cutter before the change?
example:
during the transition from tool 2 to tool 3, was tool 2 damaged or broken?
what can it entail?
can lead to incorrect calculations?
from what I understand I don't think so, because it uses the value of the called tool.
so why measure the previous tool ??
I don't understand the need for this step.
besides being useless, it only wastes time.
in Mach3 I used 2 buttons with great success.
the first was the "Probe Set"
the second "A.T.Z."
I set zero piece.
then I pressed the "Probe Set" button.
length of the current instrument detected and a value stored.
from that moment on, at each tool change I simply pressed "A.T.Z."
even though the tip broke, I replaced it, I pressed A.T.Z. and I was immediately ready and confident.
would it be possible to do it with Mach4 too?
would it be possible to convert Mach3 scripts to Mach4?
I point out that if there are spelling mistakes the reason is that I use a translator.
Re: Fast Probing, Back-off and Slow Probing in Manual Tool Change M6
« Reply #8 on: March 06, 2021, 10:08:16 PM »
Hello Daniba

I think you are getting the wrong point.
The point of this thread is not about measuring tool length before tool change, but about more accurate measuring with very low feed rate but at the same time minimizing time needed.

Measuring length before changing is not the topic. ;)
Re: Fast Probing, Back-off and Slow Probing in Manual Tool Change M6
« Reply #9 on: March 07, 2021, 02:07:41 AM »
Yes you are right.
sorry.