Hello Guest it is September 19, 2020, 01:57:37 AM

Author Topic: Macro help mcCntlGcodeExecuteWait  (Read 975 times)

0 Members and 1 Guest are viewing this topic.

Macro help mcCntlGcodeExecuteWait
« on: November 03, 2017, 06:16:52 PM »
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?

Code: [Select]
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')
--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)
      mc.mcCntlSetLastError(inst,"Peck Drill From "..zStart.." to "..zEnd)
    return 0
--macro assumes that you want to drill 60% through the material 
  if zStart<=zEnd then
    wx.wxMessageBox("zStart  is <= to zEnd")
    return 0

--Peck Drill
  sCode=sCode.."M3 S"..tostring(roughSpeed).."\n"
  sCode=sCode.."g83 x0 z"..zEnd.." r0 q.30 p.1 f4\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.mcCntlSetLastError(inst,"Pecking Time: "..string.format("%.1f min",tr))
  return 1
if mc.mcInEditor()==1 then

Any help Greatly appreciated.

Re: Macro help mcCntlGcodeExecuteWait
« Reply #1 on: November 03, 2017, 06:46:03 PM »
Hi Rt,
not sure this will help but its something I had to learn and it caused some confusion and angst before I understood.

g83 is modal, in fact quite a few of the canned cycles are. so if you write:
g83 x0 z.6 r0 q.30 p.1 f4
and then in subsequent lines
x0 z 1
x.5 z1.5
x1 z2.0
at each line the machine would attempt a g83 cycle with parameters
g83 x.5 z1.5 r0q.30 f4 for instance

Ignoring the fact that these cycles are nonsensical with your machine I point this out because you machine is reading
another line of code and attempting to do another g83 cycle despite the fact that you don't want it. What I would suggest is that you conclude your
g83 cycle with another motion code that will break the modal nature of g83. I haven't used g80 myself but I think its intent is to break a modal.

g83 x0 z.6 r0 q.30 p.1 f4 \n g80

I would be using mcCntlGcodeExecuteWait.

My wife left with my best friend...
     and I miss him!
Re: Macro help mcCntlGcodeExecuteWait
« Reply #2 on: November 03, 2017, 07:18:53 PM »
found this on page 36 of the Mill Gcode manual.

My wife left with my best friend...
     and I miss him!
Re: Macro help mcCntlGcodeExecuteWait
« Reply #3 on: November 03, 2017, 07:54:26 PM »
Crap, senior moment again, I typed M80 instead of G80.
Re: Macro help mcCntlGcodeExecuteWait
« Reply #4 on: November 03, 2017, 09:28:33 PM »
Hi RT,
I've gotten into the habit of coding macros with lowercase m and gcodes with lowercase g. Machs interpreter decodes to lowercase and strips out leading zeros.
So M03 gets decoded as m3 etc. In most cases what it gets decoded to is unique and causes no problems but there are times when its not so and an error
results. I now prefer to code in a manner that doesn't require either Mach or Windows to have to interpret what I mean.

Shame of it is that if your trying to explain to someone else what your doing uppercase Ms and Gs are more readable even if m and g are more accurate.

My wife left with my best friend...
     and I miss him!