Hello Guest it is April 18, 2024, 11:22:35 AM

Author Topic: mcCntlGcodeExecute best practice  (Read 1160 times)

0 Members and 1 Guest are viewing this topic.

mcCntlGcodeExecute best practice
« on: January 26, 2019, 04:05:03 PM »
Does anyone know if there is a way to check on the status of a gcode execution?  I have been using mc.mcCntlGcodeExecuteWait with no issues, but I want to be able to check the state of an input while the gcode is being run and then wait until it is done to move on to the next line of Lua. I am assuming that I can use mcCntlGcodeExecute to do this, but I can't figure out how to know when it is done.

Thanks,
David
Re: mcCntlGcodeExecute best practice
« Reply #1 on: January 26, 2019, 05:47:39 PM »
Hi,
there is another API which is more suitable and recommended under most circumstances:

Code: [Select]
LUA Syntax:
rc = mc.mcCntlGcodeExecuteWait(
number mInst,
string commands)

Description:
Execute G code as a unit of work and wait until it is complete

Note also that it has a return code which can be tested for success.

Code: [Select]
Returns: Return Code Description
MERROR_NOERROR No Error.
MERROR_INVALID_INSTANCE The mInst parameter was out of range.
MERROR_NOT_NOW The operation could not be completed at this time.
MERROR_NOT_COMPILED The macro scripts could not be compiled.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: mcCntlGcodeExecute best practice
« Reply #2 on: January 26, 2019, 07:03:05 PM »
Hi,
re-reading your post a little more closely and I'm thinking my previous rely is 'out to lunch'.

If I understand what you are asking is whether you can test a signal or other input WHILE a move is in progress?

If that is the case the GcodeExexcuteWait() will not work because the Gcode interpreter is hogging the CPU and there is
no way for Machs Core to do any other work.

If however you use GcodeExecute() then the function will return once it has issued instructions to the motion controller.
Thus Machs Core could presumably do something in the mean time. I'm not quite sure how it would work.
Maybe:
rc = mc.mcSignalWait(
      number mInst,
      number sigId,
      number waitMode,
      number timeoutSecs);

would work.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: mcCntlGcodeExecute best practice
« Reply #3 on: January 28, 2019, 12:00:41 PM »
Thanks Craig for the suggestions.
I think it looks like I need to use mc.mcCntlGetState
Found my answer here: https://www.machsupport.com/forum/index.php?topic=36018.0

Offline gorf23

*
  •  189 189
    • View Profile
Re: mcCntlGcodeExecute best practice
« Reply #4 on: January 29, 2019, 04:18:32 PM »
I have used GcodeExecute() and then set a variable true or false  to run in the plc that will update the screen dro for the axis running works ok no gui lockup