Hello Guest it is March 28, 2024, 04:19:35 PM

Author Topic: MACH4 Mcode testing  (Read 13198 times)

0 Members and 1 Guest are viewing this topic.

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: MACH4 Mcode testing
« Reply #20 on: May 27, 2014, 07:42:23 PM »
OK that makes sense.

Thanks (;-) TP

Offline poppabear

*
  • *
  •  2,235 2,235
  • Briceville, TN, USA
    • View Profile
Re: MACH4 Mcode testing
« Reply #21 on: May 27, 2014, 10:16:54 PM »
Terry, just so I understand (or not) what your trying to do, I have this in my m3 macro:

function m3()
    local inst = mc.mcGetInstance();
    local sigh = mc.mcSignalGetHandle(inst, mc.OSIG_SPINDLEON);
    local sigState = mc.mcSignalGetState(sigh);

    if (sigState == 0) then
        mc.mcSpindleSetDirection(inst, 1);
        --dir is:  -1=ccw, 1=cw, 0=off    
    end

    local dummy = 1;
end
 
if (mc.mcInEditor() == 1) then
   m3();
end

Then in my test a macro running from in a macro, I made a macro called: m700
here is what is in it:

function m700()
    local inst = mc.mcGetInstance();
    local rc, DebugStopVar = 0;    
    mc.mcCntlMdiExecute(inst, "m3");--call the m3 macro from within this m700 macro
    DebugStopVar = 1;
end

if (mc.mcInEditor() == 1) then
   m700();
end

Is this the kind of thing as an example, your trying to do? Run the m700 from the MDI line?

Scott
fun times

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: MACH4 Mcode testing
« Reply #22 on: May 27, 2014, 11:34:56 PM »
HIYA Scott, Nothing too fancy just try to run a M98 SUB from inside a Mcode.  IF it can be done then I am in HIGH cotton. In the simple example I call the SUB in Gcode, it does LOAD the sub in mach4 and it does display the message (start Macro) SO it gets that far. Steve explained why it does not go any further. It DOES NOT display the last message (M222 Complete).

function m222()
    local inst = mc.mcGetInstance();
    mc.mcCntlSetLastError(inst, "m101");
 
    mc.mcCntlGcodeExecuteWait(inst, "M98 P5555 L1 \n (StartMacro) ");
     
    mc.mcCntlSetLastError(inst, "M222 Completed " );
   
end

if (mc.mcInEditor() == 1) then
    m222()
end


OK in your code what does the line before and after the MDI call do ?  I will try it that way as a test using the MDI line

local rc, DebugStopVar = 0;   
    mc.mcCntlMdiExecute(inst, "m3");--call the m3 macro from within this m700 macro
    DebugStopVar = 1;

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: MACH4 Mcode testing
« Reply #23 on: May 28, 2014, 12:08:26 AM »
OK the MDI did the same thing so I did some testing with GcodeExecuteWait . It should run as teh Gcode line stated BUT it did NOT.



The Message(M222) Displayed fiirst
The X started moving to X10 and at the same time the Message (M222 Completed) was displayed
The X continued to X10 then Pause for 3 sec then returned to X0

So did something get OUT of sequence ??? or not It shoudl not have dispalyed the last message UNTIL the Gcode was done correct??

With some testing earlier it did the same thing it had 6 lines of Gcode to do using GcodeExecuteWAIT and it processed it all OUT of order it ran the 2,4,6 then it ran the 5,3,1 lines.

So far I have tried 4 PCs here and none have been able to run code that Steve and Craig can run fine without problems. SO I do not know , untill something changes I'll just wait to see what happens. I am Dead in the water.   I can can run everything else but the LUA scripting side of mach4.

I am as happy as a a pig with a new slop trough full of PIZZA with the Gcode side of MACH4. Even more so when all the #VARs get brought out so I can use them. Well maybe if we get "AND, OR ,XOR " included in the conditional side(;-).

(;-) TP

(;-) TP



function m222()
    local inst = mc.mcGetInstance();
    mc.mcCntlSetLastError(inst, "m222");
   local rc, DebugStopVar = 0;  
    mc.mcCntlGcodeExecuteWait(inst, "G1 X10 F30 \n G4p5 \n G0X0");--call the m3 macro from within this m700 macro
    DebugStopVar = 1;
    --mc.mcCntlGcodeExecuteWait(inst, "G0 x10");
      
    mc.mcCntlSetLastError(inst, "M222 Completed " );
  end
if (mc.mcInEditor() == 1) then
    m222()
end




« Last Edit: May 28, 2014, 12:19:19 AM by BR549 »

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: MACH4 Mcode testing
« Reply #24 on: May 28, 2014, 12:13:43 AM »
STEVE forgot to tell you I really LIKE that popup window in the Lua editor that when you start to type in a call it gives you a list to go by.

THAT really helps when you have to deal with that CASE sensitive beast called LUA   >:D

Thanks (;-) TP

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: MACH4 Mcode testing
« Reply #25 on: May 29, 2014, 06:36:21 PM »
Question for you WizBangs.

  local inst = mc.mcGetInstance();
    mc.mcCntlSetLastError(inst, "m101");

WHAT is the "inst" and what does it do in the 2nd line. WHAT IS ITS PURPOSE ???

(;-) TP
Re: MACH4 Mcode testing
« Reply #26 on: May 29, 2014, 07:57:52 PM »
try opening a second mach4 you will find that in the hobby version you can only run one at a time

Offline poppabear

*
  • *
  •  2,235 2,235
  • Briceville, TN, USA
    • View Profile
Re: MACH4 Mcode testing
« Reply #27 on: May 29, 2014, 09:54:17 PM »
Terry, the inst is the instance handle to the running mach application, technically if you had more than one instance of Mach4 running, you could "address" which instance your talking to, i.e. if you wanted the second instance you started, you would pass:
local inst = mc.mcGetInstance(1); (zero being the 1st instance you opened, and it the assumed default if you put no parameters in).

when you see it in the calls, that is so the call "knows" which instance you want it to do its thing on....

scott
fun times

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: MACH4 Mcode testing
« Reply #28 on: May 29, 2014, 10:10:35 PM »
Thanks  Scott, that clears that up(;-)

(;-) TP

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: MACH4 Mcode testing
« Reply #29 on: May 30, 2014, 03:24:50 AM »
OK seeing how Mcodes and multi line Gcode does not work HERE on my PC I figure out a way to Break the 6 digit s/n into 6 individual numbers to engrave the Serial Numer via a sub routine in Gcode.

DOn't need no stinkin LUA now   :o  ;D


PS but it would be nice when LUA gets to working right HERE.

(;-) TP