12/20/2012 4:16 PM | |
Joined: 1/28/2009 Last visit: 8/5/2024 Posts: 6844 Rating:
|
Hello, Before start making your time you should specify following characteristics of your timer: 1-Internal timing behavior on trigger and reset signal. 2-Digital output of the function based on trigger,reset and internal timing value. There are some discussions made before with a sample,check it here: How can you create a timer for the "S7" without using an "S7 Timer"? simulating a timer with the FC64 "TIMETICK" without using an S7-Timer Best regards Hamid Hosseini |
1/7/2013 11:43 AM | |
Posts: 35 Rating:
|
Guys thanks for your help, but it's not working or I didn't understand it correctly. Can you throw some example? All the best for the New Year... |
1/7/2013 7:33 PM | |
Joined: 1/28/2009 Last visit: 8/5/2024 Posts: 6844 Rating:
|
Hello, This is my rough version of a timer.A pause signal is also included to stop timing as you like.Change as you like.It should be called in one of the cyclic interrupt OBs.Test the whole features before you use it in a practical case! [code]FUNCTION_BLOCK FB 1 TITLE = VERSION : 0.1 VAR_INPUT trig : BOOL ; type_sel : INT := 1; impulse : BOOL ; interval : TIME ; pause : BOOL ; set : REAL := 1.000000e+001; reset : BOOL := TRUE; END_VAR VAR_OUTPUT output : BOOL ; elapse : REAL ; END_VAR VAR store_interval : REAL ; el_time : REAL ; END_VAR BEGIN NETWORK TITLE = L #interval; DTR ; L 1.000000e+003; /R ; T #store_interval; NOP 0; A #reset; JCN norm; L 0; T #elapse; T #store_interval; T #el_time; NOP 0; CLR ; = #output; JU fin; ///////////////////////////// norm: NOP 0; L #type_sel; JL hd_r; JU zero; JU one; //On delay Timer JU two; hd_r: JU fin; zero: JU fin; one: NOP 0; /////////ON Delay Timer//////////////////////////////// A #trig; JC fst; L 0; T #el_time; T #elapse; JU fin; fst: NOP 0; L #el_time; L #store_interval; -R ; L #set; TAK ; >R ; JCN res; A #impulse; A #trig; AN #pause; JCN snd; L #store_interval; L #el_time; +R ; T #el_time; T #elapse; snd: NOP 0; res: NOP 0; A( ; L #el_time; L #set; >=R ; ) ; A #trig; = #output; /////////////////////////////////////// two: NOP 0; //Under Construction!! //////////////////////////////////////// JU fin; fin: NOP 0; END_FUNCTION_BLOCK ORGANIZATION_BLOCK OB 35 TITLE = "Cyclic Interrupt" VERSION : 0.1 VAR_TEMP OB35_EV_CLASS : BYTE ; //Bits 0-3 = 1 (Coming event), Bits 4-7 = 1 (Event class 1) OB35_STRT_INF : BYTE ; //16#36 (OB 35 has started) OB35_PRIORITY : BYTE ; //Priority of OB Execution OB35_OB_NUMBR : BYTE ; //35 (Organization block 35, OB35) OB35_RESERVED_1 : BYTE ; //Reserved for system OB35_RESERVED_2 : BYTE ; //Reserved for system OB35_PHASE_OFFSET : WORD ; //Phase offset (msec) OB35_RESERVED_3 : INT ; //Reserved for system OB35_EXC_FREQ : INT ; //Frequency of execution (msec) OB35_DATE_TIME : DATE_AND_TIME ; //Date and time OB35 started END_VAR BEGIN NETWORK TITLE = // impulse AN M 0.0; = M 0.0; L #OB35_EXC_FREQ; ITD ; T DB1.DBD 6; CALL FB 1 , DB 1 ( impulse := M 0.0); END_ORGANIZATION_BLOCK [/code] Best regards Hamid Hosseini AttachmentTIMER.zip (495 Downloads) |
This contribution was helpful to
2 thankful Users |
1/15/2013 3:31 PM | |
Joined: 5/14/2012 Last visit: 4/8/2024 Posts: 2 Rating:
|
Hi Ivolvic, Hope you are looking for the below one. With Regards Rajkumar R
|
Follow us on