10/10/2011 8:21 AM | |
Posts: 241 Rating: (7) |
Dear All, Today I come across a S7 programwhere I have to Switch ON PLC output if corresponding input is ON.The condition is maximum 4 outputs can be switched ON at a time in any combination. I have used LAD logic to solve the problem, the logic is working upto 3 outputs but once I Switched ON the 4th and then Switched off back my counter not working (not subtracting the number of outputs those ON). 1. I used simple positive edge and (Less than 4) comparatorto switch ON any Output andAdd 1 toMWxx in the +ve edge. 2. I subtracted theMWxxx on -ve edge of any output. Can you tell me what is BUG in my program? Though it is very simple program but I have already consulted 3 engineers and all of them stopped and gave up. I have attached a S7 project , where one source code is OB1 which is working as per logic (but still don't know why it is working and others are not working). I wish to invite all other Forum users to share such simple but difficult to find BUG kind of S7 program.If you have or come across such problem please help us to know such kind of problems that can happen in the S7 Programming world. Thanks in advance for solving the issue. Regards, KayBee AttachmentOutputs4.zip (54 Downloads) |
Last edited by: KayBee at: 10/10/2011 8:28 AMMy english please |
|
10/10/2011 10:23 AM | |
Joined: 10/7/2005 Last visit: 10/11/2024 Posts: 3024 Rating: (1054)
|
Hello KayBee put simple, the bug is in the usage/placement of the --(P)--- instruction and I'll try to shed some light on this assertion: This example uses theOB 1 that was in Blocks folder of your S7 project (I have not fully evaluated theotherOB 1 permutations of it in yourSource folder, but presume they will suffer from a similar fate): Initial state:4 DI's have been switched ON. Result: 4 DQ's are ON andMW20 has a value of 4(all ok so far). With reference to the attached screendump in which I 0.0to I 0.3 are ON, all "MW20 < 4" comparisons are now no longer true. This meansthatthe --(P)---instruction is now ready again to detect a new rising edge in all of the first 4 networks (which evaluate I 0.0 to I 0.3, all of which are still ON by the way) Let's assumeI 0.2 is now switched OFF. Same scan: Q 0.2 will switch OFF and MW 20 is counted down to 3 (so far so good, this is what you want). Next scan: NW 1still has I 0.0 ON followed by a nowtrueagain "MW20 < 4"comparison (as MW 20 was counted down to 3 in the last san). Result: NW 1 has no choice but to increment MW 20 by one again and will make it a value of 4 again (which is NOT what you want but is what will have to happen). I hope this helps and the moral of the story is to be very mindful about placement of rising and falling edge detections instruction inside a rung, as they detect a rising or falling edgeof the whole preceding logic in the rung. |
Last edited by: fritz at: 10/10/2011 10:29 AMtypos and formatting Cheers |
|
This contribution was helpful to1 thankful Users |
10/10/2011 11:12 AM | |
Posts: 241 Rating: (7) |
Dear fritz, Thank you for pointing out the problem. I have shorted out now. You have described very nicely. AttachmentOutputs4_OK.zip (48 Downloads) |
This contribution was helpful to1 thankful Users |
Follow us on