Posted 16 Nov 2012 Hello, I searched a function block like chronometer, when I start it, it will count the time in miliseconds. When I stop it, it would freeze the counted time. It would be the reset function. Is it the function block, which I need or what could I do that I get this function. Thank you in advance. Share this post Link to post Share on other sites
Posted 9 Apr 2013 Are you looking for just a timer? or are you trying to have something like a time machine has been running? for a normal timer you could use TON... otherwise you have to make your own FunctionBlock Share this post Link to post Share on other sites
Posted 3 Sep 2013 Take a look at the information system: http://infosys.beckhoff.com/content/1033/tcplclib_tc2_standard/html/tcplclibstandard_ton.htm?id=12943 In the previous link there’s a complete description of the TON function block, which is used to count time. This link was from the TWinCAT 3 development tools environment. It works exactly in the same way for version 2. If the PLC you are using includes Windows as its operating system, then you can take advantage of the RTC and NT_GetTime functions blocks to get a real time clock (RTC) from one starting time, and the current operating system time and date. Search the Information system to get extra information about that. Good luck! Share this post Link to post Share on other sites
Posted 28 Nov 2013 Vinny, Even this can work, it has two major drawbacks: - It depends on the parameterized cycle time (if you change the task cycle time then it fails). - Moreover if the task cycle is surpassed (the task takes mor time tan the cycle time to be processed) then it fails. If you are using an old controller (BC, BX...) without a Windows operating system, then you could use a TON and the persistent TIME variable. :thumbsup: 1 person likes this Share this post Link to post Share on other sites
Posted 28 Nov 2013 (edited) Hi Joan True the value is not parametrised, i could not find the get cycle tick fb.. i know i have seen it, couldnt figure out where, but i wasnt aware of the issue of task being surpassed... thanks for that! Using TON has an issue of not being able to continue from the previous value and is limited to 999hrs (on a scheme of a machine, it not too long,is it?) Cheers Edited 28 Nov 2013 by vinny Share this post Link to post Share on other sites
Posted 21 Mar 2014 To count the cycles, first get the task number: TaskIndexID( index => TaskNr ); (* Get this tasks number *) Then get the cycletime from SystemTaskInfoArr: SystemTaskInfoArr[TaskNr].cycleTime (* cycle time in 100ns *) Then get the cycle count from SystemTaskInfoArr: SystemTaskInfoArr[TaskNr].cycleCount and you can use those to calculate passed time PassedTime:= SystemTaskInfoArr[TaskNr].cycleTime * SystemTaskInfoArr[TaskNr].cycleCount; If cycle time gets exceeded, you can check the cycleTimeExceeded and see the last cycle time lastExecTime from SystemTaskInfoArr and adjust the calculated time with that, but maybe you have some other more pressing issues, if the cycle time gets exceeded than couple of extra ticks in your timer. SystemTaskInfoArr is not visible during offline, but you can see it online in your global variables. Share this post Link to post Share on other sites