6/25/2013 11:00 PM | |
Joined: 5/4/2009 Last visit: 7/29/2023 Posts: 914 Rating: (40) |
Thanks my friend Yes it is clear now for DINT, but still the problem for DWORD see attached. |
Aim Higher |
|
6/26/2013 6:53 AM | |
Joined: 3/24/2009 Last visit: 6/20/2023 Posts: 535 Rating: (112) |
Dear TomyMaster, you can deactivate the type-check as hdhosseini suggested, or you can provide the CMP-box with the expected datatype, which is DINT (in your case L#255). Best regards, yy1 |
6/26/2013 7:03 AM | |
Joined: 1/28/2009 Last visit: 4/26/2024 Posts: 6838 Rating: (1359)
|
Hello yy1, I should disagree to your second suggestion.Work with DINT while you all processes are based on DWORD(e.g hex format).In this case you always need a calculator to change values from hex to decimal and vice versa.Poor programmer in that situation.My suggestion that is the most easiest solution would be using "STL". Best regards Hamid Hosseini |
This contribution was helpful to1 thankful Users |
6/26/2013 8:38 AM | |
Joined: 1/28/2009 Last visit: 4/26/2024 Posts: 6838 Rating: (1359)
|
Hello again yy1, I agree with the part you mentioned, it depends on the case.Most of the time you are forced to compare in hex format as the original task convey that.Most of the time data of such cases are generated from CPU internal registeres related to organization blocks.As you know, organization blocks are the interface of user program to the operating system of CPU.Should I worry for such cases(signed/unsigned-conflicts) while comparing.The answer is "NO".In hex format comparing for WORDs and DWORDs , I am interested in bit patterns.For me, sign of pattern I am checking is not important.I have plenty of tools to filter what I really want to compare.Please check the example comming from this thread (OB81 (PS_FLT) EXECUTE) , we discussed yesterday to find out battery failure in an S7-400H CPU via OB81.In the cases I checked values "#OB81_FLT_ID" and "#OB81_RACK_CPU", there were no concerns about the sign of those variable.In such cases, I have masking tools such as "AW" or "AD" for filtering the pattern. [code]//going_event==temp address boolean //battery_failed==temp address boolean L #OB81_FLT_ID L B#16#26 <>I JC END L #OB81_EV_CLASS L B#16#38 ==I = #going_event L #OB81_RACK_CPU AW W#16#700 L W#16#0 ==I AN #going_event S M 0.0 //BATTERY IN RACK0 LOW TAK L W#16#100 ==I AN #going_event S M 0.1 //BATTERY IN RACK1 LOW L #OB81_RACK_CPU AW W#16#700 L W#16#0 ==I A #going_event R M 0.0 //BATTERY IN RACK0 LOW TAK L W#16#100 ==I A #going_event R M 0.1 //BATTERY IN RACK1 LOW O M 0.0 //BATTERY IN RACK0 LOW O M 0.1 //BATTERY IN RACK1 LOW = M 0.2 // LOW BATTERY DETECTED END: NOP 0[/code] another sample for such a case would be output of SFC1 as it stored as BCD format.The output pattern is fix, for me there is no need to convert the value to INT and compare it with that criteria.Another sample can be found here: [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] The moral of story, if I wanted to do such tasks as shared above in LAD, for sure I disabled the "type check" and avoid frequent using calculator. Best regards Hamid Hosseini |
This contribution was helpful to1 thankful Users |
Follow us on