Hello Guest it is November 27, 2021, 06:06:00 AM

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

0 Members and 1 Guest are viewing this topic.

Offline Chaoticone

  • *
  •  5,626 5,626
  • 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
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

--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!