Hello Guest it is December 11, 2019, 07:13:30 PM

Author Topic: Needing help with screens  (Read 11885 times)

0 Members and 1 Guest are viewing this topic.

Offline dude1

*
  •  1,253 1,253
    • View Profile
Re: Needing help with screens
« Reply #30 on: December 04, 2014, 04:22:38 AM »
this is what I have ended up with so far what's commented out is because it crashes M4

-laser zero

local inst = mc.mcGetInstance();

mc.mcCntlGcodeExecute(inst, "G1 X10 Y10 F500");--run some g-code
wx.wxMilliSleep(18);  --it need to be set to this
mcState = mc.mcCntlGetState(inst);
--while (mcState ~= mc.MC_STATE_IDLE) do
--mcState = mc.mcCntlGetState(inst);
--wx.wxMilliSleep(30);
--end
mc.mcAxisSetPos(inst, 0, 0.000)
mc.mcAxisSetPos(inst, 1, 0.000)
--wx.wxMilliSleep (20)

so it looks like this so far to get it to work I have to home all first

-laser zero

local inst = mc.mcGetInstance();

mc.mcCntlGcodeExecute(inst, "G1 X10 Y10 F500");--run some g-code
wx.wxMilliSleep(18);--it needed to be set to this
mcState = mc.mcCntlGetState(inst);

mc.mcAxisSetPos(inst, 0, 0.000)
mc.mcAxisSetPos(inst, 1, 0.000)


Offline BR549

*
  •  6,916 6,916
    • View Profile
Re: Needing help with screens
« Reply #31 on: December 04, 2014, 10:27:00 AM »
SO does this mean that me still have the same problem in Mach4 as we had with Mach3 macros. The macros will NOT stay in sync as to Gcode and Lua AND order of execution AND we end up with a race condition. I thought we were going to fix that this time ???

(;-) TP

Offline Tweakie.CNC

*
  • *
  •  8,021 8,021
  • Super Kitty
    • View Profile
    • Tweakie.CNC
Re: Needing help with screens
« Reply #32 on: December 04, 2014, 10:47:18 AM »
SO does this mean that me still have the same problem in Mach4 as we had with Mach3 macros. The macros will NOT stay in sync as to Gcode and Lua AND order of execution AND we end up with a race condition. I thought we were going to fix that this time ???

(;-) TP

This is probably the secret that makes Mach4 faster - the first thing I discovered using the laser is that S codes, some M codes and macro's will execute before the end of the preceding line of Gcode. Delays within the macro's resolved the issue but defeated the object by slowing everything down. It's still early days yet and I am sure there will be a suitable solution.

Tweakie.
Success consists of going from failure to failure without loss of enthusiasm.  Winston Churchill.

Offline BR549

*
  •  6,916 6,916
    • View Profile
Re: Needing help with screens
« Reply #33 on: December 04, 2014, 10:49:45 AM »
I think I remember seeing a SWITCH to change that mode to SYNC.

(;-)TP

Offline poppabear

*
  • *
  •  2,233 2,233
  • Briceville, TN, USA
    • View Profile
    • S S Systems, LLC
Re: Needing help with screens
« Reply #34 on: December 04, 2014, 10:51:45 AM »
Are you running this in your PLC script section?

if so, your while loop MAY be waiting/running longer than the
PLC script scan and hanging it up, and crashing it...

You could do it as a state series if it is in the PLC script section.

***in the load screen section.
put a "RunOnce = 0;" global var

OR... you could set a global register (see the register plugin)
OR... you could set an unused #var
OR... you could set a screen User LED etc....
and use them in place of RunOnce in the code in the PLC section

***in the PLC script section

--MyMachEnabledSafetyVar can be if the enabled button is enabled for instance.

If RunOnce == 0 and MyMachEnabledSafetyVar == 1 then
    DoGcode here.
end

If RunOnce == 0 and XaxisPos == 10 and YaxisPos == 10 then
    Do your outputs or whatever...
    RunOnce = 1;--so the runonce blocks dont run again.
end


  
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: Needing help with screens
« Reply #35 on: December 04, 2014, 01:21:58 PM »
its in a button script

poppabear at this stage I can understand zero of what you have put I would like to learn how to do the scripting with just pointers of what to do but that's not working if I had the manual I think I would be ok.

all off your help gents is very well come and thank you for the help

Offline BR549

*
  •  6,916 6,916
    • View Profile
Re: Needing help with screens
« Reply #36 on: December 04, 2014, 02:30:54 PM »
Here is a tip unless it is an Mcode MOVE your test script to a seperate Directory. Mach4 does funny things if run from the Profile/macro directory. Also Mach4 will PRERUN the macros in the Proflie/macro directory on startup.

I set up Mach4hobby/MACROS directory and run tests from there MUCH better stablility and NO weird stuff happening on testing.

Just a thought, (;-) TP

Offline dude1

*
  •  1,253 1,253
    • View Profile
Re: Needing help with screens
« Reply #37 on: December 04, 2014, 04:13:19 PM »
its not in macro folder in the button script.

for running the code its just a timing problem if I have a G code move plus output on off its ok when added zero x and y that's when it goes funny I just have to get the timing correct and it works fine.

there will be better ways of doing it but that's over my head at this time.

Its probable I could just do a call from a directory like you suggest, might try that any way 

Offline dude1

*
  •  1,253 1,253
    • View Profile
Re: Needing help with screens
« Reply #38 on: December 06, 2014, 05:20:25 PM »
can some one help me I am trying to run a scripts from a folder named scripts.

I cant get the call right this is one thing I have tried I can get it to compile but not run I have it in a button script

 package.path = "./?.lua;c:/Mach4Hobby/scripts/?.mcc;"
mc.mcScriptExecute(0, inst,  "./?.lua;C:/Mach4Hobby/scripts/LaserZeroscript",0);

I have put this in screen load scripts its fine   package.path = "./?.lua;c:/Mach4Hobby/scripts/?.mcc;"

is there something I am missing or can someone please give me an example of how to do it

Offline dude1

*
  •  1,253 1,253
    • View Profile
Re: Needing help with screens
« Reply #39 on: December 06, 2014, 07:56:42 PM »
got it working I think its showing up in log as, No script engine found for ./?.lua;C:/Mach4Hobby/scripts/LaserZeroscript

the script I am using is this

Code: [Select]
--Laser Zero call
local inst= mc.mcGetInstance();
local myScriptpath = "C:/Mach4/scripts";
package.path = "./?.lua;c:/Mach4Hobby/scripts/?.mcc;"
mc.mcScriptExecute( inst, "./?.lua;C:/Mach4Hobby/scripts/LaserZeroscript" ,0);