I am somewhat confused as to how to implement a timer in Lua.
For my lube cycle (way lube pump) I need an on time and off time. Once the off time is exceeded turn on outputxx. When on time exceeded turn off outputxx. I tried the wxMilliSleep but it locks down the control during the timing and since this is a timing loop the control continuosly loops and is locked from any functionality.
As a test I tried this and it does what I said above: (Inserted in the PLC)
ActivateSignalTime = 5000
if (machEnabled == 1) then
runLube()
end
function runLube()
local inst = mc.mcGetInstance()
hsig1,rc = mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT1)
mc.mcSignalSetState(hsig1, 1)
wx.wxMessageBox("Output 1 On")
wx.wxMilliSleep(ActivateSignalTime)
mc.mcSignalSetState(hsig1, 0)
wx.wxMessageBox("Output 1 Off")
end
Although crude it does as stated above. Any ideas Scott?