Hello Guest it is April 25, 2024, 06:43:50 PM

Author Topic: Pause Lua script mach4  (Read 3767 times)

0 Members and 1 Guest are viewing this topic.

Offline Chaoticone

*
  • *
  •  5,624 5,624
  • Precision Chaos
    • View Profile
Re: Pause Lua script mach4
« Reply #10 on: August 21, 2019, 04:29:46 PM »
OK, good.

Yup, running dwell in Gcode is as good a way as any. I would just use a single line or edit Katz function to take a time parameter if it was something i might use in different places.

The code below should also check the type of dwell and convert to a number or error out if it can't be converted.

Code: [Select]
function wait(dwell)
local inst = mc.mcGetInstance()
local defaultDwell = 250
if (dwell == nil) or (dwell < defaultDwell) then --No dwell passed or a shorter dwell than the motion device can process will cause errors
dwell = defaultDwell
end
local GCode = string.format("G4 p" .. tostring(dwell))
rc = mc.mcCntlGcodeExecuteWait (inst, GCode) ---wait for time of dwell
--Do something here if rc ~= 0 because you have an error
end

--Then use it like this

wait(100) --will wait for 250 milliseconds == .25 seconds because it is less than default defined in function

wait() --will wait for 250 milliseconds == .25 seconds because dwell is not defined so function will define as default

wait(500) --will wait for 500 milliseconds  == .5 seconds

Don't use it like this though..........

Code: [Select]
wait("10 seconds") --will cause problems if the dwell type check I mentioned above isn't added
« Last Edit: August 21, 2019, 04:43:09 PM by Chaoticone »
;D If you could see the things I have in my head, you would be laughing too. ;D

My guard dog is not what you need to worry about!
Re: Pause Lua script mach4
« Reply #11 on: November 03, 2022, 09:30:08 AM »
why doesn't wx.wxMilliSleep() work in signal script
Re: Pause Lua script mach4
« Reply #12 on: November 01, 2023, 07:12:51 AM »
i use this:
function waiit()
   local inst = mc.mcGetInstance()
   local GCode =""
            GCode = GCode ..string.format("G4 p500")
            mc.mcCntlGcodeExecuteWait (inst, GCode) ---wait 0.5 second
   
end

Hi Chaoticone,
Do you agree that this is a valid solution or is it still dangerous for the reasons mentioned above?
Many thanks, Dan