Hello Guest it is March 28, 2024, 05:35:06 AM

Author Topic: Why won't this M3 Macro not execute in G-code or MDI  (Read 766 times)

0 Members and 1 Guest are viewing this topic.

Why won't this M3 Macro not execute in G-code or MDI
« on: March 23, 2020, 07:19:11 PM »
This M3 macro will not execute from G-code or MDI.  The M3 line in G-Code is just skipped.
-----------------------
function m3()   
local inst = mc.mcGetInstance()
local torchHeightInput, rc= scr.GetProperty("torchHeightInput", "Value")
mc.mcCntlSetLastError(inst, "rc code="..rc)
mc.mcCntlSetLastError(inst, "This is the new turning on torch!")
mc.mcCntlGcodeExecuteWait(inst,"m62p1")
end
----------------------

However, this one will:
----------------------
function m3()   
local inst = mc.mcGetInstance()
mc.mcCntlSetLastError(inst, "rc code="..rc)
mc.mcCntlSetLastError(inst, "This is the new turning on torch!")
mc.mcCntlGcodeExecuteWait(inst,"m62p1")
end
---------------------
This line is the difference: local torchHeightInput, rc= scr.GetProperty("torchHeightInput", "Value").
I have used this line many time in stand alone macros.  I am at a loss.
Re: Why won't this M3 Macro not execute in G-code or MDI
« Reply #1 on: March 23, 2020, 07:49:49 PM »
I added an extremely simple line that still cause the M3 line in G-Code to be skipped
----------------------------------------------------------
function m3()   
local inst = mc.mcGetInstance()
local torchHeightInput=0.06
mc.mcCntlSetLastError(inst, "rc code="..rc)
mc.mcCntlSetLastError(inst, "This is the new turning on torch!!!")
mc.mcCntlGcodeExecuteWait(inst,"m62p1")
end
------------------------------------------------------------
if the line "local torchHeightInput=0.06" is removed, everything executes as expected.  What the...?

Offline smurph

*
  • *
  •  1,544 1,544
  • "That there... that's an RV."
    • View Profile
Re: Why won't this M3 Macro not execute in G-code or MDI
« Reply #2 on: March 23, 2020, 08:18:46 PM »
Spend a bit of time learning to use the debugger.  The Zerobrane editor has a great debugger and it will show you where the issue is.  It is also very important to "compile" your macro scripts in the editor.  It will check for syntax errors.  Then run the debugger to catch runtime errors. 

Why would you use M62 in your M code?  That is to set an output that is synchronized with motion.  If you are executing M3, there is no motion!  Use mc.mcSignalGetHandle() and mc.mcSignalSetState() instead. 

Steve
Re: Why won't this M3 Macro not execute in G-code or MDI
« Reply #3 on: March 23, 2020, 09:51:23 PM »
Thanks for the quick reply.  I appreciate it.  I do compile my scripts in the editor and delete the .mcc files to force a recompile in Mach4 before I retry executing.  There are no syntax errors.  As far as the debugger goes, I have used it and it is not indicating any issues.  In addition, there are no errors being thrown at run time.  By printing debug statements to the error log you can get narrow down to the line that is causing the issue at run time.  It is the line that contains  scr.GetProperty("torchHeightInput", "Value").  The debugger indicates that zero length string is getting returned, which would cause no problem in the macro as it isn't getting used anywhere anyway.  As I stated, I have used this exact line in button scripts and have had no issues. I am at a loss where to go from here. I guess I was hoping that someone would point out that you can't use a scr.GetProperty() in a customs M3 macro (or something to that effect).  If I copy the code to a button script and comment out the G-code call, everything works okay including getting the correct value from the "torchHeightInput" text box on the screen.  There seems to be something that is an idiosyncrasy to call a custom M3.     

As far as M62 goes, that is how Warp9 Tech wants you to turn a torch on and off (M64) if you want to use some of the nice features in their Smoothstepper hardware such as torch collision detection that has resume capabilities.  The reason I am writing an M3 macro to kick off the M62 is that the post processor from Fusion360 outputs M3/M5 and I am trying to avoid further post processing of the G-Code files.