Hello Guest it is May 10, 2021, 08:20:50 PM

Author Topic: M6 Tool change is skipped in MACH4.  (Read 1289 times)

0 Members and 1 Guest are viewing this topic.

Offline Julie

*
  •  18 18
    • View Profile
M6 Tool change is skipped in MACH4.
« on: April 20, 2017, 04:52:49 AM »
Hello,

I created a new DRO on the screen, input it and am trying to use it in the M6 for tool change.
The names of the DRO on the screen are Xpos1, Ypos1, PlateThicknes.
And i created variables like below in M6 script.

local xstart= scr.GetProperty("Xpos1", "Value")
local ystart = scr.GetProperty("Ypos1", "Value")
local StrikePlateThickness= scr.GetProperty("PlateThickness", "Value")

But T2 M6(Tool change G-code) is skipped when simulate.
If the above three lines are deleted, they are executed without skipping.

I do not know what is the problem.

** I referred to the data of DazTheGas.
    Thanks, DazTheGas. ;)



Code: [Select]
function m6()

    local inst = mc.mcGetInstance()
    local ProbeSignal = mc.ISIG_DIGITIZE
    local MaxToolNum = 6   ---- MaxToolNum = 6  
    local ToolUp = -5
    local SelectedTool = mc.mcToolGetSelected(inst)
    local CurrentTool = mc.mcToolGetCurrent(inst)    
    local xstart = scr.GetProperty("Xpos1", "Value")
    local ystart = scr.GetProperty("Ypos1", "Value")
    local StrikePlateThickness = scr.GetProperty("PlateThickness", "Value")
    
        ------------- Get touch off parameters -------------
 
if selectedtool == currenttool then
    return
mc.mcCntlSetLastError(inst, "Current tool == Selected tool so there is nothing to do")
else

        mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z0.0")
        mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 X14 Y30")
        mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z"..probestart)
        mc.mcCntlGcodeExecuteWait(inst, "G91 G31 Z-15 F25")
        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")
        currenttool = selectedtool
        toollen = mc.mcToolGetData(inst, mc.MTOOL_MILL_HEIGHT, currenttool)
        probestart = guesslen + toollen
        mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 X14 Y30")
        mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z"..probestart)
        mc.mcCntlGcodeExecuteWait(inst, "G91 G31 Z-15 F25")
        mc.mcAxisSetPos(inst, 2 , toolz)
        mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z0.0")
        mc.mcCntlGcodeExecuteWait(inst,"G90 G0 X"..xstart.." Y"..ystart)
        mc.mcToolSetCurrent(inst, selectedtool)
        wx.wxMessageBox('Toolchange finished')  
        mc.mcAxisSetPos(inst, 2 , toolz)
        mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z0.0")
        mc.mcCntlGcodeExecuteWait(inst,"G90 G0 X"..xstart.." Y"..ystart)
        mc.mcToolSetCurrent(inst, selectedtool)
        wx.wxMessageBox('Toolchange finished')

        mc.mcCntlToolChangeManual(inst, true);
mc.mcCntlSetLastError(inst, "Current tool == " .. tostring(selectedtool) .. "   Previous Tool == " .. tostring(currenttool))
mc.mcToolSetCurrent(inst, selectedtool)
end
end


if (mc.mcInEditor() == 1) then
    M6()
end
« Last Edit: April 20, 2017, 04:58:59 AM by Hyojung »

Offline Julie

*
  •  18 18
    • View Profile
Re: M6 Tool change is skipped in MACH4.
« Reply #1 on: April 21, 2017, 10:27:59 PM »
There is typing error in code, M6->m6.

But if there are "scr.GetProperty" command lines, it is skipped still.

« Last Edit: April 21, 2017, 10:32:12 PM by Julie »