4/23/2013 5:32 AM | |
Joined: 1/28/2009 Last visit: 8/5/2024 Posts: 6844 Rating:
|
Hello, Ways I am thinking about is to use SFC1 (reading current date and time of CPU) and compare it with specific data which is fix.For an FAQ related to SFC1,Please check HERE. Another possibility would be using OB1X as Time of Day interrupt.For that, you should set plan in Hw.Cofig and a hardware data download is inevitable. Try and update! Best regards Hamid Hosseini |
This contribution was helpful to
1 thankful Users |
4/23/2013 6:20 PM | |
Posts: 31 Rating:
|
hdhosseini, Firstly thanks for the fast reply and for the help. You are correct about the use of SFC0 and SFC1 to check actual Date And Time ( DAT ) and compare with a referenced value of DAT. We can develop an FB that can compare the CPU Clock information with a range of DAT (start and end Date and Time ). I'm working on a problem with the condition if the range of DAT not be in the same day. By example: I need that an output stay activated between day_of_week 2 and time 22h00m until day_of_week 3 and time 06h00m. With this condition the FB still doesn't work. The FB can work if start and end date are on same day_of_week... But since now thanks a lot for your help! Best regards, Edsan |
4/23/2013 7:51 PM | |
Joined: 1/28/2009 Last visit: 8/5/2024 Posts: 6844 Rating:
|
Hello, Check the following sample, I am sure you can make a function with input of current date and time of CPU to generate set and reset signals.Your function may have flexible comparison data for day and hour plus a reset mechanism.
[code] ORGANIZATION_BLOCK "Cycle Execution" TITLE = "Main Program Sweep (Cycle)" AUTHOR : HD FAMILY : FORUM_E NAME : WEEK 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 ret : INT ; hd : DATE_AND_TIME ; test : BYTE ; END_VAR BEGIN NETWORK TITLE = CALL "READ_CLK" ( RET_VAL := #ret, CDT := #hd); L LB 29; L B#16#F; AW ; T #test; A( ; L LB 25; L B#16#13; //13 ==I ; ) ; A( ; L LB 26; L B#16#0; ==I ; ) ; A( ; L LB 27; L B#16#0; ==I ; ) ; A( ; L #test; L 6; // friday ==I ; ) ; S Q 0.0; A( ; L LB 25; L B#16#15; //15 ==I ; ) ; A( ; L LB 26; L B#16#30; //30 ==I ; ) ; A( ; L LB 27; L B#16#0; ==I ; ) ; A( ; L #test; L 2; // MONDAY ==I ; ) ; R Q 0.0; END_ORGANIZATION_BLOCK[/code] I have not tested the codes but you try! Best regards Hamid Hosseini |
Follow us on