Hello Guest it is May 18, 2021, 01:29:16 PM

Author Topic: Mcodes ??  (Read 9591 times)

0 Members and 1 Guest are viewing this topic.

Re: Mcodes ??
« Reply #10 on: December 01, 2014, 11:18:17 AM »
I don't know what to say..

It works fine for me, but I'm running build 2129.   What build are you running?

I think any build 2114 or newer should work fine.
Andrew
MachMotion
Re: Mcodes ??
« Reply #11 on: December 01, 2014, 11:33:19 AM »
Seems to quit right here at the X

One thing to take note of if you create an mcode you have to restart mach4 to get it to work, as it has to be compiled with the other mcodes on starting.

We are missing something from the load script I would have to assume. As something is not initialized
« Last Edit: December 01, 2014, 11:38:04 AM by Ya-Nvr-No »

Offline BR549

*
  •  6,952 6,952
    • View Profile
Re: Mcodes ??
« Reply #12 on: December 01, 2014, 11:35:27 AM »
I am running 2128 .

(;-0 TP

Offline BR549

*
  •  6,952 6,952
    • View Profile
Re: Mcodes ??
« Reply #13 on: December 01, 2014, 11:41:06 AM »
OK I will leave that for yall to sort out.

BUT My question remains does the M700 macro with parameters have ANYTHING to do with the Gcode G65 local  #vars A-Z ??

(;-) TP

Offline poppabear

*
  • *
  •  2,233 2,233
  • Briceville, TN, USA
    • View Profile
    • S S Systems, LLC
Re: Mcodes ??
« Reply #14 on: December 01, 2014, 12:46:12 PM »
just as a side note,
the macro is just using tables and a for loop that the function passes parameters to.
Craig, the DSC module uses this very kind of thing (and your FC module as well).

Terry:
this is a good resource if you want to learn about lua.
http://lua-users.org/wiki/TutorialDirectory

Scott
Commercial Mach3 & Mach 4, Design/Build/Retrofit CNC and Industrial machines.
http://www.ss-systems-llc.com/

Offline BR549

*
  •  6,952 6,952
    • View Profile
Re: Mcodes ??
« Reply #15 on: December 01, 2014, 12:58:07 PM »
HIYA Scott I already have that in a HOTKEY to the site(;-).

My question on the Array variables is to clear up IF it is using the G65 local #var in ANY WAY. In the code I see a reference where the GETVAR() call is used.

REMEMEBER that the G65 #vars(1-26,A-Z) are local ONLY to the G65 Macro call and are not to be used any where else. IF you allow the Mcodes to reference them we are in trouble houston.

(;-) Just a thought, (;-)TP

Offline poppabear

*
  • *
  •  2,233 2,233
  • Briceville, TN, USA
    • View Profile
    • S S Systems, LLC
Re: Mcodes ??
« Reply #16 on: December 01, 2014, 01:59:58 PM »
Hey Terry,

the:    mc.VAR_A to mc.VAR_Z  are from the Mach4API.h
and that is how you get to those variables via mcLua.

Craig and I, did a Pound Var doc a while back (see tool box).
But the findings (at that time), where some where broken, or
didn't do what you thought... etc..  (there is a early M4 thread about
it here somewhere). At any rate, at that time, those issues where on
the "to fix" list... 
I personally have not gone back and checked them,
since then.... mostly, because I use CAM to do my G code programming,
so really don't use pound vars much but for custom macros.

Craig, and/or Andy may have more recent information on them in this regard.

Scott
Commercial Mach3 & Mach 4, Design/Build/Retrofit CNC and Industrial machines.
http://www.ss-systems-llc.com/

Offline poppabear

*
  • *
  •  2,233 2,233
  • Briceville, TN, USA
    • View Profile
    • S S Systems, LLC
Re: Mcodes ??
« Reply #17 on: December 01, 2014, 11:05:11 PM »
Ok, here is a working example for passing parameter(s) to a User M-Code!!

Thanks goes out to Steve Murphy for the correct way to do this.

You can call a “USER” macro any number you want (not the OEM numbers).
For example “m700” or maybe “m55633” whatever in your MDI or G-code line.
In the G-Code that you run, there are 4 “Local Var letters” that you cannot run in the tap file, (but you could fill them by standard pound var value assignment).
Those tap file letters are: G, M, N and O

NOTE: You can pass ZERO or ONE parameter to "User Macros", in this example that ONE parameter
is a handle called: "hVars" this handle is to the local pound vars A-Z
the ONE parameter is this "hVars"
so, if you had: m103 R500  that your code would turn on the spindle CW and you would parse the R parameter for what to set the spindle speed to....
the hVars (local pound vars) live on the stack only.

(both the m700 macro, and the MCode Parameter Test.tap are posted here.

Here is the working m700() macro:
----------------------------------------------------
--Brought to you by the: "Mach4^2 Development Team"!!
--Team members both Frick, and Frack!!
----------------------------------------------------
function m700(hVars)
   local macroname = "m700"
   local rc
   local inst = mc.mcGetInstance() -- Get the current instance    
   local nilPoundVar = mc.mcCntlGetPoundVar(inst,0)   
   local message = ""
    if hVars ~= nil then
          rc = mc.mcCntlGetLocalVar(inst, hVars, mc.VAR_A)
          message = message .. "A" .. ":" .. tostring(rc) .. ", "
          rc = mc.mcCntlGetLocalVar(inst, hVars, mc.VAR_B)
          message = message .. "B" .. ":" .. tostring(rc) .. ", "
          rc = mc.mcCntlGetLocalVar(inst, hVars, mc.VAR_C)
        message = message .. "C" .. ":" .. tostring(rc) .. ", "
          rc = mc.mcCntlGetLocalVar(inst, hVars, mc.VAR_D)
          message = message .. "D" .. ":" .. tostring(rc) .. ", "
          rc = mc.mcCntlGetLocalVar(inst, hVars, mc.VAR_E)
      message = message .. "E" .. ":" .. tostring(rc) .. ", "
      rc = mc.mcCntlGetLocalVar(inst, hVars, mc.VAR_F)
      message = message .. "F" .. ":" .. tostring(rc) .. ", "
      --[[
        rc = mc.mcCntlGetLocalVar(inst, hVars, mc.VAR_G)
          message = message .. "G" .. ":" .. tostring(rc) .. ", "
      --]]
        rc = mc.mcCntlGetLocalVar(inst, hVars, mc.VAR_H)
          message = message .. "H" .. ":" .. tostring(rc) .. ", "
          rc = mc.mcCntlGetLocalVar(inst, hVars, mc.VAR_I)
          message = message .. "I" .. ":" .. tostring(rc) .. ", "
          rc = mc.mcCntlGetLocalVar(inst, hVars, mc.VAR_J)
        message = message .. "J" .. ":" .. tostring(rc) .. ", "
          rc = mc.mcCntlGetLocalVar(inst, hVars, mc.VAR_K)
          message = message .. "K" .. ":" .. tostring(rc) .. ", "
        rc = mc.mcCntlGetLocalVar(inst, hVars, mc.VAR_L)
        message = message .. "L" .. ":" .. tostring(rc) .. ", "
      --[[
        rc = mc.mcCntlGetLocalVar(inst, hVars, mc.VAR_M)
          message = message .. "M" .. ":" .. tostring(rc) .. ", "
        rc = mc.mcCntlGetLocalVar(inst, hVars, mc.VAR_N)
        message = message .. "N" .. ":" .. tostring(rc) .. ", "
        rc = mc.mcCntlGetLocalVar(inst, hVars, mc.VAR_O)
        message = message .. "O" .. ":" .. tostring(rc) .. ", "
      --]]
        rc = mc.mcCntlGetLocalVar(inst, hVars, mc.VAR_P)
        message = message .. "P" .. ":" .. tostring(rc) .. ", "
        rc = mc.mcCntlGetLocalVar(inst, hVars, mc.VAR_Q)
        message = message .. "Q" .. ":" .. tostring(rc) .. ", "
        rc = mc.mcCntlGetLocalVar(inst, hVars, mc.VAR_R)
        message = message .. "R" .. ":" .. tostring(rc) .. ", "
        rc = mc.mcCntlGetLocalVar(inst, hVars, mc.VAR_S)
        message = message .. "S" .. ":" .. tostring(rc) .. ", "
        rc = mc.mcCntlGetLocalVar(inst, hVars, mc.VAR_T)
        message = message .. "T" .. ":" .. tostring(rc) .. ", "
        rc = mc.mcCntlGetLocalVar(inst, hVars, mc.VAR_U)
        message = message .. "U" .. ":" .. tostring(rc) .. ", "
        rc = mc.mcCntlGetLocalVar(inst, hVars, mc.VAR_V)
        message = message .. "V" .. ":" .. tostring(rc) .. ", "
        rc = mc.mcCntlGetLocalVar(inst, hVars, mc.VAR_W)
        message = message .. "W" .. ":" .. tostring(rc) .. ", "
        rc = mc.mcCntlGetLocalVar(inst, hVars, mc.VAR_X)
        message = message .. "X" .. ":" .. tostring(rc) .. ", "
        rc = mc.mcCntlGetLocalVar(inst, hVars, mc.VAR_Y)
        message = message .. "Y" .. ":" .. tostring(rc) .. ", "
        rc = mc.mcCntlGetLocalVar(inst, hVars, mc.VAR_Z)
        message = message .. "Z" .. ":" .. tostring(rc)

      wx.wxMessageBox(message)
   end
end

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

Here is the MCode Parameter Test.tap

(Mcode Parameter Test)
G01 F50
m700 A1 B2 C3 D4 E5 F6 H7 I8 J9 K10 L11 P12 Q13 R14 S15 T16 U17 V18 W19 X20 Y21 Z22
X2
M30

Scott
« Last Edit: December 01, 2014, 11:17:25 PM by poppabear »
Commercial Mach3 & Mach 4, Design/Build/Retrofit CNC and Industrial machines.
http://www.ss-systems-llc.com/

Offline dude1

*
  •  1,253 1,253
    • View Profile
Re: Mcodes ??
« Reply #18 on: December 01, 2014, 11:25:04 PM »
good work second Development Team

Offline poppabear

*
  • *
  •  2,233 2,233
  • Briceville, TN, USA
    • View Profile
    • S S Systems, LLC
Re: Mcodes ??
« Reply #19 on: December 01, 2014, 11:28:42 PM »
thats, Squared..........  (^2).........  :)

Also, note that Frack will be showing how to take those passed parameters and put them into global vars, and/or registers for other stuff.

Scott
Commercial Mach3 & Mach 4, Design/Build/Retrofit CNC and Industrial machines.
http://www.ss-systems-llc.com/