Industry Online Support
Technical Forum
5/4/2013 11:44 AM | |
Joined: 1/28/2009 Last visit: 9/2/2024 Posts: 6846 Rating:
|
Hello, For doing so there are some methods that you can work on: 1-Using functions for controlling the main drive that provides the runtime of device as output (with reset capability). 2-Check the following FAQ for inspiring idea to how measure time. 3-and finally using SFB4 as IEC on-delay timer plus accumulation of its output only when drive is active.The idea comes from this thread: TOTAL TIME IN HH/MM/SS FORMAT (HOUR/MINUTE/SECOND)I tried to make it clear and perfect but it may need some modification (as it is a rough version).Times should be changed as your requirement. I tried to provide as much as comments as I could.The algorithm is based on using global memories, if you have more similar cases, I think you can easily make function of the idea. [code]ORGANIZATION_BLOCK "Cycle Execution" TITLE = "Main Program Sweep (Cycle)" VERSION : 0.1 VAR_TEMP OB1_EV_CLASS : BYTE ; //Bits 0-3 = 1 (Coming event), Bits 4-7 = 1 (Event class 1) OB1_SCAN_1 : BYTE ; //1 (Cold restart scan 1 of OB 1), 3 (Scan 2-n of OB 1) OB1_PRIORITY : BYTE ; //Priority of OB Execution OB1_OB_NUMBR : BYTE ; //1 (Organization block 1, OB1) OB1_RESERVED_1 : BYTE ; //Reserved for system OB1_RESERVED_2 : BYTE ; //Reserved for system OB1_PREV_CYCLE : INT ; //Cycle time of previous OB1 scan (milliseconds) OB1_MIN_CYCLE : INT ; //Minimum cycle time of OB1 (milliseconds) OB1_MAX_CYCLE : INT ; //Maximum cycle time of OB1 (milliseconds) OB1_DATE_TIME : DATE_AND_TIME ; //Date and time OB1 started BUFFER : TIME ; END_VAR BEGIN NETWORK TITLE = L T#24D20H31M1S; T "RUN".PT; A I 0.0; // FROM MOTOR STATUS A M 104.0; //reset for next cycle = "RUN".IN; CALL "TON" , "RUN" ; SET ; = M 104.0; //enable timing A I 0.0; JCN ONE; L "RUN".ET; L "buffer"; -D ; L "ACC"; +D ; T "ACC"; JU ENDE; ONE: NOP 0; L L#0; T "buffer"; ENDE: NOP 0; L "RUN".ET; T "buffer"; /////////////check accumulated time/// L "ACC"; L T#1M; >=D ; L S5T#5S; SP T 0; //pulse timer for a determined pulse duration NOP 0; ///////////////////// // RESET MECHANISM for simatic timer ///////////////////// A T 0; = Q 0.0; //OUTPUT ENERGIZE A T 0; FN M 104.1; JCN fin; SET ; //ACTION RELOAD,RESET ALL EVEN IEC TIMER R Q 0.0; L 0; T "buffer"; T "ACC"; CLR ; = M 104.0; //reset IEC timer to start again fin: NOP 0; END_ORGANIZATION_BLOCK [/code] Best regards Hamid Hosseini |
This contribution was helpful to
1 thankful Users |
Follow us on