Here is another idea, using the millisecond #3001 variable
just need to add output condition
as I am just showing the time value in the history.
can be set to any time and all jogging or other functions are still active
with some additional coding should be able to use these functions for other timers
--add to PLC Script
function Timer(varnum)
local inst = mc.mcGetInstance() -- Get the current instance
varvalue1 = mc.mcCntlGetPoundVar(inst, varnum); -- Get MiliSecond Time
return varvalue1
end
function TimedOut(varnum,varvalue,ontime)
local inst = mc.mcGetInstance() -- Get the current instance
varvalue2 = mc.mcCntlGetPoundVar(inst, varnum); -- Get MiliSecond Time again
increment=(varvalue2-varvalue) -- current milisecond increment
if (varvalue2>(varvalue+ontime)) then
timerupFlag=0 -- be sure to set this global variable flag set in screen load cript
mc.mcCntlSetLastError(inst, "Times Up "..tostring(increment))
else
timerupFlag=1
end
return increment
end
if (timerupFlag==1) then
increment = TimedOut(milisecondVar,varvalue1,ontime)
end
-- Add to Left up Button Script
timerupFlag=1 -- set global that timer routine is in use
milisecondVar=3001 --the Milisecond # Register
ontime=5000 -- miliseconds on time so its 5 seconds minimum
valvalue1 = Timer(milisecondVar) --set start time