Hello Guest it is December 11, 2019, 06:13:32 AM

Author Topic: Cycle Timer Not Working  (Read 1130 times)

0 Members and 1 Guest are viewing this topic.

Cycle Timer Not Working
« on: January 10, 2017, 12:29:16 PM »
My cycle time timer is not working.  The only code I can find related to the cycle timer is in the PLC Script, and it looks to be an initialize code.  Where is the script to start the timer?  I'll check the code and see if I am in conflict with the code I've put into the Screen Load Script. 
Chad Byrd
Re: Cycle Timer Not Working
« Reply #1 on: January 12, 2017, 01:01:57 PM »
Figured out a fix to the timer issue I am having.  I had some code tin the Signal Library that the Timer Script in the PLC Script didn't like.

I was forcing an Output to be an Enable in the signal library and somehow that messed up the timer script. 

I moved the Output Force to Enable script to the PLC Script and now both features are working like I want. 
Chad Byrd

Offline DazTheGas

*
  •  750 750
  • DazTheGas
    • View Profile
Re: Cycle Timer Not Working
« Reply #2 on: January 13, 2017, 01:27:36 AM »
It would be nice to share the code incase others have the same issue.

DazTheGas
Theres always time for a choccy biccy
Re: Cycle Timer Not Working
« Reply #3 on: January 13, 2017, 08:12:16 AM »
You're right DazTheGas, I don't know why I didn't post it yesterday. 
I was trying to get an Output to act like an Enable.  It worked, but it messed up my cylcle time for some reason.
Here is the code that messed up my timer, it was in the signal library.

--Enable Signals
--MOVED THIS TO PLC SCRIPT CB 1-12-17
--It messed up the part timer.  Timer works fine when this is in PLC Script.
--[mc.OSIG_MACHINE_ENABLED] = function (state)
--     if (state == 1) then
--         local inst = mc.mcGetInstance()
--         local RedLight = mc.mcSignalGetHandle (inst,mc.OSIG_OUTPUT11)
--         mc.mcSignalSetState(RedLight,0)
--     else
--         local inst = mc.mcGetInstance()
--         local RedLight = mc.mcSignalGetHandle (inst,mc.OSIG_OUTPUT11)
--         mc.mcSignalSetState(RedLight,1)       
--     end
--end,

Here is the code to do the same thing, I put it in the PLC Script and now the "Enabled Output" works great and so does my Cycle Timer.

--Enable the Output
local sigh = mc.mcSignalGetHandle(inst, mc.OSIG_MACHINE_ENABLED);
local sigState = mc.mcSignalGetState(sigh);
     if (sigState == 1) then
         local inst = mc.mcGetInstance()
         local RedLight = mc.mcSignalGetHandle (inst,mc.OSIG_OUTPUT3)
         mc.mcSignalSetState(RedLight,0)
     else
         local inst = mc.mcGetInstance()
         local RedLight = mc.mcSignalGetHandle (inst,mc.OSIG_OUTPUT3)
         mc.mcSignalSetState(RedLight,1)       
     end
Chad Byrd