Consider the following code written on an S7 plc.
[attachment]
There is an inherent error in this little program. Sometimes the program works fine but more often it won't. A couple of months back when I was still learning Ladder programming, I was bothered with this problem. However, instead of reasoning I found a default path. I just replaced the T32 contact in rung 3 by "compare T32 with 1999".
Recently, when debugging a program I encountered a similar problem. This time, with a better understanding of PLCs, I decided to act like an engineer and came up with following solution:
1. swap network 2 and network 3.
2. If for some reason network 3 must follow network 2 utoh in network4 use T32 to set a bit (say, M0.0) and in network 2 replace Q0.0 with this bit.
Any more ideas?
[attachment]
There is an inherent error in this little program. Sometimes the program works fine but more often it won't. A couple of months back when I was still learning Ladder programming, I was bothered with this problem. However, instead of reasoning I found a default path. I just replaced the T32 contact in rung 3 by "compare T32 with 1999".
Recently, when debugging a program I encountered a similar problem. This time, with a better understanding of PLCs, I decided to act like an engineer and came up with following solution:
1. swap network 2 and network 3.
2. If for some reason network 3 must follow network 2 utoh in network4 use T32 to set a bit (say, M0.0) and in network 2 replace Q0.0 with this bit.
Any more ideas?