Machsupport Forum

Mach Discussion => Mach4 General Discussion => Topic started by: Eveider on November 03, 2022, 06:44:35 AM

Title: delay and timer in signal script #mach 4
Post by: Eveider on November 03, 2022, 06:44:35 AM
hi  there

I am looking for a way to turn ON an output and turn it OFF after 5 seconds.
I managed to write a lua code in the signal script that basically turn ON and OFF an output but now i am struggling  to implement a delay

-- code
local inst = mc.mcGetInstance()
local hsig = mc.mcSignalGetHandle(inst,mc.ISIG_INPUT1)
local ISigFDBK = mc.mcSignalGetState(hsig)

local hsignal = mc.mcSignalGetHandle(inst,mc.OSIG_OUTPUT5)
local OSigFDBK = mc.mcSignalGetState(hsignal)



if (ISigFDBK == 0)then
   mc.mcSignalSetState(hsignal,1)
else
   mc.mcSignalSetState(hsignal,0)
end

 
Title: Re: delay and timer in signal script #mach 4
Post by: Bill_O on November 03, 2022, 01:08:11 PM
wx.wxMilliSleep(3000)
That is a 3 second delay
Title: Re: delay and timer in signal script #mach 4
Post by: Bill_O on November 03, 2022, 05:29:27 PM
Should have read that a little better.

if (ISigFDBK == 0)then
   mc.mcSignalSetState(hsignal,1)
   wx.wxMilliSleep(5000)
   mc.mcSignalSetState(hsignal,0)
end
Title: Re: delay and timer in signal script #mach 4
Post by: smurph on November 04, 2022, 03:59:27 PM
This is why your are not supposed to cross post (same question in multiple posts).  I answered your question in another post.  See https://www.machsupport.com/forum/index.php?topic=41633.msg294381#msg294381 (https://www.machsupport.com/forum/index.php?topic=41633.msg294381#msg294381).

Steve