drbitboy
Lifetime Supporting Member
Could you expound on the reasoning behind this? I have seen this trick given on other threads, but never found some explanation for it. Why specifically at the end of Lad 2? And what is the output that it unlatches?
As roxusa wrote, S:5/0 being 1 indicates an overflow trap has occurred (e.g. add 1 to a 16-bit Integer that is 32,767), and the overflow trip is a minor fault that triggers a major fault, if the S5:5/0 minor fault is still 1 at the exit out of LAD 2. See the image below and the RTFM for RSLogix Micro help.
The OTU does not have to be unconditional; code could also detect the minor fault and also increment a counter (floating point, or put the OTU after the increment) so it can be checked how often the overflow occurs.
Personally, I set S:2/14 (see image below) when I write code that I know will cause overflows and execute the [OTU S:5/0] at the source, so any other overflows still cause a fault and I have to go fix my code. But then, I don't write code that can harm operators or controls expensive machinery.
Btw, some time ago, one of the smarter people on this forum pointed out an edge condition when STI routines are in play and that STI routine can cause an overflow trap, the STI can interrupt and run after the OTU unlatches S:5/0 on the last rung of LAD 2 but before LAD 2 exits, in which case when the STI hands control back to LAD 2, LAD 2 exits, sees the minor fault, and triggers the major fault. I'll bet it took some time and torn-out hair to chase that puppy down.
"The only thing worse than a PLC not doing what I want it to do is when it does exactly what I told it to do."