Hi,
I think you are still doing the same thing:
function SetDepth()
------ Auto Depth Setting ------
function SetDepth()
------ Auto Depth Setting ------
mc.mcCntlGcodeExecuteWait(inst, "G00 G53 X35.93 Y2.75\n") -- go to point over depth setter
mc.mcCntlSetLastError(inst, 'Setting Tool Height')
mc.mcCntlGcodeExecuteWait(inst, "G91 G31 Z-4 F50") --probe the new tool
mc.mcCntlGcodeExecuteWait(inst, "G91 G0 Z+0.1") --Retract from the probe
mc.mcCntlGcodeExecuteWait(inst, "G91 G31 Z-0.15 F5") --Probes at slow speed
local measure_1 = mc.mcAxisGetPos(inst,2) --Saves probed Z position
mc.mcCntlSetLastError(inst, 'Setting Tool Height')
mc.mcCntlGcodeExecuteWait(inst, "G91 G31 Z-4 F50") --probe the new tool
mc.mcCntlGcodeExecuteWait(inst, "G91 G0 Z+0.1") --Retract from the probe
mc.mcCntlGcodeExecuteWait(inst, "G91 G31 Z-0.15 F5") --Probes at slow speed
local measure_1 = mc.mcAxisGetPos(inst,2) --Saves probed Z position
OK, m6 calls M1000(), so m6 is caller. M1000 calls SetDepth(), so M1000 is caller. Now SetDepth attempts to execute:
mc.mcCntlGcodeExecuteWait(inst, "G00 G53 X35.93 Y2.75\n") -- go to point over depth setter, the first
mc.CntlGcodeExecuteWait() instruction and fails because the GCode interpreter is busy.....still.
May I suggest you try some diagnostic code. First put a few wxMessageBox statements so that you can confirm that
program control reached that juncture. The second is that you are going to have to test the return code of the
mc.CntlGcodeExecuteWait() instruction. The third is to report the machine state.
Modify your code like this:
local inst = mc.mcGetInstance()
local ZGageBlockHeight = 3.3091
function m1000()
------ Auto Depth Setting ------
wx.wxMessageBox("M1000() called")
SetDepth()
end
function SetDepth()
------ Auto Depth Setting ------
wx.wxMessageBox("SetDepth() called")
local rc= mc.mcCntlGcodeExecuteWait(inst, "G00 G53 X35.93 Y2.75\n") -- go to point over depth setter
local mcState=mc.mcCntlGetState(inst)
wx.wxMessageBox(tostring(rc)..' '..tostring(mcState))
mc.mcCntlSetLastError(inst, 'Setting Tool Height')
mc.mcCntlGcodeExecuteWait(inst, "G91 G31 Z-4 F50") --probe the new tool
mc.mcCntlGcodeExecuteWait(inst, "G91 G0 Z+0.1") --Retract from the probe
mc.mcCntlGcodeExecuteWait(inst, "G91 G31 Z-0.15 F5") --Probes at slow speed
local measure_1 = mc.mcAxisGetPos(inst,2) --Saves probed Z position
When you run your code I expect to to get three message box notifications.
The first will be "M1000() called", ie that m6 has successfully called M1000.
The second will be "SetDepth() called", ie that M100 has successfully transferred control to SetDepth().
The last is the truly critical notification. If the mc.CntlGcodeExecuteWait() instruction completed normally
then the return code will be "0". If it does not complete correctly I suspect the return code will be "-18".
That corresponds to the error MERROR_NOT_NOW which is just another way to say the Gcode interpreter is busy.
The same message notification will provide a numeric value for the machine state. My guess is it will be either 108 or 207.
Either way it will tell us more.
Try the code and report how you get on.
Craig