Hello Guest it is May 02, 2024, 04:58:00 PM

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - poppabear

201
it is not TRUE inlining (like in C) in where the compiler puts the function code where it is written so no call to it is made.

what was done here, was cut out some if statements and a function call. so, in theory less calls to functions and less if statements to process along the way should = more speed (in theory).

look up "inline" and C or C++ as a key word on google or some such.

202
opps........

the:  wxMilliSleep(); is milliseconds.... sorry...

scott

203
Since your Mcode are 10microseconds to fast, put a 10 ms sleep before the output call.
So change your macros to this (and adjust the Microsleep as needed if 10ms if off:

--m770 macro turns "ON" OUTPUT0
function m770() 
   wx,wxMicroSleep(10);--10ms delay 
   mc.mcSignalSetState(mc.mcSignalGetHandle(0, mc.OSIG_OUTPUT0), 1);
end
--m770()--testing;
--[[
if (mc.mcInEditor() == 1) then--leave uncommented unless in the editor
    m770();
end
--[[

-----------**********************************---------------------------------

--m771 macro turns "OFF" OUTPUT0
function m771()   
      wx,wxMicroSleep(10);--10ms delay
      mc.mcSignalSetState(mc.mcSignalGetHandle(0, mc.OSIG_OUTPUT0), 0);
end
--m771();--testing
--[[
if (mc.mcInEditor() == 1) then--leave uncommented unless in the editor
    m771();
end
--[[

Scott

204
so here are the working In-Line (mdi and gcode) m770 and m771:
(Tweaky, tell me if it speeds up your laser output or not, I don't have one)

--m770 macro turns "ON" OUTPUT0
function m770()   
   mc.mcSignalSetState(mc.mcSignalGetHandle(0, mc.OSIG_OUTPUT0), 1);
end
--m770()--testing;
--[[
if (mc.mcInEditor() == 1) then--leave uncommented unless in the editor
    m770();
end
--[[

-----------**********************************---------------------------------

--M771 macro turns "OFF" OUTPUT0
function m771()   
   mc.mcSignalSetState(mc.mcSignalGetHandle(0, mc.OSIG_OUTPUT0), 0);
end
--m771();--testing
--[[
if (mc.mcInEditor() == 1) then--leave uncommented unless in the editor
    m771();
end
--[[

Scott

205
OK, it was an attack of STUPID!!!

you have to name the macro with a LOWER case m....

in the macro code m770, and m771 then it works!!

just never paid attention to that

scott

206
now THAT is odd....

I cannot get them to run in my MDI or G-code either!  
Never had that happen before,
I even tried:

 * UN-commenting the "is in editor stuff", no change.
 * Restoring it to "UN-inlined" (standard way of doing a macro), no change
 * putting in and taking out the function call M770() and M771(), no change
 * After each change, closing and re-opening M4, no change
 * I see it blow past the M770/M771 while watching the OUTPUT1 LED on the Diag-page, nothing

 * if I put the native code into the PLC script which via code turns on and off output1, IT WORKS!
 * BUT.... If I put mclua code to call the MDI command or Gcode command and call it via macro name
    it does NOT work....

***  I am wondering if something broke in the mclua???? Or, perhaps I have done something stupid,
***  which is always a possibility, Perhaps Steve can look it over and see where the Break or the Opps is.

Here is the M770/M771 gcode I am using to test with:

F60.000000
G0 X0.000000 Y0.000000 Z0.200000
M3 (start Spindle)
S60.000000
g1 x1 f20
M770
G4 P2
M771
x0
M5
G0 X0.000000 Y0.200000 Z0.000000
M99  

It really doesn't make any sense, and I have a "Lic." copy of M4 as well running on the "Sim".

Scott

207
Hey Twdakie,

   I am opening them in the mcLua editor, and then I hit "run" and Output 1 turns on for m770, and off for m771 what are you doing to get it not to work in yours? Do you have other things writing to that output?

scott

208
If your macros are slow (like on lasers), try "In-lining" them to save on func calls.

--M770 macro turns "ON" OUTPUT0
function M770()   
    mc.mcSignalSetState(mc.mcSignalGetHandle(0, mc.OSIG_OUTPUT0), 1);     
end
M770();
--[[
if (mc.mcInEditor() == 1) then--leave uncommented unless in the editor
    M770();
end
--]]

***********  This next macro goes into a separate macro for the off func. **********

--M771 macro turns "OFF" OUTPUT0
function M771()   
    mc.mcSignalSetState(mc.mcSignalGetHandle(0, mc.OSIG_OUTPUT0), 0);     
end
M771();
--[[
if (mc.mcInEditor() == 1) then--leave uncommented unless in the editor
    M771();
end
--]]

Scott

209
Added Output edit controls to the OUTPUTS window.

where you push the "Pause Updates" toggle button, click in the cell you want to change (0 or 1), press enter. Then press the "Set Change" button, that will immediately turn on or off that output.
press press the toggle button again to un-pause the updates.

Scott

210
Thank You Professor!!