Hello Guest it is June 14, 2025, 05:30:15 PM

Author Topic: Feed hold mc command not working?  (Read 4381 times)

0 Members and 1 Guest are viewing this topic.

Feed hold mc command not working?
« on: January 11, 2025, 03:37:08 PM »
OK, I've spent an embarrasingly long time scratching my head on this one.  I'm mapping some physical buttons to Gcode start/Feed hold and Stop.  The buttons work fine, however for some reason I am unable to get the following code to switch between cycle start and feed hold.

I have tried a couple of different signals to indicate that gcode is running, neither mc.mcCntlIsInCycle nor mc.OSIG_RUNNUNG_GCODE work.

Code: [Select]
[mc.ISIG_INPUT8] = function (state) -- Console Start/Feed Hold button
    local inst = mc.mcGetInstance()
    local sigh = mc.mcSignalGetHandle(inst, mc.OSIG_RUNNING_GCODE);
local holdState = mc.mcSignalGetState(sigh);
    if (state == 1) then
        if (holdState == TRUE) then
            wx.wxMessageBox('This feed had better be held!');
mc.mcCntlFeedHold (inst)
else
                        CycleStart()
end
end
end,

I'm clearly missing something obvious
Re: Feed hold mc command not working?
« Reply #1 on: January 12, 2025, 12:45:18 PM »
Change TRUE to lowercase true
Re: Feed hold mc command not working?
« Reply #2 on: January 12, 2025, 01:44:49 PM »
I started there actually :( i also tried == 1

Offline smurph

*
  • *
  •  1,574 1,574
  • "That there... that's an RV."
Re: Feed hold mc command not working?
« Reply #3 on: January 14, 2025, 05:30:47 PM »
Technically, if the file is running, then OSIG_RUNNING_GCODE will always be high.  The file is still running however it is running at zero velocity.  I would use mc.mcCntlGetState() with mc.MC_STATE_FRUN_FH and mc.MC_STATE_MRUN_FH (File Feed Hold and MDI Feed hold states). 
Code: [Select]
[mc.ISIG_INPUT8] = function (state) -- Console Start/Feed Hold button
    local inst = mc.mcGetInstance()
    local mstate = mc.mcCntlGetState(inst)
    if (state == 1) then
        if (mstate == mc.MC_STATE_FRUN_FH) or (mstate == mc.MC_STATE_MRUN_FH) then
            -- We are in the feed hold state, so do Cycle Start()
            CycleStart()
        elseif (mstate == mc.MC_STATE_FRUN) or (mstate == mc.MC_STATE_FRUN) then
            -- The file or MDI is running.
            wx.wxMessageBox('This feed had better be held!')  -- I don't like message boxes because they are modal.  I much prefer mc.mcCntlSetLastError(). 
    mc.mcCntlFeedHold(inst)
        end
    end
end,

Steve

Offline smurph

*
  • *
  •  1,574 1,574
  • "That there... that's an RV."
Re: Feed hold mc command not working?
« Reply #4 on: January 14, 2025, 05:35:57 PM »
This could be done in the PMC for a solution with less "programming".

Re: Feed hold mc command not working?
« Reply #5 on: January 15, 2025, 12:54:49 AM »
Nice! I will check it out.  Believe it or not, ladder logic escapes me but i can understand Lua (except for these machine-specific idiosyncrasies)

Thanks!
Re: Feed hold mc command not working?
« Reply #6 on: January 17, 2025, 12:10:37 PM »
All is working.  I thought I would post my final code snippet in case anyone wants it in the future.

This snippet fixes my issue and builds a bit on what we discussed.  In the end, I needed the button to start the gcode/mdi initially and work like a play/pause button after it had started running.  (The button on my console is labeled "START/Feed hold")

Code: [Select]
[mc.ISIG_INPUT8] = function (state) -- Console Start/Feed Hold button
local inst = mc.mcGetInstance()
local mstate = mc.mcCntlGetState(inst)
if (state == 1) then
if (mstate == mc.MC_STATE_FRUN) or (mstate == mc.MC_STATE_MRUN) then --if either gcode or macro is running
mc.mcCntlFeedHold (inst) --execute feed hold
                elseif (mstate == mc.MC_STATE_FRUN_FH) or (mstate == mc.MC_STATE_MRUN_FH) then  --otherwise if in feed hold
--            -- We are in the feed hold state, so do Cycle Start()
                        CycleStart()
        else -- and if the code is not running at all yet...
                CycleStart()
end
end
end,
Re: Feed hold mc command not working?
« Reply #7 on: May 22, 2025, 06:21:52 AM »
Thank you for doing the
leg work !
Need this exact code for the mill I'm building.

So thank you much!
Re: Feed hold mc command not working?
« Reply #8 on: May 22, 2025, 02:32:50 PM »
Happy i could help.  My machine would not have been possible without the help on this board. I know how seemingly small things can turn into huge black holes of time! Haha