Using latest build 3481 -pmdx411 - Lathe mode
When I use this code in the MDI it functions as expected
g83 x0 z.6 r0 q.30 p.1 f4
so I don't think this is pmdx related
I have tried running the macro from both the mdi: M6999 D1.5
and from a button that gets the current Zaxis position and calls(correctly) the macro
I have tried mcCntlGcodeExecute and mcCntlGcodeExecuteWait and both basically run as expected, peck to.6 on the Zaxis but then continues on for another cycle and then just keeps going past the .6 mark.
I have also tried mcCntlMdiExecute and it wont run at all.
What am I missing in the macro sCode string?
Which api call should I be using?
function m6999(hVars)
local roughFeed=4
local roughSpeed=600
local zStart=0
local zEnd=0
local inst=mc.mcGetInstance()
-- make sure the spindle is set in low gear, manual change
if mc.mcSpindleGetCurrentRange(inst)~=0 then
wx.wxMessageBox('Set Spindle Gearing to Low Speed')
mc.mcSpindleSetRange(inst,0)
end
--make sure the macro is called with the current z position
if (hVars ~= nil) then
local DFlag = mc.mcCntlGetLocalVarFlag(inst, hVars, mc.SV_D)
if(DFlag == 1) then
zStart = mc.mcCntlGetLocalVar(inst, hVars, mc.SV_D)
zEnd=zStart*.4
mc.mcCntlSetLastError(inst,"Peck Drill From "..zStart.." to "..zEnd)
end
else
wx.wxMessageBox("hVars=nil")
return 0
end
--macro assumes that you want to drill 60% through the material
if zStart<=zEnd then
wx.wxMessageBox("zStart is <= to zEnd")
return 0
end
ts=os.time()
--Peck Drill
sCode=""
sCode=sCode.."M3 S"..tostring(roughSpeed).."\n"
sCode=sCode.."g83 x0 z"..zEnd.." r0 q.30 p.1 f4\n"
sCode=sCode.."M80".."\n"
sCode=sCode.."M5".."\n"
-- move back an inch to allow for the swapping of reel seat end to finish through drill
sCode=sCode.."g0 z"..tostring(zStart+1).."\n"
-- wx.wxMessageBox(sCode)
mc.mcCntlGcodeExecuteWait(inst,sCode)
tr=os.difftime(os.time(),ts)/60
mc.mcCntlSetLastError(inst,"Pecking Time: "..string.format("%.1f min",tr))
return 1
end
if mc.mcInEditor()==1 then
m6999()
end
Any help Greatly appreciated.
RT